blob: 5adfd45a6ebf4be112c7bce9d291efc12e4bb1f2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, 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.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
Shailender Karmuchia734f332013-04-19 14:02:48 -070042
Jeff Johnson295189b2012-06-20 16:38:30 -070043/**========================================================================
44
45 \file wlan_hdd_assoc.c
46 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070047
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049/**=========================================================================
50 EDIT HISTORY FOR FILE
51
52
53 This section contains comments describing changes made to the module.
54 Notice that changes are listed in reverse chronological order.
55
56
57 $Header:$ $DateTime: $ $Author: $
58
59
60 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070061 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070062 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070063 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070064
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "wlan_hdd_includes.h"
66#include <aniGlobal.h>
67#include "dot11f.h"
68#include "wlan_nlink_common.h"
69#include "wlan_btc_svc.h"
70#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070071#include <linux/ieee80211.h>
72#include <linux/wireless.h>
73#include <net/cfg80211.h>
74#include "wlan_hdd_cfg80211.h"
75#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080#include "sme_Api.h"
81
82v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
83
Shailender Karmuchia734f332013-04-19 14:02:48 -070084struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070085{
86 u_char ether_addr_octet[6];
87};
88// These are needed to recognize WPA and RSN suite types
89#define HDD_WPA_OUI_SIZE 4
90v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
91v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
92v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
93v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
94v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
95v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
96#ifdef FEATURE_WLAN_CCX
97v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
98#endif /* FEATURE_WLAN_CCX */
99#define HDD_RSN_OUI_SIZE 4
100v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
101v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
102v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
103v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
104v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
105v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
106#ifdef FEATURE_WLAN_CCX
107v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
108#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -0700109#ifdef WLAN_FEATURE_11W
110v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
111#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
Shailender Karmuchia734f332013-04-19 14:02:48 -0700113#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700114// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700115#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
116#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700117#endif
118
119#define BEACON_FRAME_IES_OFFSET 12
120
Chet Lanctot186b5732013-03-18 10:26:30 -0700121#ifdef WLAN_FEATURE_11W
122void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
123 tANI_U32 nFrameLength,
124 tANI_U8* pbFrames,
125 tANI_U8 frameType );
126#endif
127
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700128#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
129static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
130 tANI_U8 state,
131 tANI_U16 measInterval );
132static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
133static void hdd_indicateCcxAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800134static void hdd_indicateCcxBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700135
136#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
137
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530138static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
139 tCsrRoamInfo *pRoamInfo,
140 tANI_U32 roamId,
141 eRoamCmdStatus roamStatus,
142 eCsrRoamResult roamResult );
143
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530144v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
145 eConnectionState connState )
146{
147 // save the new connection state
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 pHddStaCtx->conn_info.connState = connState;
149}
150
151// returns FALSE if not connected.
152// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
153// returns the connection state. Can specify NULL if you dont' want to get the actual state.
154
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
156 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700157{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700158 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700160
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 // get the connection state.
162 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700163 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700165 eConnectionState_IbssConnected == connState ||
166 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 {
168 fConnected = VOS_TRUE;
169 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700170 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 {
172 fConnected = VOS_FALSE;
173 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700174
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 if ( pConnState )
176 {
177 *pConnState = connState;
178 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700179
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 return( fConnected );
181}
182
183v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
184{
185 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700186}
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
188//TODO - Not used anyhwere. Can be removed.
189#if 0
190//
191v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
192{
193 v_BOOL_t fConnectedInfra = FALSE;
194 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700195
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700197 {
198 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700199 {
200 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700201 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700202 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700203
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 return( fConnectedInfra );
205}
206#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700207
Jeff Johnson295189b2012-06-20 16:38:30 -0700208static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
209{
210 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700211
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213
214 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 {
216 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
217 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 return( fConnected );
220}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700221
Jeff Johnson295189b2012-06-20 16:38:30 -0700222inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
223{
224 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700225
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700227
228 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 {
230 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
231 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 return( fConnected );
234}
235
236static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
237{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700238 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 {
240 case eCSR_BSS_TYPE_INFRASTRUCTURE:
241 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
242 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700243
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 case eCSR_BSS_TYPE_IBSS:
245 case eCSR_BSS_TYPE_START_IBSS:
246 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
247 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700248
249 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700250 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700251 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700252 default:
253 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700254 break;
255 }
256
Jeff Johnson295189b2012-06-20 16:38:30 -0700257}
258
259void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
260{
261 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
262 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700263
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700265
266 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700268 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
270 {
271 VOS_ASSERT( pRoamInfo->pBssDesc );
272 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
273
274 // Save the Station ID for this station from the 'Roam Info'.
275 //For IBSS mode, staId is assigned in NEW_PEER_IND
276 //For reassoc, the staID doesn't change and it may be invalid in this structure
277 //so no change here.
278 if( !pRoamInfo->fReassocReq )
279 {
280 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
281 }
282 }
283 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700284 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700286 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 else
288 {
289 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
290 // or we can't function.
291 VOS_ASSERT( 0 );
292 }
293
294 // notify WMM
295 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
296
297 if( !pRoamInfo->u.pConnectedProfile )
298 {
299 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
300 }
301 else
302 {
303 // Get Multicast Encryption Type
304 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
305 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
306 // Get Unicast Encrytion Type
307 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
308 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
309
310 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
311
312 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
313
314 // Save the ssid for the connection
315 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530316
317 // Save dot11mode in which STA associated to AP
318 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700320 }
321
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700323 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
324
Jeff Johnson295189b2012-06-20 16:38:30 -0700325}
326
327#if defined(WLAN_FEATURE_VOWIFI_11R)
328/*
329 * Send the 11R key information to the supplicant.
330 * Only then can the supplicant generate the PMK-R1.
331 * (BTW, the CCX supplicant also needs the Assoc Resp IEs
332 * for the same purpose.)
333 *
334 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
335 * this contains the R1KHID, R0KHID and the MDID.
336 * For FT, this consists of the Reassoc Rsp FTIEs.
337 * This is the Assoc Response.
338 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700339static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 tCsrRoamInfo *pCsrRoamInfo)
341{
342 union iwreq_data wrqu;
343 char *buff;
344 unsigned int len = 0;
345 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700346
347 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700348 {
349 hddLog(LOGE,
350 "%s: pCsrRoamInfo->nAssocRspLength=%d",
351 __func__, (int)pCsrRoamInfo->nAssocRspLength);
352 return;
353 }
354
Shailender Karmuchia734f332013-04-19 14:02:48 -0700355 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700357 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700359 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 return;
361 }
362
363 // pFTAssocRsp needs to point to the IEs
364 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
365 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
366 (unsigned int)pFTAssocRsp[0],
367 (unsigned int)pFTAssocRsp[1]);
368
369 // We need to send the IEs to the supplicant.
370 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700371 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700373 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 return;
375 }
376
377 // Send the Assoc Resp, the supplicant needs this for initial Auth.
378 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700379 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700381 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
383
384 kfree(buff);
385}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700386#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700387
388#ifdef WLAN_FEATURE_VOWIFI_11R
389
390/*---------------------------------------------------
391 *
392 * Send the FTIEs, RIC IEs during FT. This is eventually
393 * used to send the FT events to the supplicant
394 *
395 * At the reception of Auth2 we send the RIC followed
396 * by the auth response IEs to the supplicant.
397 * Once both are received in the supplicant, an FT
398 * event is generated to the supplicant.
399 *
400 *---------------------------------------------------
401 */
402void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
403{
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 tANI_U16 auth_resp_len = 0;
405 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
407
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530408#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700409 struct cfg80211_ft_event_params ftEvent;
410 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
411 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
412 struct net_device *dev = pAdapter->dev;
413#else
414 char *buff;
415 union iwreq_data wrqu;
416 tANI_U16 str_len;
417#endif
418
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530419#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530420 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
421 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700422
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530423 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800424 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530425 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700426 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530427 hddLog(LOGW,
428 "%s: RIC IEs is of length 0 not sending RIC Information for now",
429 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700430 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700431
432 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530433 ftEvent.ric_ies_len = ric_ies_length;
434 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700435
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530436 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800437 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700438
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530439 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700440 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530441 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700442 return;
443 }
444
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530445 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530446
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530447 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700448
449 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
450 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
451
Jeff Johnson59a121e2013-11-30 09:46:08 -0800452 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
453 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
454 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530455 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800456 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
457 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
458 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700459
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530460 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700461
462#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530463 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530465 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530467 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 return;
469 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530470 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700471
Shailender Karmuchia734f332013-04-19 14:02:48 -0700472 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530474 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800475 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530476 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530478 hddLog(LOGW,
479 "%s: RIC IEs is of length 0 not sending RIC Information for now",
480 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 }
482 else
483 {
484 wrqu.data.length = str_len + ric_ies_length;
485 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
486 }
487
488 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530489 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530491 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
492 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530494 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530496 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 return;
498 }
499
500 wrqu.data.length = str_len + auth_resp_len;
501 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
502
503 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700504#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700505}
506
507#endif /* WLAN_FEATURE_VOWIFI_11R */
508
509#ifdef FEATURE_WLAN_CCX
510
511/*
512 * Send the CCX required "new AP Channel info" to the supplicant.
513 * (This keeps the supplicant "up to date" on the current channel.)
514 *
515 * The current (new AP) channel information is passed in.
516 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700517static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 tCsrRoamInfo *pCsrRoamInfo)
519{
520 union iwreq_data wrqu;
521 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
Shailender Karmuchia734f332013-04-19 14:02:48 -0700523
524 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 {
526 hddLog(LOGE,
527 "%s: pCsrRoamInfo->pBssDesc=%p\n",
528 __func__, descriptor);
529 return;
530 }
531
532 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
533 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d\n", __func__, descriptor->channelId);
534 memset(&wrqu, '\0', sizeof(wrqu));
535 wrqu.freq.m = descriptor->channelId;
536 wrqu.freq.e = 0;
537 wrqu.freq.i = 0;
538 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
539}
540
541#endif /* FEATURE_WLAN_CCX */
542
543void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
544{
545 union iwreq_data wrqu;
546 u8 *pBeaconIes;
547 u8 currentLen = 0;
548 char *buff;
549 int totalIeLen = 0, currentOffset = 0, strLen;
550
551 memset(&wrqu, '\0', sizeof(wrqu));
552
553 if (0 == pCsrRoamInfo->nBeaconLength)
554 {
555 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
556 return;
557 }
558 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700559 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700561 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 return;
563 }
564
565 // pBeaconIes needs to point to the IEs
566 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
567 (unsigned int)pBeaconIes[0],
568 (unsigned int)pBeaconIes[1]);
569 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700570
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 // We need to send the IEs to the supplicant.
572 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700573 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700575 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 return;
577 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700578 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
580 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
581 currentLen = strLen + 1;
582
583 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
584 do
585 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700586 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 * max size and send it to supplicant. Changes are done in supplicant to handle this */
588 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
589 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
590 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
591 currentOffset += currentLen;
592 totalIeLen -= currentLen;
593 wrqu.data.length = strLen + 1 + currentLen;
594 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700595 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 else
597 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
598
599 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
600 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
601 } while (totalIeLen > 0);
602
603 kfree(buff);
604}
605
606static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
607{
608 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
609 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
610 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
611 union iwreq_data wrqu;
612 int we_event;
613 char *msg;
614 int type = -1;
615
Shailender Karmuchia734f332013-04-19 14:02:48 -0700616#if defined (WLAN_FEATURE_VOWIFI_11R)
617 // Added to find the auth type on the fly at run time
618 // rather than with cfg to see if FT is enabled
619 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
621#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700622
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700624 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700626
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
628 {
629 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
630 type = WLAN_STA_ASSOC_DONE_IND;
631
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700632#ifdef WLAN_FEATURE_P2P_DEBUG
633 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
634 {
635 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
636 {
637 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
638 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
639 "Connecting state to Connected State for 8-way "
640 "Handshake");
641 }
642 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
643 {
644 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
645 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
646 "Connecting state to P2P Client Connection Completed");
647 }
648 }
649#endif
Arif Hussain24bafea2013-11-15 15:10:03 -0800650 pr_info("wlan: connected to " MAC_ADDRESS_STR"\n",
651 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700652 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
653
654 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
655 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
656 * and fFTEnable is TRUE */
657#ifdef WLAN_FEATURE_VOWIFI_11R
658 // Send FT Keys to the supplicant when FT is enabled
659 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700660 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Jeff Johnson295189b2012-06-20 16:38:30 -0700661#ifdef FEATURE_WLAN_CCX
662 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
663 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
664#endif
665 )
666 {
667 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
668 }
669#endif
670 }
671 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
672 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700673 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800675 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
676 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 }
678 else /* Not Associated */
679 {
680 pr_info("wlan: disconnected\n");
681 type = WLAN_STA_DISASSOC_DONE_IND;
682 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
683 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700684 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700685
686 msg = NULL;
687 /*During the WLAN uninitialization,supplicant is stopped before the
688 driver so not sending the status of the connection to supplicant*/
689 if(pHddCtx->isLoadUnloadInProgress != TRUE)
690 {
691 wireless_send_event(dev, we_event, &wrqu, msg);
692#ifdef FEATURE_WLAN_CCX
693 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700694 {
695 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
696 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
698 }
699#endif
700 }
701 send_btc_nlink_msg(type, 0);
702}
703
704void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
705{
706 // Remove staId, bssId and peerMacAddress
707 pHddStaCtx->conn_info.staId [ 0 ] = 0;
708 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
709 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
710
711 // Clear all security settings
712 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
713 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
714 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
715
716 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700717 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700718
719 // Set not-connected state
720 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700721 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
723 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
724}
725/* TODO Revist this function. and data path */
726static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
727{
728 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700729 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
730
731 if (WLAN_HDD_IBSS != pAdapter->device_mode)
732 {
733 hdd_disconnect_tx_rx(pAdapter);
734 }
735 else
736 {
737 // Need to cleanup all queues only if the last peer leaves
738 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
739 {
740 netif_tx_disable(pAdapter->dev);
741 netif_carrier_off(pAdapter->dev);
742 hdd_disconnect_tx_rx(pAdapter);
743 }
744 else
745 {
746 // There is atleast one more peer, do not cleanup all queues
747 hdd_flush_ibss_tx_queues(pAdapter, staId);
748 }
749 }
750
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
752 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
753 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530754 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700756 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700757 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 }
759 return( vosStatus );
760}
761
762
763static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
764 tANI_U32 roamId, eRoamCmdStatus roamStatus,
765 eCsrRoamResult roamResult )
766{
767 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700768 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 struct net_device *dev = pAdapter->dev;
770 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
771 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700772 v_U8_t sta_id;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700773
774 // Sanity check
775 if(dev == NULL)
776 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700777 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700778 "%s: net_dev is released return", __func__);
779 return eHAL_STATUS_FAILURE;
780 }
781
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 // notify apps that we can't pass traffic anymore
783 netif_tx_disable(dev);
784 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700785
Jeff Johnsone7245742012-09-05 17:12:55 -0700786 INIT_COMPLETION(pAdapter->disconnect_comp_var);
787 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 /* If only STA mode is on */
789 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
790 {
791 pHddCtx->isAmpAllowed = VOS_TRUE;
792 }
793 hdd_clearRoamProfileIe( pAdapter );
794
795 // indicate 'disconnect' status to wpa_supplicant...
796 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 /* indicate disconnected event to nl80211 */
798 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
799 {
800 /*During the WLAN uninitialization,supplicant is stopped before the
801 driver so not sending the status of the connection to supplicant*/
802 if(pHddCtx->isLoadUnloadInProgress != TRUE)
803 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700804 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
805 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700807#ifdef WLAN_FEATURE_P2P_DEBUG
808 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
809 {
810 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
811 {
812 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
813 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
814 "and moved to disconnected state");
815 }
816 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
817 {
818 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
819 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
820 "and moved to inactive state");
821 }
822 }
823#endif
824
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
826 if( eCSR_ROAM_LOSTLINK == roamStatus )
827 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700828 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 }
830 else
831 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700832 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 }
834
835 //If the Device Mode is Station
836 // and the P2P Client is Connected
837 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700838
839 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700840 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700841 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 {
843 //Enable BMPS only of other Session is P2P Client
844 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700845 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700846
847 if (NULL != pVosContext)
848 {
849 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
850
851 if(NULL != pHddCtx)
852 {
853 //Only P2P Client is there Enable Bmps back
854 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700855 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530857 if (pHddCtx->hdd_wlan_suspended)
858 {
859 hdd_set_pwrparams(pHddCtx);
860 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530862 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 }
864 }
865 }
866 }
867 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700868
krunal soni3fc26642013-10-08 22:41:42 -0700869 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
870 {
871 sta_id = IBSS_BROADCAST_STAID;
872 }
873 else
874 {
875 sta_id = pHddStaCtx->conn_info.staId[0];
876 }
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530877 hdd_wmm_adapter_clear(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 //We should clear all sta register with TL, for now, only one.
krunal soni3fc26642013-10-08 22:41:42 -0700879 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
Jeff Johnson43971f52012-07-17 12:26:56 -0700880 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 "hdd_roamDeregisterSTA() failed to for staID %d. "
884 "Status= %d [0x%x]",
krunal soni3fc26642013-10-08 22:41:42 -0700885 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700886
887 status = eHAL_STATUS_FAILURE;
888 }
889
krunal soni3fc26642013-10-08 22:41:42 -0700890 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 // Clear saved connection information in HDD
892 hdd_connRemoveConnectInfo( pHddStaCtx );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530893#ifdef WLAN_FEATURE_GTK_OFFLOAD
894 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
895 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
896 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530897 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
898 sizeof (tSirGtkOffloadParams));
899 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530900 }
901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700902
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800903#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -0700904 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
905 {
906 wlan_hdd_tdls_disconnection_callback(pAdapter);
907 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800908#endif
909
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 //Unblock anyone waiting for disconnect to complete
911 complete(&pAdapter->disconnect_comp_var);
912 return( status );
913}
914static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
915 tCsrRoamInfo *pRoamInfo,
916 v_U8_t staId,
917 v_MACADDR_t *pPeerMacAddress,
918 tSirBssDescription *pBssDesc )
919{
920 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
921 WLAN_STADescType staDesc = {0};
922 eCsrEncryptionType connectedCipherAlgo;
923 v_BOOL_t fConnected;
924 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
925 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700926 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700927
928 if ( NULL == pBssDesc)
929 {
930 return VOS_STATUS_E_FAILURE;
931 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 // Get the Station ID from the one saved during the assocation.
933 staDesc.ucSTAId = staId;
934
935 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700937 staDesc.wSTAType = WLAN_STA_INFRA;
938
939 // grab the bssid from the connection info in the adapter structure and hand that
940 // over to TL when registering.
941 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
942 }
943 else
944 {
945 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700947
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
949 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
950 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
951 // pass when making an Infrastructure connection.
952 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
953 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
954 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700955
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
957
958 // set the QoS field appropriately
959 if (hdd_wmm_is_active(pAdapter))
960 {
961 staDesc.ucQosEnabled = 1;
962 }
963 else
964 {
965 staDesc.ucQosEnabled = 0;
966 }
967
968 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
969 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
970 {
971 staDesc.ucProtectedFrame = 1;
972 }
973 else
974 {
975 staDesc.ucProtectedFrame = 0;
976
977 }
978
979#ifdef FEATURE_WLAN_CCX
980 staDesc.ucIsCcxSta = pRoamInfo->isCCXAssoc;
981#endif //FEATURE_WLAN_CCX
982
983#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
984 /* check whether replay check is valid for the station or not */
985 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
986 {
987 /* Encryption mode is either TKIP or AES
988 and replay check is valid for only these
989 two encryption modes */
990 staDesc.ucIsReplayCheckValid = VOS_TRUE;
991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
992 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
993 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700994
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 else
996 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700997 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700999 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1001 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1002 }
1003#endif
1004
1005#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001006 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 if (pAdapter->wapi_info.fIsWapiSta)
1008 {
1009 staDesc.ucIsWapiSta = 1;
1010 }
1011 else
1012 {
1013 staDesc.ucIsWapiSta = 0;
1014 }
1015#endif /* FEATURE_WLAN_WAPI */
1016
1017 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1018 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1019
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 // UMA is Not ready yet, Xlation will be done by TL
1021 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 staDesc.ucSwFrameRXXlation = 1;
1023 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 staDesc.ucQosEnabled );
1026 // Initialize signatures and state
1027 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1028 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1029 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1030 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001031 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001032 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 -07001033 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1034 hdd_rx_packet_cbk,
1035 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 hdd_tx_fetch_packet_cbk, &staDesc,
1037 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001038
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1040 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001041 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001042 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001044 return vosStatus;
1045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001047 if ( cfg_param->dynSplitscan &&
1048 ( VOS_TIMER_STATE_RUNNING !=
1049 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1050 {
1051 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1052 cfg_param->trafficMntrTmrForSplitScan);
1053 }
1054
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301055 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1056 // then go to 'authenticated'. For all other authentication types
1057 // (those that donot require upper layer authentication) we can put
1058 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001059 if (staDesc.wSTAType != WLAN_STA_IBSS)
1060 VOS_ASSERT( fConnected );
1061
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301062 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001063 {
1064 // Connections that do not need Upper layer auth, transition TL directly
1065 // to 'Authenticated' state.
1066 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1067 WLANTL_STA_AUTHENTICATED );
1068
1069 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1070 }
1071 else
1072 {
1073 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301074 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1075 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001076 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301077 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001078 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 return( vosStatus );
1081}
1082
Jeff Johnson295189b2012-06-20 16:38:30 -07001083static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1084 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1085{
1086 unsigned int len = 0;
1087 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001088 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 tANI_U32 rspRsnLength = 0;
1090 struct ieee80211_channel *chan;
1091
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001092 if (!rspRsnIe)
1093 {
1094 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001095 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001096 }
1097
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001099 {
1100 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1101 goto done;
1102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001103
1104 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001105 {
1106 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1107 goto done;
1108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001109
1110 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1111 pCsrRoamInfo->nAssocReqLength);
1112 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001113 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001114
1115 //pFTAssocRsp needs to point to the IEs
1116 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1117 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x\n", __func__,
1118 (unsigned int)pFTAssocRsp[0],
1119 (unsigned int)pFTAssocRsp[1]);
1120
1121 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001122 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001125 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001126
1127 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1128 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1129 reqRsnIe, reqRsnLength,
1130 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001131
1132done:
1133 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001134}
Jeff Johnson295189b2012-06-20 16:38:30 -07001135
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301136void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1137{
1138 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1139 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1140 tCsrRoamInfo roamInfo;
1141 roamInfo.fAuthRequired = FALSE;
1142 vos_mem_copy(roamInfo.bssid,
1143 pHddStaCtx->roam_info.bssid,
1144 WNI_CFG_BSSID_LEN);
1145 vos_mem_copy(roamInfo.peerMac,
1146 pHddStaCtx->roam_info.peerMac,
1147 WNI_CFG_BSSID_LEN);
1148
1149 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1150 &roamInfo,
1151 pHddStaCtx->roam_info.roamId,
1152 pHddStaCtx->roam_info.roamStatus,
1153 eCSR_ROAM_RESULT_AUTHENTICATED);
1154 if (halStatus != eHAL_STATUS_SUCCESS)
1155 {
1156 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1157 }
1158 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1159}
1160
Shailender Karmuchia734f332013-04-19 14:02:48 -07001161static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1162 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 eCsrRoamResult roamResult )
1164{
1165 struct net_device *dev = pAdapter->dev;
1166 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1168 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001169 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1170 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001171#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 int ft_carrier_on = FALSE;
1173#endif
1174 int status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001175
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1177 {
1178 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1179
1180 // Save the connection info from CSR...
1181 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1182#ifdef FEATURE_WLAN_WAPI
1183 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1184 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1185 {
1186 pAdapter->wapi_info.fIsWapiSta = 1;
1187 }
1188 else
1189 {
1190 pAdapter->wapi_info.fIsWapiSta = 0;
1191 }
1192#endif /* FEATURE_WLAN_WAPI */
1193
1194 // indicate 'connect' status to userspace
1195 hdd_SendAssociationEvent(dev,pRoamInfo);
1196
1197
Shailender Karmuchia734f332013-04-19 14:02:48 -07001198 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 INIT_COMPLETION(pAdapter->linkup_event_var);
1200
1201 /*
1202 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1203 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 -07001204 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 know that the device is getting activated properly.
1206 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001207#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 if (pHddStaCtx->ft_carrier_on == FALSE)
1209 {
1210#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001211 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 pAdapter->isLinkUpSvcNeeded = TRUE;
1213
Shailender Karmuchia734f332013-04-19 14:02:48 -07001214 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 pAdapter->isLinkUpSvcNeeded = TRUE;
1216
1217 // Switch on the Carrier to activate the device
1218 netif_carrier_on(dev);
1219
1220 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1221 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1222 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001223 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 {
1225 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1226 }
1227
1228 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1229 pAdapter->isLinkUpSvcNeeded = FALSE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001230#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001232 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 }
1236#endif
1237 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1238
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001239#ifdef FEATURE_WLAN_TDLS
1240 wlan_hdd_tdls_connection_callback(pAdapter);
1241#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 //For reassoc, the station is already registered, all we need is to change the state
1243 //of the STA in TL.
1244 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1245 if( !pRoamInfo->fReassocReq )
1246 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001247 struct cfg80211_bss *bss;
1248#ifdef WLAN_FEATURE_VOWIFI_11R
1249 u8 *pFTAssocRsp = NULL;
1250 unsigned int assocRsplen = 0;
1251 u8 *pFTAssocReq = NULL;
1252 unsigned int assocReqlen = 0;
1253 struct ieee80211_channel *chan;
1254#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001257
1258 /* add bss_id to cfg80211 data base */
1259 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1260 if (NULL == bss)
1261 {
1262 pr_err("wlan: Not able to create BSS entry\n");
1263 return eHAL_STATUS_FAILURE;
1264 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001265#ifdef WLAN_FEATURE_VOWIFI_11R
1266 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001267 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001269
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001270 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001271 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001272 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001273 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001274 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001275 // pFTAssocRsp needs to point to the IEs
1276 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1277 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1278 (unsigned int)pFTAssocRsp[0],
1279 (unsigned int)pFTAssocRsp[1]);
1280 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001281 }
1282 else
1283 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001284 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1285 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001286 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001287
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001288 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001289 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001290 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001291 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001292 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001293 if(!ft_carrier_on)
1294 {
1295 // pFTAssocReq needs to point to the IEs
1296 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1297 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1298 (unsigned int)pFTAssocReq[0],
1299 (unsigned int)pFTAssocReq[1]);
1300 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1301 }
1302 else
1303 {
1304 /* This should contain only the FTIEs */
1305 assocReqlen = pRoamInfo->nAssocReqLength;
1306 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001307 }
1308 else
1309 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001310 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1311 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001312 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001313
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001314 if(ft_carrier_on)
1315 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001316 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
1317 "indication\n", __FUNCTION__, ft_carrier_on);
1318 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1319 (int)pRoamInfo->pBssDesc->channelId);
1320 hddLog(LOG1, "assocReqlen %d assocRsplen %d\n", assocReqlen,
1321 assocRsplen);
1322 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1323 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1324 GFP_KERNEL);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301325 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1326 {
1327 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1328 pRoamInfo->fAuthRequired = FALSE;
1329
1330 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1331 pRoamInfo->bssid,
1332 HDD_MAC_ADDR_LEN);
1333 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1334 pRoamInfo->peerMac,
1335 HDD_MAC_ADDR_LEN);
1336 pHddStaCtx->roam_info.roamId = roamId;
1337 pHddStaCtx->roam_info.roamStatus = roamStatus;
1338 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1339 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001340 }
1341 else
1342 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001343 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
1344 "indication\n", __FUNCTION__, ft_carrier_on);
1345 cfg80211_connect_result(dev, pRoamInfo->bssid,
1346 pFTAssocReq, assocReqlen,
1347 pFTAssocRsp, assocRsplen,
1348 WLAN_STATUS_SUCCESS,
1349 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001350 }
1351 }
1352 else
1353#endif
1354 {
1355 /* wpa supplicant expecting WPA/RSN IE in connect result */
1356 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1357 pAdapter->sessionId,
1358 &reqRsnLength,
1359 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001360
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001361 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1362 pAdapter->sessionId,
1363 &rspRsnLength,
1364 rspRsnIe);
1365#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1366 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001367 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001368 else
1369#endif /* FEATURE_WLAN_CCX */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001370
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001371 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001372 /* inform connect result to nl80211 */
1373 cfg80211_connect_result(dev, pRoamInfo->bssid,
1374 reqRsnIe, reqRsnLength,
1375 rspRsnIe, rspRsnLength,
1376 WLAN_STATUS_SUCCESS,
1377 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 }
Yue Maf49ba872013-08-19 12:04:25 -07001380 cfg80211_put_bss(
1381#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1382 pHddCtx->wiphy,
1383#endif
1384 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 // Register the Station with TL after associated...
1386 vosStatus = hdd_roamRegisterSTA( pAdapter,
1387 pRoamInfo,
1388 pHddStaCtx->conn_info.staId[ 0 ],
1389 NULL,
1390 pRoamInfo->pBssDesc );
1391 }
1392 else
1393 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001394 /* wpa supplicant expecting WPA/RSN IE in connect result */
1395 /* in case of reassociation also need to indicate it to supplicant */
1396 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1397 pAdapter->sessionId,
1398 &reqRsnLength,
1399 reqRsnIe);
1400
1401 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301403 if( pRoamInfo->fAuthRequired )
1404 {
1405 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1406 pHddStaCtx->conn_info.staId[ 0 ],
1407 WLANTL_STA_CONNECTED );
1408 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1409 }
1410 else
1411 {
1412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1413 "%s: staId: %d Changing TL state to AUTHENTICATED",
1414 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1415 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1416 pHddStaCtx->conn_info.staId[ 0 ],
1417 WLANTL_STA_AUTHENTICATED );
1418 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 }
1421
1422 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1423 {
1424 // perform any WMM-related association processing
1425 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1426 }
1427 else
1428 {
1429 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001430 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 vosStatus, vosStatus );
1432 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001433#ifdef WLAN_FEATURE_11W
1434 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1435 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1436#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 // Start the Queue
1438 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001439 }
1440 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1443
1444 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001445 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001446 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1447 " reason:%d and Status:%d\n",
1448 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1449 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001450 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001451 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1452 " reason:%d and Status:%d\n",
1453 MAC_ADDR_ARRAY(pWextState->req_bssId),
1454 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001455
1456 /*Handle all failure conditions*/
1457 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1458 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1459 {
1460 pHddCtx->isAmpAllowed = VOS_TRUE;
1461 }
1462
1463 //If the Device Mode is Station
1464 // and the P2P Client is Connected
1465 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001466
1467 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001468 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001469 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1470 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 (vos_concurrent_sessions_running()))
1472 {
1473 //Enable BMPS only of other Session is P2P Client
1474 hdd_context_t *pHddCtx = NULL;
1475 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1476
1477 if (NULL != pVosContext)
1478 {
1479 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1480
1481 if(NULL != pHddCtx)
1482 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301483 //Only P2P Client is there Enable Bmps back
1484 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
1485 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
1486 {
1487 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001488 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301489 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001490 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301491 hdd_enable_bmps_imps(pHddCtx);
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 }
1494 }
1495 }
1496
James Zmudafbf5ffc2013-03-25 12:45:35 -07001497 /* CR465478: Only send up a connection failure result when CSR has
James Zmuda7019bb32013-10-25 10:29:37 -07001498 * completed operation - with a ASSOCIATION_FAILURE status.
1499 * or an ASSOCIATION_COMPLETION with RESULT_NOT_ASSOCIATED */
1500 if (( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus ) ||
1501 (( eCSR_ROAM_ASSOCIATION_COMPLETION == roamStatus )
1502 && ( eCSR_ROAM_RESULT_NOT_ASSOCIATED == roamResult )))
Jeff Johnsone7245742012-09-05 17:12:55 -07001503 {
James Zmudafbf5ffc2013-03-25 12:45:35 -07001504 /* inform association failure event to nl80211 */
1505 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1506 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001507 if (pRoamInfo)
1508 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1509 NULL, 0, NULL, 0,
1510 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1511 GFP_KERNEL );
1512 else
1513 cfg80211_connect_result ( dev, pWextState->req_bssId,
1514 NULL, 0, NULL, 0,
1515 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1516 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001517 }
1518 else
1519 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001520 if (pRoamInfo)
1521 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1522 NULL, 0, NULL, 0,
1523 WLAN_STATUS_UNSPECIFIED_FAILURE,
1524 GFP_KERNEL );
1525 else
1526 cfg80211_connect_result ( dev, pWextState->req_bssId,
1527 NULL, 0, NULL, 0,
1528 WLAN_STATUS_UNSPECIFIED_FAILURE,
1529 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001530 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001533 /*Clear the roam profile*/
1534 hdd_clearRoamProfileIe( pAdapter );
1535
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 netif_tx_disable(dev);
1537 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001538
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 }
1540
1541 return eHAL_STATUS_SUCCESS;
1542}
1543
1544/**============================================================================
1545 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001546 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001548
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001550static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1551 tCsrRoamInfo *pRoamInfo,
1552 tANI_U32 roamId,
1553 eRoamCmdStatus roamStatus,
1554 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001555{
Jeff Johnson81c17882013-05-03 09:53:35 -07001556 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1557 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1558
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 switch( roamResult )
1560 {
1561 // both IBSS Started and IBSS Join should come in here.
1562 case eCSR_ROAM_RESULT_IBSS_STARTED:
1563 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001564 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001566 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1567 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001568
Jeff Johnson81c17882013-05-03 09:53:35 -07001569 if (NULL == pRoamInfo)
1570 {
1571 VOS_ASSERT(0);
1572 return;
1573 }
1574
1575 /* When IBSS Started comes from CSR, we need to move
1576 * connection state to IBSS Disconnected (meaning no peers
1577 * are in the IBSS).
1578 */
1579 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1580 eConnectionState_IbssDisconnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001581 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1582 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1583 IBSS_BROADCAST_STAID,
1584 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
Jeff Johnson81c17882013-05-03 09:53:35 -07001586 if (pRoamInfo->pBssDesc)
1587 {
1588 struct cfg80211_bss *bss;
1589
1590 /* we created the IBSS, notify supplicant */
1591 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1592 MAC_ADDRESS_STR,
1593 __func__, pAdapter->dev->name,
1594 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1595
1596 /* we must first give cfg80211 the BSS information */
1597 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1598 if (NULL == bss)
1599 {
1600 hddLog(VOS_TRACE_LEVEL_ERROR,
1601 "%s: %s: unable to create IBSS entry",
1602 __func__, pAdapter->dev->name);
1603 return;
1604 }
1605
1606 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001607 cfg80211_put_bss(
1608#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1609 pHddCtx->wiphy,
1610#endif
1611 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001612 }
1613
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 break;
1615 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001616
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1618 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001619 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1620 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 break;
1622 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001623
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001625 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1626 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001628 }
1629
Jeff Johnson81c17882013-05-03 09:53:35 -07001630 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001631}
1632
1633/**============================================================================
1634 *
1635 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1636 This information is passed to iwconfig later. The peer that joined
1637 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001638 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001640
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 ===========================================================================*/
1642static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1643{
1644 int fSuccess = FALSE;
1645 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001646
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1648 {
1649 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1650 {
1651 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001652
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001654
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 fSuccess = TRUE;
1656 break;
1657 }
1658 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001659
1660 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001661}
1662/**============================================================================
1663 *
1664 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001665 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001667
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001669static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001670{
1671 int fSuccess = FALSE;
1672 int idx = 0;
1673 v_U8_t valid_idx = 0;
1674 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001675 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001676 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001677
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1679 {
1680 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1681 {
1682 pHddStaCtx->conn_info.staId[ idx ] = 0;
1683
1684 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1685
1686 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001687
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 // Note the deleted Index, if its 0 we need special handling
1689 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001690
1691 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 }
1693 else
1694 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001695 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 {
1697 valid_idx = idx;
1698 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001699 else
1700 {
1701 // Found an empty slot
1702 empty_slots++;
1703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 }
1705 }
1706
Ravi Joshi8a934352013-09-25 16:46:58 -07001707 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1708 {
1709 // Last peer departed, set the IBSS state appropriately
1710 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001712 "Last IBSS Peer Departed!!!" );
1713 }
1714
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 // Find next active staId, to have a valid sta trigger for TL.
1716 if (fSuccess == TRUE)
1717 {
1718 if (del_idx == 0)
1719 {
1720 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1721 {
1722 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1723 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1724 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1725
1726 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1727 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1728 }
1729 }
1730 }
1731 return( fSuccess );
1732}
1733
1734/**============================================================================
1735 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001736 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001738
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 ===========================================================================*/
1740static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1741{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001742 struct cfg80211_bss *bss;
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1744 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1745 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1746
1747 // Save the connection info from CSR...
1748 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1749
1750 // Send the bssid address to the wext.
1751 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001753 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1754 if (NULL == bss)
1755 {
1756 hddLog(VOS_TRACE_LEVEL_ERROR,
1757 "%s: %s: unable to create IBSS entry",
1758 __func__, pAdapter->dev->name);
1759 return eHAL_STATUS_FAILURE;
1760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 /* send ibss join indication to nl80211 */
1762 cfg80211_ibss_joined(pAdapter->dev, &pRoamInfo->bssid[0], GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001763 cfg80211_put_bss(
1764#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1765 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1766#endif
1767 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001768
1769 return( eHAL_STATUS_SUCCESS );
1770}
1771/**============================================================================
1772 *
1773 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001774
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001776static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1777 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 eCsrRoamResult roamResult )
1779{
1780 eCsrEncryptionType connectedCipherAlgo;
1781 v_BOOL_t fConnected = FALSE;
1782 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1783 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1784 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1785 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07001786
1787 if (NULL == pRoamInfo)
1788 {
1789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
1790 return eHAL_STATUS_FAILURE;
1791 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001793 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 // not require upper layer authentication) we can put TL directly into 'authenticated'
1795 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1797 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
1798 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001799
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1801 if( fConnected )
1802 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001803 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
1804 {
1805 v_U8_t staId;
1806
1807 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
1808
1809 if ( 0 == memcmp( pRoamInfo->peerMac,
1810 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
1811 {
1812 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1813 IBSS_BROADCAST_STAID);
1814 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1815 }
1816 else
1817 {
1818 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
1819 (v_MACADDR_t*)pRoamInfo->peerMac,
1820 &staId);
1821 if ( VOS_STATUS_SUCCESS == vosStatus )
1822 {
1823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1824 "WLAN TL STA Ptk Installed for STAID=%d", staId);
1825 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1826 staId);
1827 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1828 }
1829 }
1830 }
1831 else
1832 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301833 // TODO: Considering getting a state machine in HDD later.
1834 // This routine is invoked twice. 1)set PTK 2)set GTK.
1835 // The folloing if statement will be TRUE when setting GTK.
1836 // At this time we don't handle the state in detail.
1837 // Related CR: 174048 - TL not in authenticated state
1838 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
1839 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
1840 {
1841 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
1842 "for StaId= %d. Changing TL state to AUTHENTICATED",
1843 pHddStaCtx->conn_info.staId[ 0 ] );
1844
1845 // Connections that do not need Upper layer authentication,
1846 // transition TL to 'Authenticated' state after the keys are set.
1847 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1848 pHddStaCtx->conn_info.staId[ 0 ],
1849 WLANTL_STA_AUTHENTICATED );
1850
1851 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1852 }
1853 else
1854 {
1855 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1856 pHddStaCtx->conn_info.staId[ 0 ]);
1857 }
1858
1859 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301862 else
1863 {
1864 // possible disassoc after issuing set key and waiting set key complete
1865 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1866 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001867
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 EXIT();
1869 return( eHAL_STATUS_SUCCESS );
1870}
1871/**============================================================================
1872 *
1873 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1874 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001875static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07001877{
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1879
1880 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
1881 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
1882 {
1883 struct iw_michaelmicfailure msg;
1884 union iwreq_data wreq;
1885 memset(&msg, '\0', sizeof(msg));
1886 msg.src_addr.sa_family = ARPHRD_ETHER;
1887 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08001888 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
1889 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001890
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
1892 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001893 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 msg.flags = IW_MICFAILURE_PAIRWISE;
1895 memset(&wreq, 0, sizeof(wreq));
1896 wreq.data.length = sizeof(msg);
1897 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001899 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 pRoamInfo->u.pMICFailureInfo->taMacAddr,
1901 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
1902 NL80211_KEYTYPE_GROUP :
1903 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07001904 pRoamInfo->u.pMICFailureInfo->keyId,
1905 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001907
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001909
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 return( eHAL_STATUS_SUCCESS );
1911}
1912
1913/**============================================================================
1914 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001915 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001917
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001919static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1920 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 eCsrRoamResult roamResult )
1922{
1923 VOS_STATUS vosStatus;
1924
1925 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1926 switch( roamResult )
1927 {
1928 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
1929 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001930 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001931 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001932
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001933 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07001934 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1935 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1936 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001938
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
1940 {
1941 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1942 "New IBSS peer but we already have the max we can handle. Can't register this one" );
1943 break;
1944 }
1945
1946 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1947
Shailender Karmuchia734f332013-04-19 14:02:48 -07001948 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1949 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
1950 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
1951
1952 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 vosStatus = hdd_roamRegisterSTA( pAdapter,
1954 pRoamInfo,
1955 pRoamInfo->staId,
1956 (v_MACADDR_t *)pRoamInfo->peerMac,
1957 pRoamInfo->pBssDesc );
1958 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1959 {
1960 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001961 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 vosStatus, vosStatus );
1963 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001964 pHddStaCtx->ibss_sta_generation++;
1965 memset(&staInfo, 0, sizeof(staInfo));
1966 staInfo.filled = 0;
1967 staInfo.generation = pHddStaCtx->ibss_sta_generation;
1968
1969 cfg80211_new_sta(pAdapter->dev,
1970 (const u8 *)pRoamInfo->peerMac,
1971 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001972
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001973 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
1974 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
1975 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
1976 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
1977 {
1978 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
1979 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
1980 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
1981
1982 VOS_TRACE( VOS_MODULE_ID_HDD,
1983 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d\n",
1984 pHddStaCtx->ibss_enc_key.encType);
1985
1986 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1987 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
1988
1989 if ( VOS_STATUS_SUCCESS != vosStatus )
1990 {
1991 hddLog(VOS_TRACE_LEVEL_ERROR,
1992 "%s: sme_RoamSetKey failed, returned %d",
1993 __func__, vosStatus);
1994 return VOS_STATUS_E_FAILURE;
1995 }
1996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 netif_carrier_on(pAdapter->dev);
1998 netif_tx_start_all_queues(pAdapter->dev);
1999 break;
2000 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002001
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2003 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002004
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002006
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2010 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002011 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002012
Ravi Joshicc57ed42013-10-12 16:31:25 -07002013 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 {
2015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2016 "IBSS peer departed by cannot find peer in our registration table with TL" );
2017 }
2018
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002019 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002020 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2021 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2022 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2023 pRoamInfo->staId );
2024
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2026
2027 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002028 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002029
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002030 cfg80211_del_sta(pAdapter->dev,
2031 (const u8 *)&pRoamInfo->peerMac,
2032 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 break;
2034 }
2035 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2036 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002037 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2038 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 // Stop only when we are inactive
2040 netif_tx_disable(pAdapter->dev);
2041 netif_carrier_off(pAdapter->dev);
2042 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002043
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 // Send the bssid address to the wext.
2045 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2046 // clean up data path
2047 hdd_disconnect_tx_rx(pAdapter);
2048 break;
2049 }
2050 default:
2051 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002052
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002054
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 return( eHAL_STATUS_SUCCESS );
2056}
2057
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002058#ifdef FEATURE_WLAN_TDLS
2059/**============================================================================
2060 *
2061 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2062 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2063 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002064
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002065 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002066VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2067 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002068{
2069 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002070 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002071 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2072 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002073 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2074 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002075 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2076 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002077
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002078 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2079 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002080 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002081 "%s not connected. ignored", __func__);
2082 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002083 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002084
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002085 /*
2086 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2087 * be peer MAC, here we are wokrking on direct Link
2088 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002089 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002090
2091 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002092
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002093 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002094 sizeof(tSirMacAddr) );
2095
2096 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2097 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2098
2099 /* set the QoS field appropriately ..*/
2100 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2101 : (staDesc.ucQosEnabled = 0) ;
2102
2103 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
2104 TL QoS_enabled=%d\n", staDesc.ucQosEnabled );
2105
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002106 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002107
2108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2109 "HDD register TL Sec_enabled= %d.\n", staDesc.ucProtectedFrame );
2110
Shailender Karmuchia734f332013-04-19 14:02:48 -07002111 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002112 * UMA is ready we inform TL to do frame translation.
2113 */
2114 staDesc.ucSwFrameTXXlation = 1;
2115 staDesc.ucSwFrameRXXlation = 1;
2116 staDesc.ucAddRmvLLC = 1;
2117
2118 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002119 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002120
2121 /* tdls Direct Link do not need bcastSig */
2122 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002123
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002124#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2125 if(staDesc.ucProtectedFrame)
2126 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2127 else
2128 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2129#endif
2130
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302131 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002132
Shailender Karmuchia734f332013-04-19 14:02:48 -07002133 /* Register the Station with TL... */
2134 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2135 hdd_rx_packet_cbk,
2136 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002137 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002138
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002139 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2140 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002142 "%s: WLANTL_RegisterSTAClient() failed to register. "
2143 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002144 return vosStatus;
2145 }
2146
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002147 if ( cfg_param->dynSplitscan &&
2148 ( VOS_TIMER_STATE_RUNNING !=
2149 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2150 {
2151 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2152 cfg_param->trafficMntrTmrForSplitScan);
2153 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002154 return( vosStatus );
2155}
2156
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002157static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2158{
2159 VOS_STATUS vosStatus;
2160 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2161 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2162 {
2163 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2164 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002165 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002166 __func__, staId, vosStatus, vosStatus );
2167 }
2168 return( vosStatus );
2169}
2170
2171
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002172/*
2173 * HDD interface between SME and TL to ensure TDLS client registration with
2174 * TL in case of new TDLS client is added and deregistration at the time
2175 * TDLS client is deleted.
2176 */
2177
Shailender Karmuchia734f332013-04-19 14:02:48 -07002178eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2179 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002180 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002181 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002182 eCsrRoamResult roamResult)
2183{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002184 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002185 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002186 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002187
2188#ifdef WLAN_FEATURE_TDLS_DEBUG
2189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08002190 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2191 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2192 "ADD_TDLS_PEER" :
2193 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2194 "DEL_TDLS_PEER" :
2195 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2196 "DEL_TDLS_PEER_IND" :
2197 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2198 "DEL_ALL_TDLS_PEER_IND" :
2199 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2200 "UPDATE_TDLS_PEER" :
2201 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2202 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2203 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002204#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002205 switch( roamResult )
2206 {
2207 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2208 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002209 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2210 {
2211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002212 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002213 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002214 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002215 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002216
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002217 /* check if there is available index for this new TDLS STA */
2218 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2219 {
2220 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2221 {
2222 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2223 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2224
2225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002226 ("TDLS: STA IDX at %d is %d "
2227 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002228 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002229 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002230
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002231 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002232 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2233 status = eHAL_STATUS_SUCCESS ;
2234 break ;
2235 }
2236 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002237 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002238 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002239 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2241 "wlan_hdd_tdls_set_sta_id() failed");
2242 return VOS_FALSE;
2243 }
2244
2245 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302246 /* store the ucast signature , if required for further reference. */
2247
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002248 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302249 /* start TDLS client registration with TL */
2250 status = hdd_roamRegisterTDLSSTA( pAdapter,
2251 pRoamInfo->peerMac,
2252 pRoamInfo->staId,
2253 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002254 }
2255 else
2256 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002257 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002259 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002260 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002261 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002262 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002263 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002264 break ;
2265 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002266 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2267 {
2268 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2269 {
2270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2271 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2272 }
2273 /* store the ucast signature which will be used later when
2274 * registering to TL
2275 */
2276 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2277 complete(&pAdapter->tdls_add_station_comp);
2278 break;
2279 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302280 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2281 {
2282 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2283 {
2284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2285 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2286 }
2287 complete(&pAdapter->tdls_link_establish_req_comp);
2288 break;
2289 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002290 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002291 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002292 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002293 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002294 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002295 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2296 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002297 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002299 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2300
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302301 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002302 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2303 {
2304 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2305 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2306 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002307 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002308 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
2309
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002310 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2311 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2312 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002313 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002314 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002315 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002316 break ;
2317 }
2318 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002319 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002320 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002321 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002322 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2323 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002324 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2326 "%s: Sending teardown to supplicant with reason code %u",
2327 __func__, pRoamInfo->reasonCode);
2328
2329#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302330 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002331 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002332#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002333 status = eHAL_STATUS_SUCCESS ;
2334 break ;
2335 }
2336 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2337 {
2338 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002339 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002340 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002341 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2342 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002343 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002345 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002346 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002347 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002348 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2349 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2350 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002351
2352 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[staIdx] = NULL;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002353 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002354 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002355 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2356 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002357
2358 status = eHAL_STATUS_SUCCESS ;
2359 }
2360 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302361 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002362 break ;
2363 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002364 default:
2365 {
2366 break ;
2367 }
2368 }
2369
2370 return status ;
2371}
2372#endif
2373
Shailender Karmuchia734f332013-04-19 14:02:48 -07002374eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2376{
2377 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2378 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302379 hdd_wext_state_t *pWextState = NULL;
2380 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002381 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002382 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
2384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002385 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002386 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002387
2388 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302389 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002390 {
2391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302392 "invalid adapter or adapter has invalid magic");
2393 return eHAL_STATUS_FAILURE;
2394 }
2395
2396 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2397 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2398
2399 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2400 {
2401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2402 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002403 return eHAL_STATUS_FAILURE;
2404 }
2405
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 switch( roamStatus )
2407 {
2408 case eCSR_ROAM_SESSION_OPENED:
2409 if(pAdapter != NULL)
2410 {
2411 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2412 complete(&pAdapter->session_open_comp_var);
2413 }
2414 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002415
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002416#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2418 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002419 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 * interface down */
2421 case eCSR_ROAM_FT_REASSOC_FAILED:
2422 hddLog(LOG1, FL("Reassoc Failed\n"));
2423 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2424 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2425 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2427 }
2428 pHddStaCtx->ft_carrier_on = FALSE;
2429 break;
2430
2431 case eCSR_ROAM_FT_START:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002432 // When we roam for CCX and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002434 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 // eCSR_ROAM_SHOULD_ROAM will be received.
2436 // Where in we will not mark the link down
2437 // Also we want to stop tx at this point when we will be
2438 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002439 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 {
2441 struct net_device *dev = pAdapter->dev;
2442 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002443 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002444 * Deregister for this STA with TL with the objective to flush
2445 * all the packets for this STA from wmm_tx_queue. If not done here,
2446 * we would run into a race condition (CR390567) wherein TX
2447 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2448 * been deleted. And, these packets get assigned with a STA idx of
2449 * self-sta (since the peer STA has been deleted) and get transmitted
2450 * on the new channel before the reassoc request. Since there will be
2451 * no ACK on the new channel, each packet gets retransmitted which
2452 * takes several seconds before the transmission of reassoc request.
2453 * This leads to reassoc-timeout and roam failure.
2454 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002455 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2456 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2457 {
2458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2459 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2460 pHddStaCtx->conn_info.staId[0], status, status );
2461 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 }
2464 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002465 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 break;
2467#endif
2468
2469 case eCSR_ROAM_SHOULD_ROAM:
2470 // Dont need to do anything
2471 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 struct net_device *dev = pAdapter->dev;
2473 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2474 // notify apps that we can't pass traffic anymore
2475 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002476#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 if (pHddStaCtx->ft_carrier_on == FALSE)
2478 {
2479#endif
2480 netif_carrier_off(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002481#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 }
2483#endif
2484
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002485#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 //We should clear all sta register with TL, for now, only one.
2487 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2488 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2489 {
2490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2491 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2492 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002493 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002495#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 }
2497 break;
2498 case eCSR_ROAM_LOSTLINK:
2499 case eCSR_ROAM_DISASSOCIATED:
2500 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2502 "****eCSR_ROAM_DISASSOCIATED****");
2503 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2504 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002505 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2506 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302507 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002508 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
2509 pHddCtx->configuredMcastBcastFilter =
2510 pHddCtx->sus_res_mcastbcast_filter;
Amar Singhald53568e2013-09-26 11:03:45 -07002511 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302512
Amar Singhald53568e2013-09-26 11:03:45 -07002513 hddLog(VOS_TRACE_LEVEL_INFO,
2514 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2515 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2516 pHddCtx->configuredMcastBcastFilter);
2517 hddLog(VOS_TRACE_LEVEL_INFO,
2518 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2520 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002521#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302522 /* Call to clear any MC Addr List filter applied after
2523 * successful connection.
2524 */
2525 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 }
2528 break;
2529 case eCSR_ROAM_IBSS_LEAVE:
2530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2531 "****eCSR_ROAM_IBSS_LEAVE****");
2532 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2533 break;
2534 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2536 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Gopichand Nakkala29149562013-05-10 21:43:41 +05302537 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
2538 ( (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2539 eCSR_ENCRYPT_TYPE_WEP40) ||
2540 (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2541 eCSR_ENCRYPT_TYPE_WEP104)
2542 ) &&
2543 (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 )
2545 {
2546 v_U32_t roamId = 0;
2547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2548 "****WEP open authentication failed, trying with shared authentication****");
2549 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2550 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2551 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2552 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2553 }
2554 else
2555 {
James Zmuda7019bb32013-10-25 10:29:37 -07002556 // Clear saved connection information in HDD
2557 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2559 }
2560
2561 break;
2562 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002563 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 pRoamInfo, roamId, roamStatus, roamResult );
2565 break;
2566 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002567 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2568 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 break;
2570
2571 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2572 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002573 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002574
2575 case eCSR_ROAM_MIC_ERROR_IND:
2576 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2577 break;
2578
2579 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002580 {
2581 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2582
2583 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002584 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2585 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2586 (eCSR_ROAM_RESULT_NONE == roamResult))
2587 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002588 /* Send DTIM period to the FW; only if the wlan is already
2589 in suspend. This is the case with roaming (reassoc),
2590 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2591 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2592 before the ENTER_BMPS_REQ ensures Listen Interval is
2593 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002594 hdd_set_pwrparams(pHddCtx);
2595 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2596
2597 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002598 if due to unexpected scenario, if we are in BMPS,
2599 then trigger Exit and Enter BMPS to take DTIM period
2600 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002601 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2602 {
2603 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2604
2605 /* put the device into full power */
2606 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
2607
2608 /* put the device back into BMPS */
2609 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
2610 }
2611 }
2612 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 break;
2615#ifdef WLAN_FEATURE_VOWIFI_11R
2616 case eCSR_ROAM_FT_RESPONSE:
2617 hdd_SendFTEvent(pAdapter);
2618 break;
2619#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002620#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002621 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002622 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002623 {
2624 /* Notify the supplicant of a new candidate */
2625 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2626 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002627 break;
2628#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002629
Yue Maef608272013-04-08 23:09:17 -07002630#ifdef FEATURE_WLAN_LFR_METRICS
2631 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2632 /* This event is to notify pre-auth initiation */
2633 if (VOS_STATUS_SUCCESS !=
2634 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2635 {
2636 halStatus = eHAL_STATUS_FAILURE;
2637 }
2638 break;
2639 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2640 /* This event will notify pre-auth completion in case of success */
2641 if (VOS_STATUS_SUCCESS !=
2642 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2643 pRoamInfo, 1))
2644 {
2645 halStatus = eHAL_STATUS_FAILURE;
2646 }
2647 break;
2648 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2649 /* This event will notify pre-auth completion in case of failure. */
2650 if (VOS_STATUS_SUCCESS !=
2651 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2652 pRoamInfo, 0))
2653 {
2654 halStatus = eHAL_STATUS_FAILURE;
2655 }
2656 break;
2657 case eCSR_ROAM_HANDOVER_SUCCESS:
2658 /* This event is to notify handover success.
2659 It will be only invoked on success */
2660 if (VOS_STATUS_SUCCESS !=
2661 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2662 {
2663 halStatus = eHAL_STATUS_FAILURE;
2664 }
2665 break;
2666#endif
2667
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2669 hdd_indicateMgmtFrame( pAdapter,
2670 pRoamInfo->nFrameLength,
2671 pRoamInfo->pbFrames,
2672 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302673 pRoamInfo->rxChan,
2674 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 break;
2676 case eCSR_ROAM_REMAIN_CHAN_READY:
2677 hdd_remainChanReadyHandler( pAdapter );
2678 break;
2679 case eCSR_ROAM_SEND_ACTION_CNF:
2680 hdd_sendActionCnf( pAdapter,
2681 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2682 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002683#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002684 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002685 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002686 roamId, roamStatus, roamResult );
2687 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002688 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2689 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2690 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002691#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002692#ifdef WLAN_FEATURE_11W
2693 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2694 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2695 pRoamInfo->pbFrames,
2696 pRoamInfo->frameType);
2697 break;
2698#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002699#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
2700 case eCSR_ROAM_TSM_IE_IND:
2701 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2702 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2703 break;
2704
2705 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
2706 {
2707 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
2708 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
2709 {
2710 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
2711 }
2712 break;
2713 }
2714
2715 case eCSR_ROAM_CCX_ADJ_AP_REPORT_IND:
2716 {
2717 hdd_indicateCcxAdjApRepInd(pAdapter, pRoamInfo);
2718 break;
2719 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002720
2721 case eCSR_ROAM_CCX_BCN_REPORT_IND:
2722 {
2723 hdd_indicateCcxBcnReportInd(pAdapter, pRoamInfo);
2724 break;
2725 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002726#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 default:
2728 break;
2729 }
2730 return( halStatus );
2731}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002732eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002733{
2734 eCsrAuthType auth_type;
2735 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002736 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 {
2738 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002739 } else
2740 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 {
2742 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002743 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002744#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002745 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002746 {
2747 // Check for 11r FT Authentication with PSK
2748 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002749 } else
2750 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 {
2752 // Check for 11R FT Authentication with 802.1X
2753 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002754 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002755#endif
2756#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002757 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 {
2759 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2760 } else
2761#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -07002762#ifdef WLAN_FEATURE_11W
2763 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2764 {
2765 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2766 } else
2767#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002768 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2770 }
2771 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002772}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002773
Shailender Karmuchia734f332013-04-19 14:02:48 -07002774eCsrAuthType
2775hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002776{
2777 eCsrAuthType auth_type;
2778 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002779 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 {
2781 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002782 } else
2783 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 {
2785 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002786 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002787#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002788 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 {
2790 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002791 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002792#endif /* FEATURE_WLAN_CCX */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002793 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2795 }
2796 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2797 return auth_type;
2798}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002799
Shailender Karmuchia734f332013-04-19 14:02:48 -07002800eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002801hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002802{
2803 eCsrEncryptionType cipher_type;
2804 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002805 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 {
2807 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002808 }
2809 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 {
2811 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002812 }
2813 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 {
2815 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002816 }
2817 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 {
2819 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002820 }
2821 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2822 {
2823 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2824 }
2825 else
2826 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2828 }
2829 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2830 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002831}
Jeff Johnson295189b2012-06-20 16:38:30 -07002832/* To find if the MAC address is NULL */
2833static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2834{
2835 int i;
2836 for (i = 0; i < length; i++)
2837 {
2838 if (0x00 != (macAddr[i]))
2839 {
2840 return FALSE;
2841 }
2842 }
2843 return TRUE;
2844} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08002845
Shailender Karmuchia734f332013-04-19 14:02:48 -07002846eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002847hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002848{
2849 eCsrEncryptionType cipher_type;
2850 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002851 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 {
2853 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002854 } else
2855 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 {
2857 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002858 } else
2859 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 {
2861 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002862 } else
2863 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 {
2865 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002866 } else
2867 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002869 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
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
Shailender Karmuchia734f332013-04-19 14:02:48 -07002878static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2879 struct ether_addr *pBssid,
2880 eCsrEncryptionType *pEncryptType,
2881 eCsrEncryptionType *mcEncryptType,
2882 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002883#ifdef WLAN_FEATURE_11W
2884 u_int8_t *pMfpRequired,
2885 u_int8_t *pMfpCapable,
2886#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002887 u_int16_t gen_ie_len,
2888 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07002889{
2890 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002891 eHalStatus result;
2892 tDot11fIERSN dot11RSNIE;
2893 tDot11fIEWPA dot11WPAIE;
2894 tANI_U32 i;
2895 tANI_U8 *pRsnIe;
2896 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07002898 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002899
2900 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2901 flag to 0 */
2902 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2903 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2904
2905 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002906 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2907 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 return -EINVAL;
2909 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07002910 if ( gen_ie[0] == DOT11F_EID_RSN)
2911 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002913 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2915 {
2916 return -EINVAL;
2917 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002918 // Skip past the EID byte and length byte
2919 pRsnIe = gen_ie + 2;
2920 RSNIeLen = gen_ie_len - 2;
2921 // Unpack the RSN IE
2922 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2923 pRsnIe,
2924 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002926 // Copy out the encryption and authentication types
2927 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002928 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002929 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002930 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002931 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 but probably I suspect we can do something different*/
2933 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07002934 // Just translate the FIRST one
2935 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2936 //dot11RSNIE.pwise_cipher_suite_count
2937 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2938 //dot11RSNIE.gp_cipher_suite_count
2939 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07002940#ifdef WLAN_FEATURE_11W
2941 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
2942 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
2943#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07002945 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002947 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 {
2949 break;
2950 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002951 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 {
2953 break;
2954 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002955 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002956 // For right now, I assume setASSOCIATE() has passed in the bssid.
2957 vos_mem_copy(PMKIDCache[i].BSSID,
2958 pBssid, ETHER_ADDR_LEN);
2959 vos_mem_copy(PMKIDCache[i].PMKID,
2960 dot11RSNIE.pmkid[i],
2961 CSR_RSN_PMKID_SIZE);
2962 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002963
2964 if (updatePMKCache)
2965 {
2966 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002967 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002968 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07002969 // Finally set the PMKSA ID Cache in CSR
2970 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
2971 PMKIDCache,
2972 dot11RSNIE.pmkid_count );
2973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 }
2975 else if (gen_ie[0] == DOT11F_EID_WPA)
2976 {
2977 // Validity checks
2978 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
2979 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
2980 {
2981 return -EINVAL;
2982 }
2983 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07002984 pRsnIe = gen_ie + 2 + 4;
2985 RSNIeLen = gen_ie_len - (2 + 4);
2986 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
2988 pRsnIe,
2989 RSNIeLen,
2990 &dot11WPAIE);
2991 // Copy out the encryption and authentication types
2992 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002993 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002995 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 //dot11WPAIE.auth_suite_count
2997 // Just translate the FIRST one
2998 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
2999 //dot11WPAIE.unicast_cipher_count
3000 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3001 //dot11WPAIE.unicast_cipher_count
3002 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3003 }
3004 else
3005 {
3006 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003007 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 }
3009 return 0;
3010}
3011int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3012{
3013 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3014 v_U32_t status = 0;
3015 eCsrEncryptionType RSNEncryptType;
3016 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003017#ifdef WLAN_FEATURE_11W
3018 u_int8_t RSNMfpRequired;
3019 u_int8_t RSNMfpCapable;
3020#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 struct ether_addr bSsid; // MAC address of assoc peer
3022 // MAC address of assoc peer
3023 // But, this routine is only called when we are NOT associated.
3024 vos_mem_copy(bSsid.ether_addr_octet,
3025 pWextState->roamProfile.BSSIDs.bssid,
3026 sizeof(bSsid.ether_addr_octet));
3027 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3028 {
3029 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003030 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 else
3032 {
3033 return 0;
3034 }
3035 // The actual processing may eventually be more extensive than this.
3036 // Right now, just consume any PMKIDs that are sent in by the app.
3037 status = hdd_ProcessGENIE(pAdapter,
3038 &bSsid, // MAC address of assoc peer
3039 &RSNEncryptType,
3040 &mcRSNEncryptType,
3041 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003042#ifdef WLAN_FEATURE_11W
3043 &RSNMfpRequired,
3044 &RSNMfpCapable,
3045#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 pWextState->WPARSNIE[1]+2,
3047 pWextState->WPARSNIE);
3048 if (status == 0)
3049 {
3050 // Now copy over all the security attributes you have parsed out
3051 pWextState->roamProfile.EncryptionType.numEntries = 1;
3052 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003053
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3055 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003056
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003057 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3058 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3059 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3060 {
3061 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3062 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3063 either AES/TKIP based on group cipher configuration
3064 mentioned in the wpa_supplicant.conf.*/
3065
3066 /*Set the unicast cipher same as multicast cipher*/
3067 pWextState->roamProfile.EncryptionType.encryptionType[0]
3068 = mcRSNEncryptType;
3069 }
3070
Chet Lanctot186b5732013-03-18 10:26:30 -07003071#ifdef WLAN_FEATURE_11W
3072 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3073 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3074#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003075 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 }
3077 return 0;
3078}
3079int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3080{
3081 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3082 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3083 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3084 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003085
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 pRoamProfile->AuthType.numEntries = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003087 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d\n", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003088
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 switch( pHddStaCtx->conn_info.authType)
3090 {
3091 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3092#ifdef FEATURE_WLAN_CCX
3093 case eCSR_AUTH_TYPE_CCKM_WPA:
3094 case eCSR_AUTH_TYPE_CCKM_RSN:
3095#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003096 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3097
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003099 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003101
Jeff Johnson295189b2012-06-20 16:38:30 -07003102#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003103 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3104 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3105 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003106 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003107 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3108 } else
3109 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003110 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003111 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 } else
3113#endif
3114 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3115 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003116 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3117 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3119 == IW_AUTH_KEY_MGMT_PSK) {
3120 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003121 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 }
3125 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
3126#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003127 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3128 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3129 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003130 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003131 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003133 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003134 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003135 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 } else
3137#endif
3138
3139#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003140 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3141 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003143 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003144 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003145 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3147 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003148 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 } else
3150#endif
3151
Chet Lanctot186b5732013-03-18 10:26:30 -07003152#ifdef WLAN_FEATURE_11W
3153 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3154 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3155 } else
3156#endif
3157
Shailender Karmuchia734f332013-04-19 14:02:48 -07003158 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003160 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3161 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3163 == IW_AUTH_KEY_MGMT_PSK) {
3164 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003165 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003169 break;
3170
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003172
3173 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 break;
3175 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003176
Jeff Johnson295189b2012-06-20 16:38:30 -07003177#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003178 hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003179#endif /* FEATURE_WLAN_CCX */
3180 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3181 break;
3182 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003183
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003185 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003186
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 EXIT();
3188 return 0;
3189}
3190
3191/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003192
3193 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003195 to the CSR roam profile.
3196
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 \param - dev - Pointer to the net device.
3198 - info - Pointer to the iw_request_info.
3199 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003200 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003202
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 --------------------------------------------------------------------------*/
3204
Shailender Karmuchia734f332013-04-19 14:02:48 -07003205int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 struct iw_request_info *info,
3207 union iwreq_data *wrqu, char *extra)
3208{
3209 v_U32_t status = 0;
3210 hdd_wext_state_t *pWextState;
3211 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3212 v_U32_t roamId;
3213 tCsrRoamProfile *pRoamProfile;
3214 eMib_dot11DesiredBssType connectedBssType;
3215 eCsrAuthType RSNAuthType;
3216 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3217 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003218
3219 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3220
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 ENTER();
3222
3223 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3224 {
3225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3226 "%s:LOGP in Progress. Ignore!!!",__func__);
3227 return 0;
3228 }
3229
3230 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3231 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3232 return -EBUSY;
3233 }
3234 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3235 return -EINVAL;
3236 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003237 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 {
3239 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3240 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3241 {
3242 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003243 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3245 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3246
3247 if(VOS_STATUS_SUCCESS == vosStatus)
3248 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3249 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3250 }
3251 }
3252 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003253 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 {
3255 return -EINVAL;
3256 }
3257 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003258 /** when cfg80211 defined, wpa_supplicant wext driver uses
3259 zero-length, null-string ssid for force disconnection.
3260 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 driver MUST return success */
3262 if ( 0 == wrqu->essid.length ) {
3263 return 0;
3264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003265
3266 status = hdd_wmm_get_uapsd_mask(pAdapter,
3267 &pWextState->roamProfile.uapsd_mask);
3268 if (VOS_STATUS_SUCCESS != status)
3269 {
3270 pWextState->roamProfile.uapsd_mask = 0;
3271 }
3272 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003273
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003275
3276 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3278 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3279 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003280
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 //set gen ie
3282 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3283
3284 //set auth
3285 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3286 }
3287#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003288 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 if (pAdapter->wapi_info.nWapiMode)
3290 {
3291 switch (pAdapter->wapi_info.wapiAuthMode)
3292 {
3293 case WAPI_AUTH_MODE_PSK:
3294 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003295 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 pRoamProfile->AuthType.numEntries = 1;
3297 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3298 break;
3299 }
3300 case WAPI_AUTH_MODE_CERT:
3301 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003302 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 pRoamProfile->AuthType.numEntries = 1;
3304 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3305 break;
3306 }
3307 } // End of switch
3308 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3309 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3310 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003311 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 pRoamProfile->EncryptionType.numEntries = 1;
3313 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3314 pRoamProfile->mcEncryptionType.numEntries = 1;
3315 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3316 }
3317 }
3318#endif /* FEATURE_WLAN_WAPI */
3319 /* if previous genIE is not NULL, update AssocIE */
3320 if (0 != pWextState->genIE.length)
3321 {
3322 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3323 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3324 pWextState->genIE.length);
3325 pWextState->assocAddIE.length = pWextState->genIE.length;
3326 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3327 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3328
3329 /* clear previous genIE after use it */
3330 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3331 }
3332
3333 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3334 pWextState->roamProfile.bWPSAssociation = FALSE;
3335
3336 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3337 pWextState->roamProfile.nAddIEAssocLength))
3338 pWextState->roamProfile.bWPSAssociation = TRUE;
3339
3340
3341 // Disable auto BMPS entry by PMC until DHCP is done
3342 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3343
Shailender Karmuchia734f332013-04-19 14:02:48 -07003344 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003346
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003347 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3348 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003349 hdd_select_cbmode(pAdapter,
3350 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3351 }
3352 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3353 &(pWextState->roamProfile), &roamId);
3354 pRoamProfile->ChannelInfo.ChannelList = NULL;
3355 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003356
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003357 EXIT();
3358 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003359}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003360
Jeff Johnson295189b2012-06-20 16:38:30 -07003361/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003362
3363 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003365
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 \param - dev - Pointer to the net device.
3367 - info - Pointer to the iw_request_info.
3368 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003369 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003371
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003373int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 struct iw_request_info *info,
3375 struct iw_point *dwrq, char *extra)
3376{
3377 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003378 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3380 ENTER();
3381
3382 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3383 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3384 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3385 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3386 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3387 {
3388 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3389 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3390 dwrq->flags = 1;
3391 } else {
3392 memset(extra, 0, dwrq->length);
3393 dwrq->length = 0;
3394 dwrq->flags = 0;
3395 }
3396 EXIT();
3397 return 0;
3398}
3399/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003400
3401 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003403
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 \param - dev - Pointer to the net device.
3405 - info - Pointer to the iw_request_info.
3406 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003407 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003409
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 --------------------------------------------------------------------------*/
3411int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3412 union iwreq_data *wrqu,char *extra)
3413{
3414 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003415 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3417 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003418 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003420
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003422
3423 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3424 {
3425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3426 "%s:LOGP in Progress. Ignore!!!", __func__);
3427 return -EBUSY;
3428 }
3429
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 switch(wrqu->param.flags & IW_AUTH_INDEX)
3431 {
3432 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003433
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003435
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003437
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 case IW_AUTH_CIPHER_PAIRWISE:
3439 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003440 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3444 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3447 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003448 }
3449
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451
3452 if( (IW_AUTH_KEY_MGMT_802_1X
3453 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3455 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003456 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 else
3458 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003459 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003462
3463 if( ( IW_AUTH_KEY_MGMT_802_1X
3464 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3466 /*Dynamic WEP key*/
3467 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3468 else
3469 /*Static WEP key*/
3470 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003471
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 }
3473 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003474
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003476 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 return -EINVAL;
3478 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003479
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 pRoamProfile->EncryptionType.numEntries = 1;
3481 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 break;
3484 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003485 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3487 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3488 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003489
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3491 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3492 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003493
3494 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3496 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003497
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003499
3500 if( ( IW_AUTH_KEY_MGMT_802_1X
3501 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3502 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3503
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003505
3506 else
3507 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003509
3510 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3511 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003513 if( ( IW_AUTH_KEY_MGMT_802_1X
3514 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3516 {
3517 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3518 }
3519 else
3520 {
3521 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3522 }
3523 }
3524 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003525
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003527 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 return -EINVAL;
3529 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003530
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 pRoamProfile->mcEncryptionType.numEntries = 1;
3532 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3533 }
3534 break;
3535
3536 case IW_AUTH_80211_AUTH_ALG:
3537 {
3538 /*Save the auth algo here and set auth type to SME Roam profile
3539 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003540 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003542
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3544 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3545
3546 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3547 /*Not supported*/
3548 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3549 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3550 }
3551 break;
3552
3553 case IW_AUTH_KEY_MGMT:
3554 {
3555#ifdef FEATURE_WLAN_CCX
3556#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3557 /*Check for CCKM AKM type */
3558 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003559 //hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
3560 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003561 /* Set the CCKM bit in authKeyMgmt */
3562 /* Right now, this breaks all ref to authKeyMgmt because our
3563 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 */
3565 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3566 /*Set the key management to 802.1X*/
3567 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3568 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3569 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3570 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3571 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3572 /*Save the key management*/
3573 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3574 //pWextState->authKeyMgmt = wrqu->param.value;
3575 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3576 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3577 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3578 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3579 /*Save the key management anyway*/
3580 pWextState->authKeyMgmt = wrqu->param.value;
3581 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3582 /*Save the key management*/
3583 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3584 //pWextState->authKeyMgmt = wrqu->param.value;
3585 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3586 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3587 }
3588#else
3589 /*Save the key management*/
3590 pWextState->authKeyMgmt = wrqu->param.value;
3591#endif /* FEATURE_WLAN_CCX */
3592 }
3593 break;
3594
3595 case IW_AUTH_TKIP_COUNTERMEASURES:
3596 {
3597 if(wrqu->param.value) {
3598 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3599 "Counter Measure started %d", wrqu->param.value);
3600 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3601 }
3602 else {
3603 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3604 "Counter Measure stopped=%d", wrqu->param.value);
3605 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3606 }
3607 }
3608 break;
3609 case IW_AUTH_DROP_UNENCRYPTED:
3610 case IW_AUTH_WPA_ENABLED:
3611 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3612 case IW_AUTH_ROAMING_CONTROL:
3613 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003614
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003616
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003617 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 wrqu->param.flags & IW_AUTH_INDEX);
3619 break;
3620 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003621
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 EXIT();
3623 return 0;
3624}
3625/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003626
3627 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003629
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 \param - dev - Pointer to the net device.
3631 - info - Pointer to the iw_request_info.
3632 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003633 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003635
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 --------------------------------------------------------------------------*/
3637int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3638 union iwreq_data *wrqu,char *extra)
3639{
3640 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003641 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3643 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003644
3645 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3646 {
3647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3648 "%s:LOGP in Progress. Ignore!!!", __func__);
3649 return -EBUSY;
3650 }
3651
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 switch(pRoamProfile->negotiatedAuthType)
3653 {
3654 case eCSR_AUTH_TYPE_WPA_NONE:
3655 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3656 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3657 break;
3658 case eCSR_AUTH_TYPE_WPA:
3659 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3660 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3661 break;
3662#ifdef WLAN_FEATURE_VOWIFI_11R
3663 case eCSR_AUTH_TYPE_FT_RSN:
3664#endif
3665 case eCSR_AUTH_TYPE_RSN:
3666 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3667 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3668 break;
3669 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3670 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3671 break;
3672 case eCSR_AUTH_TYPE_SHARED_KEY:
3673 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3674 break;
3675 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003676 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3678 break;
3679 case eCSR_AUTH_TYPE_AUTOSWITCH:
3680 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3681 break;
3682 case eCSR_AUTH_TYPE_WPA_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003683 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3685 return -EIO;
3686#ifdef WLAN_FEATURE_VOWIFI_11R
3687 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3688#endif
3689 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003690#ifdef WLAN_FEATURE_11W
3691 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3692#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003693 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3695 return -EIO;
3696 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003697 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3699 return -EIO;
3700 }
3701 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3702 {
3703 switch(pRoamProfile->negotiatedUCEncryptionType)
3704 {
3705 case eCSR_ENCRYPT_TYPE_NONE:
3706 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3707 break;
3708 case eCSR_ENCRYPT_TYPE_WEP40:
3709 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3710 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3711 break;
3712 case eCSR_ENCRYPT_TYPE_TKIP:
3713 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3714 break;
3715 case eCSR_ENCRYPT_TYPE_WEP104:
3716 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3717 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3718 break;
3719 case eCSR_ENCRYPT_TYPE_AES:
3720 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3721 break;
3722 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003723 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 return -EIO;
3725 }
3726 }
3727
Shailender Karmuchia734f332013-04-19 14:02:48 -07003728 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 {
3730 switch(pRoamProfile->negotiatedMCEncryptionType)
3731 {
3732 case eCSR_ENCRYPT_TYPE_NONE:
3733 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3734 break;
3735 case eCSR_ENCRYPT_TYPE_WEP40:
3736 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3737 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3738 break;
3739 case eCSR_ENCRYPT_TYPE_TKIP:
3740 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3741 break;
3742 case eCSR_ENCRYPT_TYPE_WEP104:
3743 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3744 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3745 break;
3746 case eCSR_ENCRYPT_TYPE_AES:
3747 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3748 break;
3749 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003750 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 return -EIO;
3752 }
3753 }
3754
3755 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003756 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 EXIT();
3758 return 0;
3759}
3760/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003761
3762 \brief iw_set_ap_address() -
3763 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003765
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 \param - dev - Pointer to the net device.
3767 - info - Pointer to the iw_request_info.
3768 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003769 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003771
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 --------------------------------------------------------------------------*/
3773int iw_set_ap_address(struct net_device *dev,
3774 struct iw_request_info *info,
3775 union iwreq_data *wrqu, char *extra)
3776{
3777 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3778 v_U8_t *pMacAddress=NULL;
3779 ENTER();
3780 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08003781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
3782 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3784 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003785
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 return 0;
3787}
3788/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003789
3790 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 This function returns the BSSID to the wpa_supplicant
3792 \param - dev - Pointer to the net device.
3793 - info - Pointer to the iw_request_info.
3794 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003795 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003797
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 --------------------------------------------------------------------------*/
3799int iw_get_ap_address(struct net_device *dev,
3800 struct iw_request_info *info,
3801 union iwreq_data *wrqu, char *extra)
3802{
3803 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3804 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3805
3806 ENTER();
3807
3808 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3809 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3810 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003811 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 }
3813 else
3814 {
3815 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3816 }
3817 EXIT();
3818 return 0;
3819}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003820
Chet Lanctot186b5732013-03-18 10:26:30 -07003821#ifdef WLAN_FEATURE_11W
3822/**---------------------------------------------------------------------------
3823
3824 \brief hdd_indicateUnprotMgmtFrame -
3825 This function forwards the unprotected management frame to the supplicant
3826 \param - pAdapter - Pointer to HDD adapter
3827 - nFrameLength - Length of the unprotected frame being passed
3828 - pbFrames - Pointer to the frame buffer
3829 - frameType - 802.11 frame type
3830 \return - nothing
3831
3832 --------------------------------------------------------------------------*/
3833void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
3834 tANI_U32 nFrameLength,
3835 tANI_U8* pbFrames,
3836 tANI_U8 frameType )
3837{
3838 tANI_U8 type = 0;
3839 tANI_U8 subType = 0;
3840
3841 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
3842 __func__, frameType, nFrameLength);
3843
3844 /* Sanity Checks */
3845 if (NULL == pAdapter)
3846 {
3847 hddLog( LOGE, FL("pAdapter is NULL"));
3848 return;
3849 }
3850
3851 if (NULL == pAdapter->dev)
3852 {
3853 hddLog( LOGE, FL("pAdapter->dev is NULL"));
3854 return;
3855 }
3856
3857 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
3858 {
3859 hddLog( LOGE, FL("pAdapter has invalid magic"));
3860 return;
3861 }
3862
3863 if( !nFrameLength )
3864 {
3865 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
3866 return;
3867 }
3868
3869 if (NULL == pbFrames) {
3870 hddLog( LOGE, FL("pbFrames is NULL"));
3871 return;
3872 }
3873
3874 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3875 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3876
3877 /* Get pAdapter from Destination mac address of the frame */
3878 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
3879 {
3880 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
3881 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
3882 }
3883 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
3884 {
3885 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
3886 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
3887 }
3888 else
3889 {
3890 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
3891 return;
3892 }
3893}
3894#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003895
3896#if defined (FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
3897void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
3898 tANI_U8 state,
3899 tANI_U16 measInterval )
3900{
3901 union iwreq_data wrqu;
3902 char buf[IW_CUSTOM_MAX + 1];
3903
3904 if (NULL == pAdapter)
3905 return;
3906
3907 // create the event
3908 memset(&wrqu, '\0', sizeof(wrqu));
3909 memset(buf, '\0', sizeof(buf));
3910
3911 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
3912 tid, state, measInterval);
3913
3914 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
3915
3916 wrqu.data.pointer = buf;
3917 wrqu.data.length = strlen(buf);
3918 // send the event
3919 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3920}
3921
3922void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
3923{
3924 union iwreq_data wrqu;
3925 char buf[IW_CUSTOM_MAX + 1];
3926 char *pos = buf;
3927 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3928
3929 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3930 return;
3931
3932 // create the event
3933 memset(&wrqu, '\0', sizeof(wrqu));
3934 memset(buf, '\0', sizeof(buf));
3935
3936 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arif Hussain24bafea2013-11-15 15:10:03 -08003937 hddLog(VOS_TRACE_LEVEL_ERROR, "CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %lu:%lu",
3938 MAC_ADDR_ARRAY(pRoamInfo->bssid),
3939 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003940
3941 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
3942 pos += nBytes;
3943 freeBytes -= nBytes;
3944
3945 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
3946 pos += WNI_CFG_BSSID_LEN;
3947 freeBytes -= WNI_CFG_BSSID_LEN;
3948
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003949 snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003950
3951 wrqu.data.pointer = buf;
3952 wrqu.data.length = strlen(buf);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003953
3954 // send the event
3955 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3956}
3957
3958void hdd_indicateCcxAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
3959{
3960 union iwreq_data wrqu;
3961 char buf[IW_CUSTOM_MAX + 1];
3962
3963 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3964 return;
3965
3966 // create the event
3967 memset(&wrqu, '\0', sizeof(wrqu));
3968 memset(buf, '\0', sizeof(buf));
3969
3970 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
3971
3972 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
3973
3974 wrqu.data.pointer = buf;
3975 wrqu.data.length = strlen(buf);
3976
3977 // send the event
3978 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3979}
3980
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003981void hdd_indicateCcxBcnReportInd(const hdd_adapter_t *pAdapter,
3982 const tCsrRoamInfo *pRoamInfo)
3983{
3984 union iwreq_data wrqu;
3985 char buf[IW_CUSTOM_MAX + 1];
3986 char *pos = buf;
3987 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3988 tANI_U8 i = 0, len = 0;
3989 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
3990 tANI_U8 lastSent = 0, sendBss = 0;
3991 int bcnRepFieldSize = sizeof(pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
3992
3993 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3994 return;
3995
3996 /* Custom event can pass maximum of 256 bytes of data,
3997 based on the IE len we need to identify how many BSS info can
3998 be filled in to custom event data */
3999 /*
4000 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4001 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4002 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4003 */
4004
4005 if ((pRoamInfo->pCcxBcnReportRsp->flag >> 1) && (!pRoamInfo->pCcxBcnReportRsp->numBss))
4006 {
4007 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4008 /* If the measurement is none and no scan results found,
4009 indicate the supplicant about measurement done */
4010 memset(&wrqu, '\0', sizeof(wrqu));
4011 memset(buf, '\0', sizeof(buf));
4012
4013 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
4014 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4015 pRoamInfo->pCcxBcnReportRsp->numBss, tot_bcn_ieLen);
4016
4017 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d",
4018 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4019 pRoamInfo->pCcxBcnReportRsp->numBss);
4020
4021 wrqu.data.pointer = buf;
4022 wrqu.data.length = strlen(buf);
4023 // send the event
4024 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4025 }
4026 else
4027 {
4028 while (lastSent < pRoamInfo->pCcxBcnReportRsp->numBss)
4029 {
4030 memset(&wrqu, '\0', sizeof(wrqu));
4031 memset(buf, '\0', sizeof(buf));
4032 tot_bcn_ieLen = 0;
4033 sendBss = 0;
4034 pos = buf;
4035 freeBytes = IW_CUSTOM_MAX;
4036
4037 for (i = lastSent; i < pRoamInfo->pCcxBcnReportRsp->numBss; i++)
4038 {
4039 len = bcnRepFieldSize + 1 + pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i].ieLen;
4040 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - 18))
4041 {
4042 break;
4043 }
4044 tot_bcn_ieLen += len;
4045 sendBss++;
4046 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4047 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4048 i, bcnRepFieldSize, 1,
4049 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i].ieLen,
4050 tot_bcn_ieLen);
4051 }
4052
4053 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4054 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
4055 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4056 pRoamInfo->pCcxBcnReportRsp->numBss, tot_bcn_ieLen);
4057
4058 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4059 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4060 pRoamInfo->pCcxBcnReportRsp->numBss);
4061 pos += nBytes;
4062 freeBytes -= nBytes;
4063
4064 /* Copy total Beacon report data length */
4065 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4066 pos += sizeof(tot_bcn_ieLen);
4067 freeBytes -= sizeof(tot_bcn_ieLen);
4068
4069 for (i = 0; i < sendBss; i++)
4070 {
4071 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
4072 " PhyType(%d) RecvSigPower(%d) ParentTSF(%lu)"
4073 " TargetTSF[0](%lu) TargetTSF[1](%lu) BeaconInterval(%u)"
4074 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4075 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4076 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4077 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4078 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4079 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4080 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4081 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4082 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4083 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4084 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4085 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4086 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4087 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4088 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4089 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4090 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
4091
4092 /* bcn report fields are copied */
4093 len = sizeof(pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4094 vos_mem_copy(pos, (char*)&pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
4095 pos += len;
4096 freeBytes -= len;
4097
4098 /* Add 1 byte of ie len */
4099 len = pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
4100 vos_mem_copy(pos, (char*)&len, sizeof(len));
4101 pos += sizeof(len);
4102 freeBytes -= sizeof(len);
4103
4104 /* copy IE from scan results */
4105 vos_mem_copy(pos, (char*)pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
4106 pos += len;
4107 freeBytes -= len;
4108 }
4109
4110 wrqu.data.pointer = buf;
4111 wrqu.data.length = strlen(buf);
4112
4113 // send the event
4114 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4115 lastSent += sendBss;
4116 }
4117 }
4118}
4119
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004120#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
4121