blob: 1861cc2bbb9989364b346294781b7450dc36d90d [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include <linux/ieee80211.h>
57#include <linux/wireless.h>
58#include <net/cfg80211.h>
59#include "wlan_hdd_cfg80211.h"
60#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070061#include "wlan_hdd_p2p.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080062#ifdef FEATURE_WLAN_TDLS
63#include "wlan_hdd_tdls.h"
64#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
66
67v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
68
Shailender Karmuchia734f332013-04-19 14:02:48 -070069struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070070{
71 u_char ether_addr_octet[6];
72};
73// These are needed to recognize WPA and RSN suite types
74#define HDD_WPA_OUI_SIZE 4
75v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
76v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
77v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
78v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
79v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
80v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
81#ifdef FEATURE_WLAN_CCX
82v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
83#endif /* FEATURE_WLAN_CCX */
84#define HDD_RSN_OUI_SIZE 4
85v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
86v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
87v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
88v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
89v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
90v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
91#ifdef FEATURE_WLAN_CCX
92v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
93#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -070094#ifdef WLAN_FEATURE_11W
95v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
96#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070097
Shailender Karmuchia734f332013-04-19 14:02:48 -070098#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -070099// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700100#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
101#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700102#endif
103
104#define BEACON_FRAME_IES_OFFSET 12
105
Chet Lanctot186b5732013-03-18 10:26:30 -0700106#ifdef WLAN_FEATURE_11W
107void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
108 tANI_U32 nFrameLength,
109 tANI_U8* pbFrames,
110 tANI_U8 frameType );
111#endif
112
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700113#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
114static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
115 tANI_U8 state,
116 tANI_U16 measInterval );
117static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
118static void hdd_indicateCcxAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800119static void hdd_indicateCcxBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700120
121#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
122
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530123static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
124 tCsrRoamInfo *pRoamInfo,
125 tANI_U32 roamId,
126 eRoamCmdStatus roamStatus,
127 eCsrRoamResult roamResult );
128
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530129v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
130 eConnectionState connState )
131{
132 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530133 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
134 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 pHddStaCtx->conn_info.connState = connState;
136}
137
138// returns FALSE if not connected.
139// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
140// returns the connection state. Can specify NULL if you dont' want to get the actual state.
141
Shailender Karmuchia734f332013-04-19 14:02:48 -0700142static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
143 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700144{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700145 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700147
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 // get the connection state.
149 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700150 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700152 eConnectionState_IbssConnected == connState ||
153 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 {
155 fConnected = VOS_TRUE;
156 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700157 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 {
159 fConnected = VOS_FALSE;
160 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700161
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 if ( pConnState )
163 {
164 *pConnState = connState;
165 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 return( fConnected );
168}
169
170v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
171{
172 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700173}
Jeff Johnson295189b2012-06-20 16:38:30 -0700174
175//TODO - Not used anyhwere. Can be removed.
176#if 0
177//
178v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
179{
180 v_BOOL_t fConnectedInfra = FALSE;
181 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700182
Jeff Johnson295189b2012-06-20 16:38:30 -0700183 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700184 {
185 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 {
187 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700188 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700190
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 return( fConnectedInfra );
192}
193#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700194
Jeff Johnson295189b2012-06-20 16:38:30 -0700195static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
196{
197 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700198
Jeff Johnson295189b2012-06-20 16:38:30 -0700199 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700200
201 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700202 {
203 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
204 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700205
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 return( fConnected );
207}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
210{
211 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700214
215 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 {
217 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
218 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700219
Jeff Johnson295189b2012-06-20 16:38:30 -0700220 return( fConnected );
221}
222
223static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
224{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700225 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 {
227 case eCSR_BSS_TYPE_INFRASTRUCTURE:
228 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
229 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 case eCSR_BSS_TYPE_IBSS:
232 case eCSR_BSS_TYPE_START_IBSS:
233 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
234 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700235
236 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700237 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700238 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 default:
240 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700241 break;
242 }
243
Jeff Johnson295189b2012-06-20 16:38:30 -0700244}
245
246void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
247{
248 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
249 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700250
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700252
253 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700255 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
257 {
258 VOS_ASSERT( pRoamInfo->pBssDesc );
259 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
260
261 // Save the Station ID for this station from the 'Roam Info'.
262 //For IBSS mode, staId is assigned in NEW_PEER_IND
263 //For reassoc, the staID doesn't change and it may be invalid in this structure
264 //so no change here.
265 if( !pRoamInfo->fReassocReq )
266 {
267 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
268 }
269 }
270 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700271 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700273 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 else
275 {
276 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
277 // or we can't function.
278 VOS_ASSERT( 0 );
279 }
280
281 // notify WMM
282 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
283
284 if( !pRoamInfo->u.pConnectedProfile )
285 {
286 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
287 }
288 else
289 {
290 // Get Multicast Encryption Type
291 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
292 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
293 // Get Unicast Encrytion Type
294 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
295 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
296
297 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
298
299 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
300
301 // Save the ssid for the connection
302 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530303
304 // Save dot11mode in which STA associated to AP
305 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700307 }
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700310 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
311
Jeff Johnson295189b2012-06-20 16:38:30 -0700312}
313
314#if defined(WLAN_FEATURE_VOWIFI_11R)
315/*
316 * Send the 11R key information to the supplicant.
317 * Only then can the supplicant generate the PMK-R1.
318 * (BTW, the CCX supplicant also needs the Assoc Resp IEs
319 * for the same purpose.)
320 *
321 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
322 * this contains the R1KHID, R0KHID and the MDID.
323 * For FT, this consists of the Reassoc Rsp FTIEs.
324 * This is the Assoc Response.
325 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700326static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 tCsrRoamInfo *pCsrRoamInfo)
328{
329 union iwreq_data wrqu;
330 char *buff;
331 unsigned int len = 0;
332 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700333
334 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 {
336 hddLog(LOGE,
337 "%s: pCsrRoamInfo->nAssocRspLength=%d",
338 __func__, (int)pCsrRoamInfo->nAssocRspLength);
339 return;
340 }
341
Shailender Karmuchia734f332013-04-19 14:02:48 -0700342 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700344 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700346 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 return;
348 }
349
350 // pFTAssocRsp needs to point to the IEs
351 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
352 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
353 (unsigned int)pFTAssocRsp[0],
354 (unsigned int)pFTAssocRsp[1]);
355
356 // We need to send the IEs to the supplicant.
357 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700358 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700360 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 return;
362 }
363
364 // Send the Assoc Resp, the supplicant needs this for initial Auth.
365 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700366 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700368 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
370
371 kfree(buff);
372}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700373#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700374
375#ifdef WLAN_FEATURE_VOWIFI_11R
376
377/*---------------------------------------------------
378 *
379 * Send the FTIEs, RIC IEs during FT. This is eventually
380 * used to send the FT events to the supplicant
381 *
382 * At the reception of Auth2 we send the RIC followed
383 * by the auth response IEs to the supplicant.
384 * Once both are received in the supplicant, an FT
385 * event is generated to the supplicant.
386 *
387 *---------------------------------------------------
388 */
389void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
390{
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 tANI_U16 auth_resp_len = 0;
392 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700393 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
394
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530395#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700396 struct cfg80211_ft_event_params ftEvent;
397 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
398 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
399 struct net_device *dev = pAdapter->dev;
400#else
401 char *buff;
402 union iwreq_data wrqu;
403 tANI_U16 str_len;
404#endif
405
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530406#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530407 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
408 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700409
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530410 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800411 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530412 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700413 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530414 hddLog(LOGW,
415 "%s: RIC IEs is of length 0 not sending RIC Information for now",
416 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700417 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700418
419 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530420 ftEvent.ric_ies_len = ric_ies_length;
421 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700422
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530423 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800424 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700425
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530426 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700427 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530428 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700429 return;
430 }
431
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530432 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530433
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530434 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700435
436 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
437 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
438
Jeff Johnson59a121e2013-11-30 09:46:08 -0800439 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
440 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
441 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530442 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800443 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
444 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
445 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700446
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530447 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700448
449#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530450 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530452 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530454 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 return;
456 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530457 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700458
Shailender Karmuchia734f332013-04-19 14:02:48 -0700459 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530461 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800462 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530463 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530465 hddLog(LOGW,
466 "%s: RIC IEs is of length 0 not sending RIC Information for now",
467 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 }
469 else
470 {
471 wrqu.data.length = str_len + ric_ies_length;
472 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
473 }
474
475 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530476 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530478 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
479 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530481 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530483 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 return;
485 }
486
487 wrqu.data.length = str_len + auth_resp_len;
488 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
489
490 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700491#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700492}
493
494#endif /* WLAN_FEATURE_VOWIFI_11R */
495
496#ifdef FEATURE_WLAN_CCX
497
498/*
499 * Send the CCX required "new AP Channel info" to the supplicant.
500 * (This keeps the supplicant "up to date" on the current channel.)
501 *
502 * The current (new AP) channel information is passed in.
503 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700504static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 tCsrRoamInfo *pCsrRoamInfo)
506{
507 union iwreq_data wrqu;
508 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700509
Shailender Karmuchia734f332013-04-19 14:02:48 -0700510
511 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 {
513 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800514 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 __func__, descriptor);
516 return;
517 }
518
519 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800520 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 memset(&wrqu, '\0', sizeof(wrqu));
522 wrqu.freq.m = descriptor->channelId;
523 wrqu.freq.e = 0;
524 wrqu.freq.i = 0;
525 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
526}
527
528#endif /* FEATURE_WLAN_CCX */
529
530void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
531{
532 union iwreq_data wrqu;
533 u8 *pBeaconIes;
534 u8 currentLen = 0;
535 char *buff;
536 int totalIeLen = 0, currentOffset = 0, strLen;
537
538 memset(&wrqu, '\0', sizeof(wrqu));
539
540 if (0 == pCsrRoamInfo->nBeaconLength)
541 {
542 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
543 return;
544 }
545 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700546 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700548 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 return;
550 }
551
552 // pBeaconIes needs to point to the IEs
553 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
554 (unsigned int)pBeaconIes[0],
555 (unsigned int)pBeaconIes[1]);
556 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700557
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 // We need to send the IEs to the supplicant.
559 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700560 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700562 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 return;
564 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700565 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
567 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
568 currentLen = strLen + 1;
569
570 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
571 do
572 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700573 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 * max size and send it to supplicant. Changes are done in supplicant to handle this */
575 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
576 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
577 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
578 currentOffset += currentLen;
579 totalIeLen -= currentLen;
580 wrqu.data.length = strLen + 1 + currentLen;
581 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700582 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 else
584 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
585
586 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
587 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
588 } while (totalIeLen > 0);
589
590 kfree(buff);
591}
592
593static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
594{
595 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
596 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
597 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
598 union iwreq_data wrqu;
599 int we_event;
600 char *msg;
601 int type = -1;
602
Shailender Karmuchia734f332013-04-19 14:02:48 -0700603#if defined (WLAN_FEATURE_VOWIFI_11R)
604 // Added to find the auth type on the fly at run time
605 // rather than with cfg to see if FT is enabled
606 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
608#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700609
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700611 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700613
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
615 {
616 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
617 type = WLAN_STA_ASSOC_DONE_IND;
618
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700619#ifdef WLAN_FEATURE_P2P_DEBUG
620 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
621 {
622 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
623 {
624 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
625 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
626 "Connecting state to Connected State for 8-way "
627 "Handshake");
628 }
629 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
630 {
631 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
632 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
633 "Connecting state to P2P Client Connection Completed");
634 }
635 }
636#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800637 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
638 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800639 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
641
642 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
643 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
644 * and fFTEnable is TRUE */
645#ifdef WLAN_FEATURE_VOWIFI_11R
646 // Send FT Keys to the supplicant when FT is enabled
647 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700648 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Jeff Johnson295189b2012-06-20 16:38:30 -0700649#ifdef FEATURE_WLAN_CCX
650 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
651 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
652#endif
653 )
654 {
655 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
656 }
657#endif
658 }
659 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
660 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700661 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800663 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
664 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 }
666 else /* Not Associated */
667 {
668 pr_info("wlan: disconnected\n");
669 type = WLAN_STA_DISASSOC_DONE_IND;
670 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
671 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700672 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673
674 msg = NULL;
675 /*During the WLAN uninitialization,supplicant is stopped before the
676 driver so not sending the status of the connection to supplicant*/
677 if(pHddCtx->isLoadUnloadInProgress != TRUE)
678 {
679 wireless_send_event(dev, we_event, &wrqu, msg);
680#ifdef FEATURE_WLAN_CCX
681 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700682 {
683 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
684 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
686 }
687#endif
688 }
689 send_btc_nlink_msg(type, 0);
690}
691
692void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
693{
694 // Remove staId, bssId and peerMacAddress
695 pHddStaCtx->conn_info.staId [ 0 ] = 0;
696 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
697 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
698
699 // Clear all security settings
700 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
701 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
702 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
703
704 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700705 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700706
707 // Set not-connected state
708 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700709 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Jeff Johnson295189b2012-06-20 16:38:30 -0700710
711 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
712}
713/* TODO Revist this function. and data path */
714static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
715{
716 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700717 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
718
719 if (WLAN_HDD_IBSS != pAdapter->device_mode)
720 {
721 hdd_disconnect_tx_rx(pAdapter);
722 }
723 else
724 {
725 // Need to cleanup all queues only if the last peer leaves
726 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
727 {
728 netif_tx_disable(pAdapter->dev);
729 netif_carrier_off(pAdapter->dev);
730 hdd_disconnect_tx_rx(pAdapter);
731 }
732 else
733 {
734 // There is atleast one more peer, do not cleanup all queues
735 hdd_flush_ibss_tx_queues(pAdapter, staId);
736 }
737 }
738
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
740 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
741 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700744 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700745 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 }
747 return( vosStatus );
748}
749
750
751static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
752 tANI_U32 roamId, eRoamCmdStatus roamStatus,
753 eCsrRoamResult roamResult )
754{
755 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700756 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 struct net_device *dev = pAdapter->dev;
758 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
759 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700760 v_U8_t sta_id;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700761
762 // Sanity check
763 if(dev == NULL)
764 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530765 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700766 "%s: net_dev is released return", __func__);
767 return eHAL_STATUS_FAILURE;
768 }
769
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 // notify apps that we can't pass traffic anymore
771 netif_tx_disable(dev);
772 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700773
Jeff Johnsone7245742012-09-05 17:12:55 -0700774 INIT_COMPLETION(pAdapter->disconnect_comp_var);
775 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 /* If only STA mode is on */
777 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
778 {
779 pHddCtx->isAmpAllowed = VOS_TRUE;
780 }
781 hdd_clearRoamProfileIe( pAdapter );
782
783 // indicate 'disconnect' status to wpa_supplicant...
784 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 /* indicate disconnected event to nl80211 */
786 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
787 {
788 /*During the WLAN uninitialization,supplicant is stopped before the
789 driver so not sending the status of the connection to supplicant*/
790 if(pHddCtx->isLoadUnloadInProgress != TRUE)
791 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700792 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
793 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700795#ifdef WLAN_FEATURE_P2P_DEBUG
796 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
797 {
798 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
799 {
800 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
801 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
802 "and moved to disconnected state");
803 }
804 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
805 {
806 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
807 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
808 "and moved to inactive state");
809 }
810 }
811#endif
812
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
814 if( eCSR_ROAM_LOSTLINK == roamStatus )
815 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700816 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 }
818 else
819 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700820 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 }
822
823 //If the Device Mode is Station
824 // and the P2P Client is Connected
825 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700826
827 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700828 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700829 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 {
831 //Enable BMPS only of other Session is P2P Client
832 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700833 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700834
835 if (NULL != pVosContext)
836 {
837 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
838
839 if(NULL != pHddCtx)
840 {
841 //Only P2P Client is there Enable Bmps back
842 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700843 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530845 if (pHddCtx->hdd_wlan_suspended)
846 {
847 hdd_set_pwrparams(pHddCtx);
848 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530850 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 }
852 }
853 }
854 }
855 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700856
krunal soni3fc26642013-10-08 22:41:42 -0700857 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
858 {
859 sta_id = IBSS_BROADCAST_STAID;
860 }
861 else
862 {
863 sta_id = pHddStaCtx->conn_info.staId[0];
864 }
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530865 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530866#if defined(WLAN_FEATURE_VOWIFI_11R)
867 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
868#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 //We should clear all sta register with TL, for now, only one.
krunal soni3fc26642013-10-08 22:41:42 -0700870 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
Jeff Johnson43971f52012-07-17 12:26:56 -0700871 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 "hdd_roamDeregisterSTA() failed to for staID %d. "
875 "Status= %d [0x%x]",
krunal soni3fc26642013-10-08 22:41:42 -0700876 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700877
878 status = eHAL_STATUS_FAILURE;
879 }
880
krunal soni3fc26642013-10-08 22:41:42 -0700881 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 // Clear saved connection information in HDD
883 hdd_connRemoveConnectInfo( pHddStaCtx );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530884#ifdef WLAN_FEATURE_GTK_OFFLOAD
885 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
886 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
887 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530888 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
889 sizeof (tSirGtkOffloadParams));
890 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530891 }
892#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700893
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800894#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -0700895 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
896 {
897 wlan_hdd_tdls_disconnection_callback(pAdapter);
898 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800899#endif
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 //Unblock anyone waiting for disconnect to complete
902 complete(&pAdapter->disconnect_comp_var);
903 return( status );
904}
905static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
906 tCsrRoamInfo *pRoamInfo,
907 v_U8_t staId,
908 v_MACADDR_t *pPeerMacAddress,
909 tSirBssDescription *pBssDesc )
910{
911 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
912 WLAN_STADescType staDesc = {0};
913 eCsrEncryptionType connectedCipherAlgo;
914 v_BOOL_t fConnected;
915 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
916 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700917 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700918
919 if ( NULL == pBssDesc)
920 {
921 return VOS_STATUS_E_FAILURE;
922 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 // Get the Station ID from the one saved during the assocation.
924 staDesc.ucSTAId = staId;
925
926 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700928 staDesc.wSTAType = WLAN_STA_INFRA;
929
930 // grab the bssid from the connection info in the adapter structure and hand that
931 // over to TL when registering.
932 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
933 }
934 else
935 {
936 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700938
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
940 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
941 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
942 // pass when making an Infrastructure connection.
943 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
944 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
945 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700946
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
948
949 // set the QoS field appropriately
950 if (hdd_wmm_is_active(pAdapter))
951 {
952 staDesc.ucQosEnabled = 1;
953 }
954 else
955 {
956 staDesc.ucQosEnabled = 0;
957 }
958
959 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
960 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
961 {
962 staDesc.ucProtectedFrame = 1;
963 }
964 else
965 {
966 staDesc.ucProtectedFrame = 0;
967
968 }
969
970#ifdef FEATURE_WLAN_CCX
971 staDesc.ucIsCcxSta = pRoamInfo->isCCXAssoc;
972#endif //FEATURE_WLAN_CCX
973
974#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
975 /* check whether replay check is valid for the station or not */
976 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
977 {
978 /* Encryption mode is either TKIP or AES
979 and replay check is valid for only these
980 two encryption modes */
981 staDesc.ucIsReplayCheckValid = VOS_TRUE;
982 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
983 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
984 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700985
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 else
987 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700988 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700990 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
992 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
993 }
994#endif
995
996#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700997 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 if (pAdapter->wapi_info.fIsWapiSta)
999 {
1000 staDesc.ucIsWapiSta = 1;
1001 }
1002 else
1003 {
1004 staDesc.ucIsWapiSta = 0;
1005 }
1006#endif /* FEATURE_WLAN_WAPI */
1007
1008 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1009 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1010
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 // UMA is Not ready yet, Xlation will be done by TL
1012 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 staDesc.ucSwFrameRXXlation = 1;
1014 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 staDesc.ucQosEnabled );
1017 // Initialize signatures and state
1018 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1019 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1020 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1021 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001022 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001023 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 -07001024 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1025 hdd_rx_packet_cbk,
1026 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 hdd_tx_fetch_packet_cbk, &staDesc,
1028 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001029
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1031 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001033 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001035 return vosStatus;
1036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001038 if ( cfg_param->dynSplitscan &&
1039 ( VOS_TIMER_STATE_RUNNING !=
1040 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1041 {
1042 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1043 cfg_param->trafficMntrTmrForSplitScan);
1044 }
1045
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301046 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1047 // then go to 'authenticated'. For all other authentication types
1048 // (those that donot require upper layer authentication) we can put
1049 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001050 if (staDesc.wSTAType != WLAN_STA_IBSS)
1051 VOS_ASSERT( fConnected );
1052
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301053 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001054 {
1055 // Connections that do not need Upper layer auth, transition TL directly
1056 // to 'Authenticated' state.
1057 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1058 WLANTL_STA_AUTHENTICATED );
1059
1060 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1061 }
1062 else
1063 {
1064 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301065 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1066 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001067 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301068 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001069 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 return( vosStatus );
1072}
1073
Jeff Johnson295189b2012-06-20 16:38:30 -07001074static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1075 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1076{
1077 unsigned int len = 0;
1078 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001079 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 tANI_U32 rspRsnLength = 0;
1081 struct ieee80211_channel *chan;
1082
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001083 if (!rspRsnIe)
1084 {
1085 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001086 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001087 }
1088
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001090 {
1091 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1092 goto done;
1093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001094
1095 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001096 {
1097 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1098 goto done;
1099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001100
1101 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1102 pCsrRoamInfo->nAssocReqLength);
1103 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001104 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001105
1106 //pFTAssocRsp needs to point to the IEs
1107 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001108 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 (unsigned int)pFTAssocRsp[0],
1110 (unsigned int)pFTAssocRsp[1]);
1111
1112 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001113 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001116 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001117
1118 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1119 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1120 reqRsnIe, reqRsnLength,
1121 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001122
1123done:
1124 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001125}
Jeff Johnson295189b2012-06-20 16:38:30 -07001126
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301127void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1128{
1129 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1130 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1131 tCsrRoamInfo roamInfo;
1132 roamInfo.fAuthRequired = FALSE;
1133 vos_mem_copy(roamInfo.bssid,
1134 pHddStaCtx->roam_info.bssid,
1135 WNI_CFG_BSSID_LEN);
1136 vos_mem_copy(roamInfo.peerMac,
1137 pHddStaCtx->roam_info.peerMac,
1138 WNI_CFG_BSSID_LEN);
1139
1140 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1141 &roamInfo,
1142 pHddStaCtx->roam_info.roamId,
1143 pHddStaCtx->roam_info.roamStatus,
1144 eCSR_ROAM_RESULT_AUTHENTICATED);
1145 if (halStatus != eHAL_STATUS_SUCCESS)
1146 {
1147 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1148 }
1149 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1150}
1151
Shailender Karmuchia734f332013-04-19 14:02:48 -07001152static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1153 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 eCsrRoamResult roamResult )
1155{
1156 struct net_device *dev = pAdapter->dev;
1157 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1158 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1159 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001160 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1161 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001162#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 int ft_carrier_on = FALSE;
1164#endif
1165 int status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001166
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1168 {
1169 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1170
1171 // Save the connection info from CSR...
1172 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1173#ifdef FEATURE_WLAN_WAPI
1174 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1175 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1176 {
1177 pAdapter->wapi_info.fIsWapiSta = 1;
1178 }
1179 else
1180 {
1181 pAdapter->wapi_info.fIsWapiSta = 0;
1182 }
1183#endif /* FEATURE_WLAN_WAPI */
1184
1185 // indicate 'connect' status to userspace
1186 hdd_SendAssociationEvent(dev,pRoamInfo);
1187
1188
Shailender Karmuchia734f332013-04-19 14:02:48 -07001189 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 INIT_COMPLETION(pAdapter->linkup_event_var);
1191
1192 /*
1193 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1194 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 -07001195 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 know that the device is getting activated properly.
1197 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001198#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 if (pHddStaCtx->ft_carrier_on == FALSE)
1200 {
1201#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001202 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 pAdapter->isLinkUpSvcNeeded = TRUE;
1204
Shailender Karmuchia734f332013-04-19 14:02:48 -07001205 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 pAdapter->isLinkUpSvcNeeded = TRUE;
1207
1208 // Switch on the Carrier to activate the device
1209 netif_carrier_on(dev);
1210
1211 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1212 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1213 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001214 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 {
1216 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1217 }
1218
1219 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1220 pAdapter->isLinkUpSvcNeeded = FALSE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001221#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001223 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 }
1227#endif
1228 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1229
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001230#ifdef FEATURE_WLAN_TDLS
1231 wlan_hdd_tdls_connection_callback(pAdapter);
1232#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 //For reassoc, the station is already registered, all we need is to change the state
1234 //of the STA in TL.
1235 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1236 if( !pRoamInfo->fReassocReq )
1237 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001238 struct cfg80211_bss *bss;
1239#ifdef WLAN_FEATURE_VOWIFI_11R
1240 u8 *pFTAssocRsp = NULL;
1241 unsigned int assocRsplen = 0;
1242 u8 *pFTAssocReq = NULL;
1243 unsigned int assocReqlen = 0;
1244 struct ieee80211_channel *chan;
1245#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001248
1249 /* add bss_id to cfg80211 data base */
1250 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1251 if (NULL == bss)
1252 {
1253 pr_err("wlan: Not able to create BSS entry\n");
1254 return eHAL_STATUS_FAILURE;
1255 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001256#ifdef WLAN_FEATURE_VOWIFI_11R
1257 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001258 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001260
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001261 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001262 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001263 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001264 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001265 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001266 // pFTAssocRsp needs to point to the IEs
1267 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1268 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1269 (unsigned int)pFTAssocRsp[0],
1270 (unsigned int)pFTAssocRsp[1]);
1271 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001272 }
1273 else
1274 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001275 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1276 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001277 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001278
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001279 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001280 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001281 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001282 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001283 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001284 if(!ft_carrier_on)
1285 {
1286 // pFTAssocReq needs to point to the IEs
1287 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1288 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1289 (unsigned int)pFTAssocReq[0],
1290 (unsigned int)pFTAssocReq[1]);
1291 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1292 }
1293 else
1294 {
1295 /* This should contain only the FTIEs */
1296 assocReqlen = pRoamInfo->nAssocReqLength;
1297 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001298 }
1299 else
1300 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001301 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1302 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001303 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001304
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001305 if(ft_carrier_on)
1306 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001307 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001308 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001309 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1310 (int)pRoamInfo->pBssDesc->channelId);
Arif Hussain6d2a3322013-11-17 19:50:10 -08001311 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001312 assocRsplen);
1313 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1314 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1315 GFP_KERNEL);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301316 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1317 {
1318 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1319 pRoamInfo->fAuthRequired = FALSE;
1320
1321 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1322 pRoamInfo->bssid,
1323 HDD_MAC_ADDR_LEN);
1324 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1325 pRoamInfo->peerMac,
1326 HDD_MAC_ADDR_LEN);
1327 pHddStaCtx->roam_info.roamId = roamId;
1328 pHddStaCtx->roam_info.roamStatus = roamStatus;
1329 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1330 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001331 }
1332 else
1333 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001334 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001335 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001336 cfg80211_connect_result(dev, pRoamInfo->bssid,
1337 pFTAssocReq, assocReqlen,
1338 pFTAssocRsp, assocRsplen,
1339 WLAN_STATUS_SUCCESS,
1340 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001341 }
1342 }
1343 else
1344#endif
1345 {
1346 /* wpa supplicant expecting WPA/RSN IE in connect result */
1347 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1348 pAdapter->sessionId,
1349 &reqRsnLength,
1350 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001351
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001352 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1353 pAdapter->sessionId,
1354 &rspRsnLength,
1355 rspRsnIe);
1356#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1357 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001358 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001359 else
1360#endif /* FEATURE_WLAN_CCX */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001361
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001362 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301363 hddLog(VOS_TRACE_LEVEL_INFO,
1364 "%s: sending connect indication to nl80211:"
1365 " for bssid " MAC_ADDRESS_STR
1366 " reason:%d and Status:%d\n",
1367 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1368 roamResult, roamStatus);
1369
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001370 /* inform connect result to nl80211 */
1371 cfg80211_connect_result(dev, pRoamInfo->bssid,
1372 reqRsnIe, reqRsnLength,
1373 rspRsnIe, rspRsnLength,
1374 WLAN_STATUS_SUCCESS,
1375 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 }
Yue Maf49ba872013-08-19 12:04:25 -07001378 cfg80211_put_bss(
1379#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1380 pHddCtx->wiphy,
1381#endif
1382 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 // Register the Station with TL after associated...
1384 vosStatus = hdd_roamRegisterSTA( pAdapter,
1385 pRoamInfo,
1386 pHddStaCtx->conn_info.staId[ 0 ],
1387 NULL,
1388 pRoamInfo->pBssDesc );
1389 }
1390 else
1391 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001392 /* wpa supplicant expecting WPA/RSN IE in connect result */
1393 /* in case of reassociation also need to indicate it to supplicant */
1394 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1395 pAdapter->sessionId,
1396 &reqRsnLength,
1397 reqRsnIe);
1398
1399 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301401 if( pRoamInfo->fAuthRequired )
1402 {
1403 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1404 pHddStaCtx->conn_info.staId[ 0 ],
1405 WLANTL_STA_CONNECTED );
1406 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1407 }
1408 else
1409 {
1410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1411 "%s: staId: %d Changing TL state to AUTHENTICATED",
1412 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1413 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1414 pHddStaCtx->conn_info.staId[ 0 ],
1415 WLANTL_STA_AUTHENTICATED );
1416 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 }
1419
1420 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1421 {
1422 // perform any WMM-related association processing
1423 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1424 }
1425 else
1426 {
1427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001428 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 vosStatus, vosStatus );
1430 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001431#ifdef WLAN_FEATURE_11W
1432 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1433 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1434#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 // Start the Queue
1436 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001437 }
1438 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1441
1442 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001443 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001444 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1445 " reason:%d and Status:%d\n",
1446 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1447 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001448 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001449 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1450 " reason:%d and Status:%d\n",
1451 MAC_ADDR_ARRAY(pWextState->req_bssId),
1452 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001453
1454 /*Handle all failure conditions*/
1455 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1456 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1457 {
1458 pHddCtx->isAmpAllowed = VOS_TRUE;
1459 }
1460
1461 //If the Device Mode is Station
1462 // and the P2P Client is Connected
1463 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001464
1465 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001466 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001467 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1468 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 (vos_concurrent_sessions_running()))
1470 {
1471 //Enable BMPS only of other Session is P2P Client
1472 hdd_context_t *pHddCtx = NULL;
1473 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1474
1475 if (NULL != pVosContext)
1476 {
1477 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1478
1479 if(NULL != pHddCtx)
1480 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301481 //Only P2P Client is there Enable Bmps back
1482 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
1483 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
1484 {
1485 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001486 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301487 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001488 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301489 hdd_enable_bmps_imps(pHddCtx);
1490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 }
1492 }
1493 }
1494
James Zmudafbf5ffc2013-03-25 12:45:35 -07001495 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001496 * completed operation - with a ASSOCIATION_FAILURE status.*/
1497 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
Jeff Johnsone7245742012-09-05 17:12:55 -07001498 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301499 if (pRoamInfo)
1500 hddLog(VOS_TRACE_LEVEL_ERROR,
1501 "%s: send connect failure to nl80211:"
1502 " for bssid " MAC_ADDRESS_STR
1503 " reason:%d and Status:%d\n" ,
1504 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1505 roamResult, roamStatus);
1506 else
1507 hddLog(VOS_TRACE_LEVEL_ERROR,
1508 "%s: connect failed:"
1509 " for bssid " MAC_ADDRESS_STR
1510 " reason:%d and Status:%d\n" ,
1511 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1512 roamResult, roamStatus);
1513
James Zmudafbf5ffc2013-03-25 12:45:35 -07001514 /* inform association failure event to nl80211 */
1515 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1516 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001517 if (pRoamInfo)
1518 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1519 NULL, 0, NULL, 0,
1520 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1521 GFP_KERNEL );
1522 else
1523 cfg80211_connect_result ( dev, pWextState->req_bssId,
1524 NULL, 0, NULL, 0,
1525 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1526 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001527 }
1528 else
1529 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001530 if (pRoamInfo)
1531 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1532 NULL, 0, NULL, 0,
1533 WLAN_STATUS_UNSPECIFIED_FAILURE,
1534 GFP_KERNEL );
1535 else
1536 cfg80211_connect_result ( dev, pWextState->req_bssId,
1537 NULL, 0, NULL, 0,
1538 WLAN_STATUS_UNSPECIFIED_FAILURE,
1539 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001540 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001542
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001543 /*Clear the roam profile*/
1544 hdd_clearRoamProfileIe( pAdapter );
1545
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 netif_tx_disable(dev);
1547 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001548
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 }
1550
1551 return eHAL_STATUS_SUCCESS;
1552}
1553
1554/**============================================================================
1555 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001556 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001558
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001560static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1561 tCsrRoamInfo *pRoamInfo,
1562 tANI_U32 roamId,
1563 eRoamCmdStatus roamStatus,
1564 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001565{
Jeff Johnson81c17882013-05-03 09:53:35 -07001566 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1567 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1568
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 switch( roamResult )
1570 {
1571 // both IBSS Started and IBSS Join should come in here.
1572 case eCSR_ROAM_RESULT_IBSS_STARTED:
1573 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001574 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001576 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1577 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001578
Jeff Johnson81c17882013-05-03 09:53:35 -07001579 if (NULL == pRoamInfo)
1580 {
1581 VOS_ASSERT(0);
1582 return;
1583 }
1584
1585 /* When IBSS Started comes from CSR, we need to move
1586 * connection state to IBSS Disconnected (meaning no peers
1587 * are in the IBSS).
1588 */
1589 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1590 eConnectionState_IbssDisconnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001591 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1592 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1593 IBSS_BROADCAST_STAID,
1594 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001595
Jeff Johnson81c17882013-05-03 09:53:35 -07001596 if (pRoamInfo->pBssDesc)
1597 {
1598 struct cfg80211_bss *bss;
1599
1600 /* we created the IBSS, notify supplicant */
1601 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1602 MAC_ADDRESS_STR,
1603 __func__, pAdapter->dev->name,
1604 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1605
1606 /* we must first give cfg80211 the BSS information */
1607 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1608 if (NULL == bss)
1609 {
1610 hddLog(VOS_TRACE_LEVEL_ERROR,
1611 "%s: %s: unable to create IBSS entry",
1612 __func__, pAdapter->dev->name);
1613 return;
1614 }
1615
1616 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001617 cfg80211_put_bss(
1618#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1619 pHddCtx->wiphy,
1620#endif
1621 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001622 }
1623
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 break;
1625 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001626
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1628 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001629 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1630 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 break;
1632 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001633
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001635 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1636 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001638 }
1639
Jeff Johnson81c17882013-05-03 09:53:35 -07001640 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641}
1642
1643/**============================================================================
1644 *
1645 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1646 This information is passed to iwconfig later. The peer that joined
1647 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001648 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001650
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 ===========================================================================*/
1652static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1653{
1654 int fSuccess = FALSE;
1655 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001656
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1658 {
1659 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1660 {
1661 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001662
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001664
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 fSuccess = TRUE;
1666 break;
1667 }
1668 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001669
1670 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001671}
1672/**============================================================================
1673 *
1674 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001675 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001677
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001679static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001680{
1681 int fSuccess = FALSE;
1682 int idx = 0;
1683 v_U8_t valid_idx = 0;
1684 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001685 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001686 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001687
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1689 {
1690 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1691 {
1692 pHddStaCtx->conn_info.staId[ idx ] = 0;
1693
1694 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1695
1696 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001697
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 // Note the deleted Index, if its 0 we need special handling
1699 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001700
1701 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 }
1703 else
1704 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001705 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 {
1707 valid_idx = idx;
1708 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001709 else
1710 {
1711 // Found an empty slot
1712 empty_slots++;
1713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 }
1715 }
1716
Ravi Joshi8a934352013-09-25 16:46:58 -07001717 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1718 {
1719 // Last peer departed, set the IBSS state appropriately
1720 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001721 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001722 "Last IBSS Peer Departed!!!" );
1723 }
1724
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 // Find next active staId, to have a valid sta trigger for TL.
1726 if (fSuccess == TRUE)
1727 {
1728 if (del_idx == 0)
1729 {
1730 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1731 {
1732 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1733 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1734 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1735
1736 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1737 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1738 }
1739 }
1740 }
1741 return( fSuccess );
1742}
1743
1744/**============================================================================
1745 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001746 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001748
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 ===========================================================================*/
1750static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1751{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001752 struct cfg80211_bss *bss;
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1754 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1755 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1756
1757 // Save the connection info from CSR...
1758 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1759
1760 // Send the bssid address to the wext.
1761 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001762 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001763 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1764 if (NULL == bss)
1765 {
1766 hddLog(VOS_TRACE_LEVEL_ERROR,
1767 "%s: %s: unable to create IBSS entry",
1768 __func__, pAdapter->dev->name);
1769 return eHAL_STATUS_FAILURE;
1770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 /* send ibss join indication to nl80211 */
1772 cfg80211_ibss_joined(pAdapter->dev, &pRoamInfo->bssid[0], GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001773 cfg80211_put_bss(
1774#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1775 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1776#endif
1777 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001778
1779 return( eHAL_STATUS_SUCCESS );
1780}
1781/**============================================================================
1782 *
1783 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001784
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001786static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1787 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 eCsrRoamResult roamResult )
1789{
1790 eCsrEncryptionType connectedCipherAlgo;
1791 v_BOOL_t fConnected = FALSE;
1792 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1793 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1794 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1795 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07001796
1797 if (NULL == pRoamInfo)
1798 {
1799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
1800 return eHAL_STATUS_FAILURE;
1801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001803 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 // not require upper layer authentication) we can put TL directly into 'authenticated'
1805 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1807 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
1808 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001809
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1811 if( fConnected )
1812 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001813 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
1814 {
1815 v_U8_t staId;
1816
1817 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
1818
1819 if ( 0 == memcmp( pRoamInfo->peerMac,
1820 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
1821 {
1822 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1823 IBSS_BROADCAST_STAID);
1824 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1825 }
1826 else
1827 {
1828 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
1829 (v_MACADDR_t*)pRoamInfo->peerMac,
1830 &staId);
1831 if ( VOS_STATUS_SUCCESS == vosStatus )
1832 {
1833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1834 "WLAN TL STA Ptk Installed for STAID=%d", staId);
1835 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1836 staId);
1837 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1838 }
1839 }
1840 }
1841 else
1842 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301843 // TODO: Considering getting a state machine in HDD later.
1844 // This routine is invoked twice. 1)set PTK 2)set GTK.
1845 // The folloing if statement will be TRUE when setting GTK.
1846 // At this time we don't handle the state in detail.
1847 // Related CR: 174048 - TL not in authenticated state
1848 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
1849 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
1850 {
1851 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
1852 "for StaId= %d. Changing TL state to AUTHENTICATED",
1853 pHddStaCtx->conn_info.staId[ 0 ] );
1854
1855 // Connections that do not need Upper layer authentication,
1856 // transition TL to 'Authenticated' state after the keys are set.
1857 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1858 pHddStaCtx->conn_info.staId[ 0 ],
1859 WLANTL_STA_AUTHENTICATED );
1860
1861 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1862 }
1863 else
1864 {
1865 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1866 pHddStaCtx->conn_info.staId[ 0 ]);
1867 }
1868
1869 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301872 else
1873 {
1874 // possible disassoc after issuing set key and waiting set key complete
1875 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1876 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001877
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 EXIT();
1879 return( eHAL_STATUS_SUCCESS );
1880}
1881/**============================================================================
1882 *
1883 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1884 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001885static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07001887{
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1889
1890 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
1891 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
1892 {
1893 struct iw_michaelmicfailure msg;
1894 union iwreq_data wreq;
1895 memset(&msg, '\0', sizeof(msg));
1896 msg.src_addr.sa_family = ARPHRD_ETHER;
1897 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08001898 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
1899 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001900
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
1902 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001903 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 msg.flags = IW_MICFAILURE_PAIRWISE;
1905 memset(&wreq, 0, sizeof(wreq));
1906 wreq.data.length = sizeof(msg);
1907 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001909 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 pRoamInfo->u.pMICFailureInfo->taMacAddr,
1911 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
1912 NL80211_KEYTYPE_GROUP :
1913 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07001914 pRoamInfo->u.pMICFailureInfo->keyId,
1915 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001917
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001919
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 return( eHAL_STATUS_SUCCESS );
1921}
1922
1923/**============================================================================
1924 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001925 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001927
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001929static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1930 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 eCsrRoamResult roamResult )
1932{
1933 VOS_STATUS vosStatus;
1934
1935 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1936 switch( roamResult )
1937 {
1938 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
1939 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001940 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001941 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001942
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001943 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07001944 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1945 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1946 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001948
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
1950 {
1951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1952 "New IBSS peer but we already have the max we can handle. Can't register this one" );
1953 break;
1954 }
1955
1956 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1957
Shailender Karmuchia734f332013-04-19 14:02:48 -07001958 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1959 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
1960 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
1961
1962 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 vosStatus = hdd_roamRegisterSTA( pAdapter,
1964 pRoamInfo,
1965 pRoamInfo->staId,
1966 (v_MACADDR_t *)pRoamInfo->peerMac,
1967 pRoamInfo->pBssDesc );
1968 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1969 {
1970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001971 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 vosStatus, vosStatus );
1973 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001974 pHddStaCtx->ibss_sta_generation++;
1975 memset(&staInfo, 0, sizeof(staInfo));
1976 staInfo.filled = 0;
1977 staInfo.generation = pHddStaCtx->ibss_sta_generation;
1978
1979 cfg80211_new_sta(pAdapter->dev,
1980 (const u8 *)pRoamInfo->peerMac,
1981 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001982
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001983 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
1984 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
1985 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
1986 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
1987 {
1988 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
1989 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
1990 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
1991
1992 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001993 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001994 pHddStaCtx->ibss_enc_key.encType);
1995
1996 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1997 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
1998
1999 if ( VOS_STATUS_SUCCESS != vosStatus )
2000 {
2001 hddLog(VOS_TRACE_LEVEL_ERROR,
2002 "%s: sme_RoamSetKey failed, returned %d",
2003 __func__, vosStatus);
2004 return VOS_STATUS_E_FAILURE;
2005 }
2006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 netif_carrier_on(pAdapter->dev);
2008 netif_tx_start_all_queues(pAdapter->dev);
2009 break;
2010 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002011
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2013 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002014
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002016
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2020 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002021 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002022
Ravi Joshicc57ed42013-10-12 16:31:25 -07002023 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 {
2025 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2026 "IBSS peer departed by cannot find peer in our registration table with TL" );
2027 }
2028
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002029 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002030 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2031 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2032 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2033 pRoamInfo->staId );
2034
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2036
2037 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002038 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002039
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002040 cfg80211_del_sta(pAdapter->dev,
2041 (const u8 *)&pRoamInfo->peerMac,
2042 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 break;
2044 }
2045 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2046 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002047 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2048 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 // Stop only when we are inactive
2050 netif_tx_disable(pAdapter->dev);
2051 netif_carrier_off(pAdapter->dev);
2052 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002053
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 // Send the bssid address to the wext.
2055 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2056 // clean up data path
2057 hdd_disconnect_tx_rx(pAdapter);
2058 break;
2059 }
2060 default:
2061 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002062
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002064
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 return( eHAL_STATUS_SUCCESS );
2066}
2067
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002068#ifdef FEATURE_WLAN_TDLS
2069/**============================================================================
2070 *
2071 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2072 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2073 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002074
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002075 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002076VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2077 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002078{
2079 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002080 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002081 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2082 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002083 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2084 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002085 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2086 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002087
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002088 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2089 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002090 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002091 "%s not connected. ignored", __func__);
2092 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002093 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002094
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002095 /*
2096 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2097 * be peer MAC, here we are wokrking on direct Link
2098 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002099 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002100
2101 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002102
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002103 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002104 sizeof(tSirMacAddr) );
2105
2106 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2107 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2108
2109 /* set the QoS field appropriately ..*/
2110 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2111 : (staDesc.ucQosEnabled = 0) ;
2112
2113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002114 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002115
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002116 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002117
2118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002119 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002120
Shailender Karmuchia734f332013-04-19 14:02:48 -07002121 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002122 * UMA is ready we inform TL to do frame translation.
2123 */
2124 staDesc.ucSwFrameTXXlation = 1;
2125 staDesc.ucSwFrameRXXlation = 1;
2126 staDesc.ucAddRmvLLC = 1;
2127
2128 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002129 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002130
2131 /* tdls Direct Link do not need bcastSig */
2132 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002133
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002134#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2135 if(staDesc.ucProtectedFrame)
2136 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2137 else
2138 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2139#endif
2140
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302141 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002142
Shailender Karmuchia734f332013-04-19 14:02:48 -07002143 /* Register the Station with TL... */
2144 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2145 hdd_rx_packet_cbk,
2146 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002147 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002148
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002149 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2150 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002151 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002152 "%s: WLANTL_RegisterSTAClient() failed to register. "
2153 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002154 return vosStatus;
2155 }
2156
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002157 if ( cfg_param->dynSplitscan &&
2158 ( VOS_TIMER_STATE_RUNNING !=
2159 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2160 {
2161 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2162 cfg_param->trafficMntrTmrForSplitScan);
2163 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002164 return( vosStatus );
2165}
2166
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002167static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2168{
2169 VOS_STATUS vosStatus;
2170 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2171 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2172 {
2173 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2174 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002175 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002176 __func__, staId, vosStatus, vosStatus );
2177 }
2178 return( vosStatus );
2179}
2180
2181
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002182/*
2183 * HDD interface between SME and TL to ensure TDLS client registration with
2184 * TL in case of new TDLS client is added and deregistration at the time
2185 * TDLS client is deleted.
2186 */
2187
Shailender Karmuchia734f332013-04-19 14:02:48 -07002188eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2189 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002190 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002191 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002192 eCsrRoamResult roamResult)
2193{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002194 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002195 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002196 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002197
2198#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002200 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2201 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2202 "ADD_TDLS_PEER" :
2203 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2204 "DEL_TDLS_PEER" :
2205 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2206 "DEL_TDLS_PEER_IND" :
2207 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2208 "DEL_ALL_TDLS_PEER_IND" :
2209 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2210 "UPDATE_TDLS_PEER" :
2211 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2212 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2213 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002214#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002215 switch( roamResult )
2216 {
2217 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2218 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002219 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2220 {
2221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002222 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002223 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002224 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002225 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002226
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002227 /* check if there is available index for this new TDLS STA */
2228 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2229 {
2230 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2231 {
2232 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2233 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2234
2235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002236 ("TDLS: STA IDX at %d is %d "
2237 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002238 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002239 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002240
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002241 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002242 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2243 status = eHAL_STATUS_SUCCESS ;
2244 break ;
2245 }
2246 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002247 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002248 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002249 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2251 "wlan_hdd_tdls_set_sta_id() failed");
2252 return VOS_FALSE;
2253 }
2254
2255 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302256 /* store the ucast signature , if required for further reference. */
2257
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002258 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302259 /* start TDLS client registration with TL */
2260 status = hdd_roamRegisterTDLSSTA( pAdapter,
2261 pRoamInfo->peerMac,
2262 pRoamInfo->staId,
2263 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002264 }
2265 else
2266 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002267 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002269 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002270 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002271 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002272 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002273 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002274 break ;
2275 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002276 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2277 {
2278 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2279 {
2280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2281 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2282 }
2283 /* store the ucast signature which will be used later when
2284 * registering to TL
2285 */
2286 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2287 complete(&pAdapter->tdls_add_station_comp);
2288 break;
2289 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302290 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2291 {
2292 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2293 {
2294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2295 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2296 }
2297 complete(&pAdapter->tdls_link_establish_req_comp);
2298 break;
2299 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002300 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002301 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002302 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002303 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002304 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002305 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2306 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002307 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002309 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2310
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302311 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002312 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2313 {
2314 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2315 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2316 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002317 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002318 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
2319
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002320 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2321 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2322 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002323 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002324 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002325 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002326 break ;
2327 }
2328 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002329 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002330 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002331 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002332 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2333 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002334 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002335 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2336 "%s: Sending teardown to supplicant with reason code %u",
2337 __func__, pRoamInfo->reasonCode);
2338
2339#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302340 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002341 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002342#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002343 status = eHAL_STATUS_SUCCESS ;
2344 break ;
2345 }
2346 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2347 {
2348 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002349 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002350 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002351 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2352 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002353 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002355 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002356 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002357 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002358 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2359 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2360 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002361
2362 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[staIdx] = NULL;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002363 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002364 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002365 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2366 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002367
2368 status = eHAL_STATUS_SUCCESS ;
2369 }
2370 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302371 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002372 break ;
2373 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002374 default:
2375 {
2376 break ;
2377 }
2378 }
2379
2380 return status ;
2381}
2382#endif
2383
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002384static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2385{
2386 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2387 hdd_context_t *pHddCtx = NULL;
2388 int ret;
2389
2390 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2391 {
2392 hddLog(VOS_TRACE_LEVEL_ERROR,
2393 "%s: Bad param, pAdapter [%p]",
2394 __func__, pAdapter);
2395 return;
2396 }
2397
2398 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2399 ret = wlan_hdd_validate_context(pHddCtx);
2400 if (0 != ret)
2401 {
2402 hddLog(VOS_TRACE_LEVEL_ERROR,
2403 "%s: HDD context is not valid (%d)", __func__, ret);
2404 return;
2405 }
2406
2407 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2408 {
2409 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2410 }
2411}
2412
Shailender Karmuchia734f332013-04-19 14:02:48 -07002413eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2415{
2416 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2417 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302418 hdd_wext_state_t *pWextState = NULL;
2419 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002420 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002421 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002422
2423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002424 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002425 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002426
2427 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302428 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002429 {
2430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302431 "invalid adapter or adapter has invalid magic");
2432 return eHAL_STATUS_FAILURE;
2433 }
2434
2435 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2436 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2437
2438 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2439 {
2440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2441 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002442 return eHAL_STATUS_FAILURE;
2443 }
2444
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 switch( roamStatus )
2446 {
2447 case eCSR_ROAM_SESSION_OPENED:
2448 if(pAdapter != NULL)
2449 {
2450 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2451 complete(&pAdapter->session_open_comp_var);
2452 }
2453 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002454
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002455#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2457 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002458 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 * interface down */
2460 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302461 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2462 roamStatus, roamResult, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2464 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2465 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2467 }
2468 pHddStaCtx->ft_carrier_on = FALSE;
2469 break;
2470
2471 case eCSR_ROAM_FT_START:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002472 // When we roam for CCX and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002474 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 // eCSR_ROAM_SHOULD_ROAM will be received.
2476 // Where in we will not mark the link down
2477 // Also we want to stop tx at this point when we will be
2478 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002479 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 {
2481 struct net_device *dev = pAdapter->dev;
2482 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002483 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002484 * Deregister for this STA with TL with the objective to flush
2485 * all the packets for this STA from wmm_tx_queue. If not done here,
2486 * we would run into a race condition (CR390567) wherein TX
2487 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2488 * been deleted. And, these packets get assigned with a STA idx of
2489 * self-sta (since the peer STA has been deleted) and get transmitted
2490 * on the new channel before the reassoc request. Since there will be
2491 * no ACK on the new channel, each packet gets retransmitted which
2492 * takes several seconds before the transmission of reassoc request.
2493 * This leads to reassoc-timeout and roam failure.
2494 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002495 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2496 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2497 {
2498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2499 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2500 pHddStaCtx->conn_info.staId[0], status, status );
2501 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 }
2504 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002505 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 break;
2507#endif
2508
2509 case eCSR_ROAM_SHOULD_ROAM:
2510 // Dont need to do anything
2511 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 struct net_device *dev = pAdapter->dev;
2513 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2514 // notify apps that we can't pass traffic anymore
2515 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002516#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 if (pHddStaCtx->ft_carrier_on == FALSE)
2518 {
2519#endif
2520 netif_carrier_off(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002521#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 }
2523#endif
2524
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002525#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 //We should clear all sta register with TL, for now, only one.
2527 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2528 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2529 {
2530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2531 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2532 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002533 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 }
2537 break;
2538 case eCSR_ROAM_LOSTLINK:
2539 case eCSR_ROAM_DISASSOCIATED:
2540 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2542 "****eCSR_ROAM_DISASSOCIATED****");
2543 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2544 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002545 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2546 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302547 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002548 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002549
2550 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2551 pHddCtx->configuredMcastBcastFilter =
2552 pHddCtx->sus_res_mcastbcast_filter;
2553 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2554 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302555
Amar Singhald53568e2013-09-26 11:03:45 -07002556 hddLog(VOS_TRACE_LEVEL_INFO,
2557 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2558 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2559 pHddCtx->configuredMcastBcastFilter);
2560 hddLog(VOS_TRACE_LEVEL_INFO,
2561 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2563 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002564#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302565 /* Call to clear any MC Addr List filter applied after
2566 * successful connection.
2567 */
2568 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002569#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 }
2571 break;
2572 case eCSR_ROAM_IBSS_LEAVE:
2573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2574 "****eCSR_ROAM_IBSS_LEAVE****");
2575 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2576 break;
2577 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2579 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Gopichand Nakkala29149562013-05-10 21:43:41 +05302580 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
2581 ( (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2582 eCSR_ENCRYPT_TYPE_WEP40) ||
2583 (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2584 eCSR_ENCRYPT_TYPE_WEP104)
2585 ) &&
2586 (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07002587 )
2588 {
2589 v_U32_t roamId = 0;
2590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2591 "****WEP open authentication failed, trying with shared authentication****");
2592 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2593 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2594 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2595 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2596 }
2597 else
2598 {
Arun Kumar Khandavalli700037e2014-01-24 17:56:31 +05302599 // To Do - address probable memory leak with WEP encryption upon successful association
2600 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
2601 {
2602 //Clear saved connection information in HDD
2603 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
2604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2606 }
2607
2608 break;
2609 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002610 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 pRoamInfo, roamId, roamStatus, roamResult );
2612 break;
2613 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002614 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2615 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 break;
2617
2618 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2619 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002620 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002621
2622 case eCSR_ROAM_MIC_ERROR_IND:
2623 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2624 break;
2625
2626 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002627 {
2628 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2629
2630 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002631 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2632 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2633 (eCSR_ROAM_RESULT_NONE == roamResult))
2634 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002635 /* Send DTIM period to the FW; only if the wlan is already
2636 in suspend. This is the case with roaming (reassoc),
2637 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2638 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2639 before the ENTER_BMPS_REQ ensures Listen Interval is
2640 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002641 hdd_set_pwrparams(pHddCtx);
2642 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2643
2644 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002645 if due to unexpected scenario, if we are in BMPS,
2646 then trigger Exit and Enter BMPS to take DTIM period
2647 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002648 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2649 {
2650 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2651
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002652 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2653 iw_full_power_cbfn, pAdapter,
2654 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002655 }
2656 }
2657 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 break;
2660#ifdef WLAN_FEATURE_VOWIFI_11R
2661 case eCSR_ROAM_FT_RESPONSE:
2662 hdd_SendFTEvent(pAdapter);
2663 break;
2664#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002665#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002666 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002667 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002668 {
2669 /* Notify the supplicant of a new candidate */
2670 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2671 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002672 break;
2673#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002674
Yue Maef608272013-04-08 23:09:17 -07002675#ifdef FEATURE_WLAN_LFR_METRICS
2676 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2677 /* This event is to notify pre-auth initiation */
2678 if (VOS_STATUS_SUCCESS !=
2679 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2680 {
2681 halStatus = eHAL_STATUS_FAILURE;
2682 }
2683 break;
2684 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2685 /* This event will notify pre-auth completion in case of success */
2686 if (VOS_STATUS_SUCCESS !=
2687 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2688 pRoamInfo, 1))
2689 {
2690 halStatus = eHAL_STATUS_FAILURE;
2691 }
2692 break;
2693 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2694 /* This event will notify pre-auth completion in case of failure. */
2695 if (VOS_STATUS_SUCCESS !=
2696 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2697 pRoamInfo, 0))
2698 {
2699 halStatus = eHAL_STATUS_FAILURE;
2700 }
2701 break;
2702 case eCSR_ROAM_HANDOVER_SUCCESS:
2703 /* This event is to notify handover success.
2704 It will be only invoked on success */
2705 if (VOS_STATUS_SUCCESS !=
2706 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2707 {
2708 halStatus = eHAL_STATUS_FAILURE;
2709 }
2710 break;
2711#endif
2712
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2714 hdd_indicateMgmtFrame( pAdapter,
2715 pRoamInfo->nFrameLength,
2716 pRoamInfo->pbFrames,
2717 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302718 pRoamInfo->rxChan,
2719 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 break;
2721 case eCSR_ROAM_REMAIN_CHAN_READY:
2722 hdd_remainChanReadyHandler( pAdapter );
2723 break;
2724 case eCSR_ROAM_SEND_ACTION_CNF:
2725 hdd_sendActionCnf( pAdapter,
2726 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2727 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002728#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002729 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002730 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002731 roamId, roamStatus, roamResult );
2732 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002733 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2734 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2735 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002736#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002737#ifdef WLAN_FEATURE_11W
2738 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2739 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2740 pRoamInfo->pbFrames,
2741 pRoamInfo->frameType);
2742 break;
2743#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002744#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
2745 case eCSR_ROAM_TSM_IE_IND:
2746 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2747 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2748 break;
2749
2750 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
2751 {
2752 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
2753 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
2754 {
2755 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
2756 }
2757 break;
2758 }
2759
2760 case eCSR_ROAM_CCX_ADJ_AP_REPORT_IND:
2761 {
2762 hdd_indicateCcxAdjApRepInd(pAdapter, pRoamInfo);
2763 break;
2764 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002765
2766 case eCSR_ROAM_CCX_BCN_REPORT_IND:
2767 {
2768 hdd_indicateCcxBcnReportInd(pAdapter, pRoamInfo);
2769 break;
2770 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002771#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 default:
2773 break;
2774 }
2775 return( halStatus );
2776}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002777eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002778{
2779 eCsrAuthType auth_type;
2780 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002781 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 {
2783 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002784 } else
2785 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 {
2787 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002788 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002789#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002790 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 {
2792 // Check for 11r FT Authentication with PSK
2793 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002794 } else
2795 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 {
2797 // Check for 11R FT Authentication with 802.1X
2798 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002799 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002800#endif
2801#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002802 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 {
2804 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2805 } else
2806#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -07002807#ifdef WLAN_FEATURE_11W
2808 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2809 {
2810 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2811 } else
2812#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002813 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2815 }
2816 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002817}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002818
Shailender Karmuchia734f332013-04-19 14:02:48 -07002819eCsrAuthType
2820hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002821{
2822 eCsrAuthType auth_type;
2823 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002824 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 {
2826 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002827 } else
2828 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 {
2830 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002831 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002832#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002833 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 {
2835 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002836 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002837#endif /* FEATURE_WLAN_CCX */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002838 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2840 }
2841 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2842 return auth_type;
2843}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002844
Shailender Karmuchia734f332013-04-19 14:02:48 -07002845eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002846hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002847{
2848 eCsrEncryptionType cipher_type;
2849 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002850 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 {
2852 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002853 }
2854 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 {
2856 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002857 }
2858 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 {
2860 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002861 }
2862 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 {
2864 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002865 }
2866 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2867 {
2868 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2869 }
2870 else
2871 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2873 }
2874 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2875 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002876}
Jeff Johnson295189b2012-06-20 16:38:30 -07002877/* To find if the MAC address is NULL */
2878static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2879{
2880 int i;
2881 for (i = 0; i < length; i++)
2882 {
2883 if (0x00 != (macAddr[i]))
2884 {
2885 return FALSE;
2886 }
2887 }
2888 return TRUE;
2889} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08002890
Shailender Karmuchia734f332013-04-19 14:02:48 -07002891eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002892hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002893{
2894 eCsrEncryptionType cipher_type;
2895 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002896 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 {
2898 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002899 } else
2900 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 {
2902 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002903 } else
2904 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 {
2906 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002907 } else
2908 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 {
2910 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002911 } else
2912 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002914 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2915 } else
2916 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2918 }
2919 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2920 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002921}
Jeff Johnson295189b2012-06-20 16:38:30 -07002922
Shailender Karmuchia734f332013-04-19 14:02:48 -07002923static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2924 struct ether_addr *pBssid,
2925 eCsrEncryptionType *pEncryptType,
2926 eCsrEncryptionType *mcEncryptType,
2927 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002928#ifdef WLAN_FEATURE_11W
2929 u_int8_t *pMfpRequired,
2930 u_int8_t *pMfpCapable,
2931#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002932 u_int16_t gen_ie_len,
2933 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07002934{
2935 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002936 eHalStatus result;
2937 tDot11fIERSN dot11RSNIE;
2938 tDot11fIEWPA dot11WPAIE;
2939 tANI_U32 i;
2940 tANI_U8 *pRsnIe;
2941 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07002943 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002944
2945 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2946 flag to 0 */
2947 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2948 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2949
2950 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002951 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2952 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05302953 {
2954 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
2955 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002956 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05302957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07002959 if ( gen_ie[0] == DOT11F_EID_RSN)
2960 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002962 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2964 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05302965 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
2966 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 return -EINVAL;
2968 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002969 // Skip past the EID byte and length byte
2970 pRsnIe = gen_ie + 2;
2971 RSNIeLen = gen_ie_len - 2;
2972 // Unpack the RSN IE
2973 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2974 pRsnIe,
2975 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002977 // Copy out the encryption and authentication types
2978 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002979 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002980 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002981 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002982 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 but probably I suspect we can do something different*/
2984 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07002985 // Just translate the FIRST one
2986 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2987 //dot11RSNIE.pwise_cipher_suite_count
2988 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2989 //dot11RSNIE.gp_cipher_suite_count
2990 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07002991#ifdef WLAN_FEATURE_11W
2992 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
2993 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
2994#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07002996 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002998 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303000 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 break;
3002 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003003 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303005 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 break;
3007 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003008 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 // For right now, I assume setASSOCIATE() has passed in the bssid.
3010 vos_mem_copy(PMKIDCache[i].BSSID,
3011 pBssid, ETHER_ADDR_LEN);
3012 vos_mem_copy(PMKIDCache[i].PMKID,
3013 dot11RSNIE.pmkid[i],
3014 CSR_RSN_PMKID_SIZE);
3015 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003016
3017 if (updatePMKCache)
3018 {
3019 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003020 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003021 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003022 // Finally set the PMKSA ID Cache in CSR
3023 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3024 PMKIDCache,
3025 dot11RSNIE.pmkid_count );
3026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 }
3028 else if (gen_ie[0] == DOT11F_EID_WPA)
3029 {
3030 // Validity checks
3031 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3032 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3033 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303034 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3035 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 return -EINVAL;
3037 }
3038 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003039 pRsnIe = gen_ie + 2 + 4;
3040 RSNIeLen = gen_ie_len - (2 + 4);
3041 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3043 pRsnIe,
3044 RSNIeLen,
3045 &dot11WPAIE);
3046 // Copy out the encryption and authentication types
3047 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003048 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003050 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 //dot11WPAIE.auth_suite_count
3052 // Just translate the FIRST one
3053 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3054 //dot11WPAIE.unicast_cipher_count
3055 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3056 //dot11WPAIE.unicast_cipher_count
3057 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3058 }
3059 else
3060 {
3061 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003062 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 }
3064 return 0;
3065}
3066int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3067{
3068 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3069 v_U32_t status = 0;
3070 eCsrEncryptionType RSNEncryptType;
3071 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003072#ifdef WLAN_FEATURE_11W
3073 u_int8_t RSNMfpRequired;
3074 u_int8_t RSNMfpCapable;
3075#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 struct ether_addr bSsid; // MAC address of assoc peer
3077 // MAC address of assoc peer
3078 // But, this routine is only called when we are NOT associated.
3079 vos_mem_copy(bSsid.ether_addr_octet,
3080 pWextState->roamProfile.BSSIDs.bssid,
3081 sizeof(bSsid.ether_addr_octet));
3082 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3083 {
3084 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 else
3087 {
3088 return 0;
3089 }
3090 // The actual processing may eventually be more extensive than this.
3091 // Right now, just consume any PMKIDs that are sent in by the app.
3092 status = hdd_ProcessGENIE(pAdapter,
3093 &bSsid, // MAC address of assoc peer
3094 &RSNEncryptType,
3095 &mcRSNEncryptType,
3096 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003097#ifdef WLAN_FEATURE_11W
3098 &RSNMfpRequired,
3099 &RSNMfpCapable,
3100#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 pWextState->WPARSNIE[1]+2,
3102 pWextState->WPARSNIE);
3103 if (status == 0)
3104 {
3105 // Now copy over all the security attributes you have parsed out
3106 pWextState->roamProfile.EncryptionType.numEntries = 1;
3107 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003108
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3110 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003111
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003112 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3113 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3114 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3115 {
3116 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3117 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3118 either AES/TKIP based on group cipher configuration
3119 mentioned in the wpa_supplicant.conf.*/
3120
3121 /*Set the unicast cipher same as multicast cipher*/
3122 pWextState->roamProfile.EncryptionType.encryptionType[0]
3123 = mcRSNEncryptType;
3124 }
3125
Chet Lanctot186b5732013-03-18 10:26:30 -07003126#ifdef WLAN_FEATURE_11W
3127 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3128 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3129#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003130 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 }
3132 return 0;
3133}
3134int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3135{
3136 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3137 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3138 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3139 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003140
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003142 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003143
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 switch( pHddStaCtx->conn_info.authType)
3145 {
3146 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3147#ifdef FEATURE_WLAN_CCX
3148 case eCSR_AUTH_TYPE_CCKM_WPA:
3149 case eCSR_AUTH_TYPE_CCKM_RSN:
3150#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003151 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3152
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003154 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003156
Jeff Johnson295189b2012-06-20 16:38:30 -07003157#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003158 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3159 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3160 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003161 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003162 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3163 } else
3164 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003165 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003166 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 } else
3168#endif
3169 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3170 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003171 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3172 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3174 == IW_AUTH_KEY_MGMT_PSK) {
3175 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003176 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 }
3180 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
3181#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003182 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3183 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3184 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003185 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003186 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003188 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003189 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003190 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 } else
3192#endif
3193
3194#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003195 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3196 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003198 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003199 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003200 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3202 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003203 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 } else
3205#endif
3206
Chet Lanctot186b5732013-03-18 10:26:30 -07003207#ifdef WLAN_FEATURE_11W
3208 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3209 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3210 } else
3211#endif
3212
Shailender Karmuchia734f332013-04-19 14:02:48 -07003213 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003215 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3216 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3218 == IW_AUTH_KEY_MGMT_PSK) {
3219 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003220 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003224 break;
3225
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003227
3228 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 break;
3230 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003231
Jeff Johnson295189b2012-06-20 16:38:30 -07003232#ifdef FEATURE_WLAN_CCX
Arif Hussain6d2a3322013-11-17 19:50:10 -08003233 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003234#endif /* FEATURE_WLAN_CCX */
3235 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3236 break;
3237 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003238
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003240 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003241
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 EXIT();
3243 return 0;
3244}
3245
3246/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003247
3248 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003250 to the CSR roam profile.
3251
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 \param - dev - Pointer to the net device.
3253 - info - Pointer to the iw_request_info.
3254 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003255 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003257
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 --------------------------------------------------------------------------*/
3259
Shailender Karmuchia734f332013-04-19 14:02:48 -07003260int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 struct iw_request_info *info,
3262 union iwreq_data *wrqu, char *extra)
3263{
3264 v_U32_t status = 0;
3265 hdd_wext_state_t *pWextState;
3266 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3267 v_U32_t roamId;
3268 tCsrRoamProfile *pRoamProfile;
3269 eMib_dot11DesiredBssType connectedBssType;
3270 eCsrAuthType RSNAuthType;
3271 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003273
3274 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3275
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 ENTER();
3277
3278 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3279 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 "%s:LOGP in Progress. Ignore!!!",__func__);
3282 return 0;
3283 }
3284
3285 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3286 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3287 return -EBUSY;
3288 }
3289 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3290 return -EINVAL;
3291 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003292 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 {
3294 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3295 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3296 {
3297 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003298 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3300 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3301
3302 if(VOS_STATUS_SUCCESS == vosStatus)
3303 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3304 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3305 }
3306 }
3307 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003308 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 {
3310 return -EINVAL;
3311 }
3312 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003313 /** when cfg80211 defined, wpa_supplicant wext driver uses
3314 zero-length, null-string ssid for force disconnection.
3315 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 driver MUST return success */
3317 if ( 0 == wrqu->essid.length ) {
3318 return 0;
3319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003320
3321 status = hdd_wmm_get_uapsd_mask(pAdapter,
3322 &pWextState->roamProfile.uapsd_mask);
3323 if (VOS_STATUS_SUCCESS != status)
3324 {
3325 pWextState->roamProfile.uapsd_mask = 0;
3326 }
3327 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003328
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003330
3331 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3333 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3334 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003335
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 //set gen ie
3337 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3338
3339 //set auth
3340 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3341 }
3342#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003343 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 if (pAdapter->wapi_info.nWapiMode)
3345 {
3346 switch (pAdapter->wapi_info.wapiAuthMode)
3347 {
3348 case WAPI_AUTH_MODE_PSK:
3349 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003350 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 pRoamProfile->AuthType.numEntries = 1;
3352 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3353 break;
3354 }
3355 case WAPI_AUTH_MODE_CERT:
3356 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003357 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 pRoamProfile->AuthType.numEntries = 1;
3359 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3360 break;
3361 }
3362 } // End of switch
3363 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3364 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3365 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003366 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 pRoamProfile->EncryptionType.numEntries = 1;
3368 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3369 pRoamProfile->mcEncryptionType.numEntries = 1;
3370 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3371 }
3372 }
3373#endif /* FEATURE_WLAN_WAPI */
3374 /* if previous genIE is not NULL, update AssocIE */
3375 if (0 != pWextState->genIE.length)
3376 {
3377 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3378 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3379 pWextState->genIE.length);
3380 pWextState->assocAddIE.length = pWextState->genIE.length;
3381 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3382 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3383
3384 /* clear previous genIE after use it */
3385 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3386 }
3387
3388 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3389 pWextState->roamProfile.bWPSAssociation = FALSE;
3390
3391 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3392 pWextState->roamProfile.nAddIEAssocLength))
3393 pWextState->roamProfile.bWPSAssociation = TRUE;
3394
3395
3396 // Disable auto BMPS entry by PMC until DHCP is done
3397 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3398
Shailender Karmuchia734f332013-04-19 14:02:48 -07003399 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003401
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003402 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3403 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003404 hdd_select_cbmode(pAdapter,
3405 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3406 }
3407 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3408 &(pWextState->roamProfile), &roamId);
3409 pRoamProfile->ChannelInfo.ChannelList = NULL;
3410 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003411
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003412 EXIT();
3413 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003414}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003415
Jeff Johnson295189b2012-06-20 16:38:30 -07003416/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003417
3418 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003420
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 \param - dev - Pointer to the net device.
3422 - info - Pointer to the iw_request_info.
3423 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003424 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003425 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003426
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003428int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 struct iw_request_info *info,
3430 struct iw_point *dwrq, char *extra)
3431{
3432 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003433 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3435 ENTER();
3436
3437 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3438 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3439 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3440 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3441 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3442 {
3443 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3444 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3445 dwrq->flags = 1;
3446 } else {
3447 memset(extra, 0, dwrq->length);
3448 dwrq->length = 0;
3449 dwrq->flags = 0;
3450 }
3451 EXIT();
3452 return 0;
3453}
3454/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003455
3456 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003458
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 \param - dev - Pointer to the net device.
3460 - info - Pointer to the iw_request_info.
3461 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003462 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003464
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 --------------------------------------------------------------------------*/
3466int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3467 union iwreq_data *wrqu,char *extra)
3468{
3469 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003470 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3472 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003473 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003475
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003477
3478 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3479 {
3480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3481 "%s:LOGP in Progress. Ignore!!!", __func__);
3482 return -EBUSY;
3483 }
3484
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 switch(wrqu->param.flags & IW_AUTH_INDEX)
3486 {
3487 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003488
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003490
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003492
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 case IW_AUTH_CIPHER_PAIRWISE:
3494 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003495 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3499 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3502 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003503 }
3504
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003506
3507 if( (IW_AUTH_KEY_MGMT_802_1X
3508 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3510 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003511 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 else
3513 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003514 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003517
3518 if( ( IW_AUTH_KEY_MGMT_802_1X
3519 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3521 /*Dynamic WEP key*/
3522 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3523 else
3524 /*Static WEP key*/
3525 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003526
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 }
3528 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003529
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003531 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 return -EINVAL;
3533 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003534
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 pRoamProfile->EncryptionType.numEntries = 1;
3536 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 break;
3539 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003540 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3542 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3543 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003544
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3546 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3547 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003548
3549 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3551 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003552
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003554
3555 if( ( IW_AUTH_KEY_MGMT_802_1X
3556 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3557 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3558
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003560
3561 else
3562 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003564
3565 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3566 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003568 if( ( IW_AUTH_KEY_MGMT_802_1X
3569 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3571 {
3572 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3573 }
3574 else
3575 {
3576 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3577 }
3578 }
3579 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003580
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003582 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 return -EINVAL;
3584 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003585
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 pRoamProfile->mcEncryptionType.numEntries = 1;
3587 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3588 }
3589 break;
3590
3591 case IW_AUTH_80211_AUTH_ALG:
3592 {
3593 /*Save the auth algo here and set auth type to SME Roam profile
3594 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003595 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003597
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3599 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3600
3601 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3602 /*Not supported*/
3603 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3604 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3605 }
3606 break;
3607
3608 case IW_AUTH_KEY_MGMT:
3609 {
3610#ifdef FEATURE_WLAN_CCX
3611#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3612 /*Check for CCKM AKM type */
3613 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003614 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3615 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003616 /* Set the CCKM bit in authKeyMgmt */
3617 /* Right now, this breaks all ref to authKeyMgmt because our
3618 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 */
3620 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3621 /*Set the key management to 802.1X*/
3622 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3623 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3624 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3625 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3626 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3627 /*Save the key management*/
3628 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3629 //pWextState->authKeyMgmt = wrqu->param.value;
3630 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3631 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3632 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3633 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3634 /*Save the key management anyway*/
3635 pWextState->authKeyMgmt = wrqu->param.value;
3636 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3637 /*Save the key management*/
3638 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3639 //pWextState->authKeyMgmt = wrqu->param.value;
3640 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3641 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3642 }
3643#else
3644 /*Save the key management*/
3645 pWextState->authKeyMgmt = wrqu->param.value;
3646#endif /* FEATURE_WLAN_CCX */
3647 }
3648 break;
3649
3650 case IW_AUTH_TKIP_COUNTERMEASURES:
3651 {
3652 if(wrqu->param.value) {
3653 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3654 "Counter Measure started %d", wrqu->param.value);
3655 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3656 }
3657 else {
3658 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3659 "Counter Measure stopped=%d", wrqu->param.value);
3660 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3661 }
3662 }
3663 break;
3664 case IW_AUTH_DROP_UNENCRYPTED:
3665 case IW_AUTH_WPA_ENABLED:
3666 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3667 case IW_AUTH_ROAMING_CONTROL:
3668 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003669
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003671
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003672 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 wrqu->param.flags & IW_AUTH_INDEX);
3674 break;
3675 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003676
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 EXIT();
3678 return 0;
3679}
3680/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003681
3682 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003684
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 \param - dev - Pointer to the net device.
3686 - info - Pointer to the iw_request_info.
3687 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003688 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003690
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 --------------------------------------------------------------------------*/
3692int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3693 union iwreq_data *wrqu,char *extra)
3694{
3695 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003696 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3698 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003699
3700 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3701 {
3702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3703 "%s:LOGP in Progress. Ignore!!!", __func__);
3704 return -EBUSY;
3705 }
3706
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 switch(pRoamProfile->negotiatedAuthType)
3708 {
3709 case eCSR_AUTH_TYPE_WPA_NONE:
3710 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3711 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3712 break;
3713 case eCSR_AUTH_TYPE_WPA:
3714 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3715 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3716 break;
3717#ifdef WLAN_FEATURE_VOWIFI_11R
3718 case eCSR_AUTH_TYPE_FT_RSN:
3719#endif
3720 case eCSR_AUTH_TYPE_RSN:
3721 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3722 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3723 break;
3724 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3725 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3726 break;
3727 case eCSR_AUTH_TYPE_SHARED_KEY:
3728 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3729 break;
3730 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003731 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3733 break;
3734 case eCSR_AUTH_TYPE_AUTOSWITCH:
3735 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3736 break;
3737 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303738 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3740 return -EIO;
3741#ifdef WLAN_FEATURE_VOWIFI_11R
3742 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3743#endif
3744 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003745#ifdef WLAN_FEATURE_11W
3746 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3747#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05303748 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3750 return -EIO;
3751 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303752 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3754 return -EIO;
3755 }
3756 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3757 {
3758 switch(pRoamProfile->negotiatedUCEncryptionType)
3759 {
3760 case eCSR_ENCRYPT_TYPE_NONE:
3761 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3762 break;
3763 case eCSR_ENCRYPT_TYPE_WEP40:
3764 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3765 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3766 break;
3767 case eCSR_ENCRYPT_TYPE_TKIP:
3768 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3769 break;
3770 case eCSR_ENCRYPT_TYPE_WEP104:
3771 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3772 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3773 break;
3774 case eCSR_ENCRYPT_TYPE_AES:
3775 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3776 break;
3777 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303778 hddLog(LOG1, "%s called with unknown auth type %d ",
3779 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 return -EIO;
3781 }
3782 }
3783
Shailender Karmuchia734f332013-04-19 14:02:48 -07003784 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 {
3786 switch(pRoamProfile->negotiatedMCEncryptionType)
3787 {
3788 case eCSR_ENCRYPT_TYPE_NONE:
3789 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3790 break;
3791 case eCSR_ENCRYPT_TYPE_WEP40:
3792 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3793 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3794 break;
3795 case eCSR_ENCRYPT_TYPE_TKIP:
3796 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3797 break;
3798 case eCSR_ENCRYPT_TYPE_WEP104:
3799 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3800 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3801 break;
3802 case eCSR_ENCRYPT_TYPE_AES:
3803 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3804 break;
3805 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303806 hddLog(LOG1, "%s called with unknown auth type %d ",
3807 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 return -EIO;
3809 }
3810 }
3811
3812 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003813 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 EXIT();
3815 return 0;
3816}
3817/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003818
3819 \brief iw_set_ap_address() -
3820 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003822
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 \param - dev - Pointer to the net device.
3824 - info - Pointer to the iw_request_info.
3825 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003826 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003828
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 --------------------------------------------------------------------------*/
3830int iw_set_ap_address(struct net_device *dev,
3831 struct iw_request_info *info,
3832 union iwreq_data *wrqu, char *extra)
3833{
3834 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3835 v_U8_t *pMacAddress=NULL;
3836 ENTER();
3837 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08003838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
3839 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3841 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003842
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 return 0;
3844}
3845/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003846
3847 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 This function returns the BSSID to the wpa_supplicant
3849 \param - dev - Pointer to the net device.
3850 - info - Pointer to the iw_request_info.
3851 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003852 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003854
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 --------------------------------------------------------------------------*/
3856int iw_get_ap_address(struct net_device *dev,
3857 struct iw_request_info *info,
3858 union iwreq_data *wrqu, char *extra)
3859{
3860 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3861 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3862
3863 ENTER();
3864
3865 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3866 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3867 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003868 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 }
3870 else
3871 {
3872 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3873 }
3874 EXIT();
3875 return 0;
3876}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003877
Chet Lanctot186b5732013-03-18 10:26:30 -07003878#ifdef WLAN_FEATURE_11W
3879/**---------------------------------------------------------------------------
3880
3881 \brief hdd_indicateUnprotMgmtFrame -
3882 This function forwards the unprotected management frame to the supplicant
3883 \param - pAdapter - Pointer to HDD adapter
3884 - nFrameLength - Length of the unprotected frame being passed
3885 - pbFrames - Pointer to the frame buffer
3886 - frameType - 802.11 frame type
3887 \return - nothing
3888
3889 --------------------------------------------------------------------------*/
3890void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
3891 tANI_U32 nFrameLength,
3892 tANI_U8* pbFrames,
3893 tANI_U8 frameType )
3894{
3895 tANI_U8 type = 0;
3896 tANI_U8 subType = 0;
3897
3898 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
3899 __func__, frameType, nFrameLength);
3900
3901 /* Sanity Checks */
3902 if (NULL == pAdapter)
3903 {
3904 hddLog( LOGE, FL("pAdapter is NULL"));
3905 return;
3906 }
3907
3908 if (NULL == pAdapter->dev)
3909 {
3910 hddLog( LOGE, FL("pAdapter->dev is NULL"));
3911 return;
3912 }
3913
3914 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
3915 {
3916 hddLog( LOGE, FL("pAdapter has invalid magic"));
3917 return;
3918 }
3919
3920 if( !nFrameLength )
3921 {
3922 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
3923 return;
3924 }
3925
3926 if (NULL == pbFrames) {
3927 hddLog( LOGE, FL("pbFrames is NULL"));
3928 return;
3929 }
3930
3931 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3932 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3933
3934 /* Get pAdapter from Destination mac address of the frame */
3935 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
3936 {
3937 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
3938 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
3939 }
3940 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
3941 {
3942 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
3943 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
3944 }
3945 else
3946 {
3947 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
3948 return;
3949 }
3950}
3951#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003952
3953#if defined (FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
3954void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
3955 tANI_U8 state,
3956 tANI_U16 measInterval )
3957{
3958 union iwreq_data wrqu;
3959 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003960 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003961
3962 if (NULL == pAdapter)
3963 return;
3964
3965 // create the event
3966 memset(&wrqu, '\0', sizeof(wrqu));
3967 memset(buf, '\0', sizeof(buf));
3968
3969 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
3970 tid, state, measInterval);
3971
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003972 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003973
3974 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003975 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003976 // send the event
3977 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3978}
3979
3980void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
3981{
3982 union iwreq_data wrqu;
3983 char buf[IW_CUSTOM_MAX + 1];
3984 char *pos = buf;
3985 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3986
3987 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3988 return;
3989
3990 // create the event
3991 memset(&wrqu, '\0', sizeof(wrqu));
3992 memset(buf, '\0', sizeof(buf));
3993
3994 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05303995 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
3996 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
3997 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
3998 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003999
4000 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4001 pos += nBytes;
4002 freeBytes -= nBytes;
4003
4004 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4005 pos += WNI_CFG_BSSID_LEN;
4006 freeBytes -= WNI_CFG_BSSID_LEN;
4007
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004008 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4009 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004010
4011 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004012 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004013
4014 // send the event
4015 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4016}
4017
4018void hdd_indicateCcxAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4019{
4020 union iwreq_data wrqu;
4021 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004022 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004023
4024 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4025 return;
4026
4027 // create the event
4028 memset(&wrqu, '\0', sizeof(wrqu));
4029 memset(buf, '\0', sizeof(buf));
4030
4031 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4032
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004033 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004034
4035 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004036 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004037
4038 // send the event
4039 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4040}
4041
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004042void hdd_indicateCcxBcnReportInd(const hdd_adapter_t *pAdapter,
4043 const tCsrRoamInfo *pRoamInfo)
4044{
4045 union iwreq_data wrqu;
4046 char buf[IW_CUSTOM_MAX + 1];
4047 char *pos = buf;
4048 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4049 tANI_U8 i = 0, len = 0;
4050 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4051 tANI_U8 lastSent = 0, sendBss = 0;
4052 int bcnRepFieldSize = sizeof(pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4053
4054 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4055 return;
4056
4057 /* Custom event can pass maximum of 256 bytes of data,
4058 based on the IE len we need to identify how many BSS info can
4059 be filled in to custom event data */
4060 /*
4061 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4062 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4063 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4064 */
4065
4066 if ((pRoamInfo->pCcxBcnReportRsp->flag >> 1) && (!pRoamInfo->pCcxBcnReportRsp->numBss))
4067 {
4068 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4069 /* If the measurement is none and no scan results found,
4070 indicate the supplicant about measurement done */
4071 memset(&wrqu, '\0', sizeof(wrqu));
4072 memset(buf, '\0', sizeof(buf));
4073
4074 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
4075 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4076 pRoamInfo->pCcxBcnReportRsp->numBss, tot_bcn_ieLen);
4077
4078 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d",
4079 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4080 pRoamInfo->pCcxBcnReportRsp->numBss);
4081
4082 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004083 wrqu.data.length = nBytes;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004084 // send the event
4085 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4086 }
4087 else
4088 {
4089 while (lastSent < pRoamInfo->pCcxBcnReportRsp->numBss)
4090 {
4091 memset(&wrqu, '\0', sizeof(wrqu));
4092 memset(buf, '\0', sizeof(buf));
4093 tot_bcn_ieLen = 0;
4094 sendBss = 0;
4095 pos = buf;
4096 freeBytes = IW_CUSTOM_MAX;
4097
4098 for (i = lastSent; i < pRoamInfo->pCcxBcnReportRsp->numBss; i++)
4099 {
4100 len = bcnRepFieldSize + 1 + pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i].ieLen;
4101 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - 18))
4102 {
4103 break;
4104 }
4105 tot_bcn_ieLen += len;
4106 sendBss++;
4107 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4108 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4109 i, bcnRepFieldSize, 1,
4110 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i].ieLen,
4111 tot_bcn_ieLen);
4112 }
4113
4114 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4115 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
4116 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4117 pRoamInfo->pCcxBcnReportRsp->numBss, tot_bcn_ieLen);
4118
4119 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4120 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4121 pRoamInfo->pCcxBcnReportRsp->numBss);
4122 pos += nBytes;
4123 freeBytes -= nBytes;
4124
4125 /* Copy total Beacon report data length */
4126 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4127 pos += sizeof(tot_bcn_ieLen);
4128 freeBytes -= sizeof(tot_bcn_ieLen);
4129
4130 for (i = 0; i < sendBss; i++)
4131 {
4132 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304133 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4134 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004135 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4136 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4137 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4138 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4139 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4140 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4141 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4142 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4143 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4144 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4145 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4146 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4147 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4148 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4149 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4150 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4151 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
4152
4153 /* bcn report fields are copied */
4154 len = sizeof(pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4155 vos_mem_copy(pos, (char*)&pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
4156 pos += len;
4157 freeBytes -= len;
4158
4159 /* Add 1 byte of ie len */
4160 len = pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
4161 vos_mem_copy(pos, (char*)&len, sizeof(len));
4162 pos += sizeof(len);
4163 freeBytes -= sizeof(len);
4164
4165 /* copy IE from scan results */
4166 vos_mem_copy(pos, (char*)pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
4167 pos += len;
4168 freeBytes -= len;
4169 }
4170
4171 wrqu.data.pointer = buf;
4172 wrqu.data.length = strlen(buf);
4173
4174 // send the event
4175 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4176 lastSent += sendBss;
4177 }
4178 }
4179}
4180
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004181#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
4182