blob: 9f001648091b31281f0b461261512d8df30748f2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +053056#include "wlan_hdd_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include <linux/ieee80211.h>
58#include <linux/wireless.h>
59#include <net/cfg80211.h>
60#include "wlan_hdd_cfg80211.h"
61#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053063#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080064#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053066#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053067#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053068#include <wlan_hdd_wext.h>
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053069#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053070
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053071#if defined CFG80211_ROAMED_API_UNIFIED || \
72 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
73/**
74 * hdd_send_roamed_ind() - send roamed indication to cfg80211
75 * @dev: network device
76 * @bss: cfg80211 roamed bss pointer
77 * @req_ie: IEs used in reassociation request
78 * @req_ie_len: Length of the @req_ie
79 * @resp_ie: IEs received in successful reassociation response
80 * @resp_ie_len: Length of @resp_ie
81 *
82 * Return: none
83 */
84static void hdd_send_roamed_ind(struct net_device *dev,
85 struct cfg80211_bss *bss, const uint8_t *req_ie,
86 size_t req_ie_len, const uint8_t *resp_ie,
87 size_t resp_ie_len)
88{
89 struct cfg80211_roam_info info = {0};
90
91 info.bss = bss;
92 info.req_ie = req_ie;
93 info.req_ie_len = req_ie_len;
94 info.resp_ie = resp_ie;
95 info.resp_ie_len = resp_ie_len;
96
97 cfg80211_roamed(dev, &info, GFP_KERNEL);
98}
99#else
100/**
101 * hdd_send_roamed_ind() - send roamed indication to cfg80211
102 * @dev: network device
103 * @bss: cfg80211 roamed bss pointer
104 * @req_ie: IEs used in reassociation request
105 * @req_ie_len: Length of the @req_ie
106 * @resp_ie: IEs received in successful reassociation response
107 * @resp_ie_len: Length of @resp_ie
108 *
109 * Return: none
110 */
111static inline void hdd_send_roamed_ind(struct net_device *dev,
112 struct cfg80211_bss *bss,
113 const uint8_t *req_ie, size_t req_ie_len,
114 const uint8_t *resp_ie,
115 size_t resp_ie_len)
116{
117 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
118 GFP_KERNEL);
119}
120#endif
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
123
Shailender Karmuchia734f332013-04-19 14:02:48 -0700124struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -0700125{
126 u_char ether_addr_octet[6];
127};
128// These are needed to recognize WPA and RSN suite types
129#define HDD_WPA_OUI_SIZE 4
130v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
131v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
132v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
133v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
134v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
135v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800136#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700137v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800138#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700139#define HDD_RSN_OUI_SIZE 4
140v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
141v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
142v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
143v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
144v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
145v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800146#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700147v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800148#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -0700149#ifdef WLAN_FEATURE_11W
150v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
Abhishek Singhae408032014-09-25 17:22:04 +0530151/* RSN-8021X-SHA256 */
152v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700153#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700154
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700156// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700157#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
158#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700159#endif
160
161#define BEACON_FRAME_IES_OFFSET 12
162
Abhishek Singh78c691f2017-11-30 13:48:44 +0530163/* The time after add bss, in which SAP should start ECSA to move to SCC */
164#define ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL 1500
Abhishek Singh10e17cf2018-03-12 14:34:22 +0530165/*
166 * Time in ms after disconnect, in which the SAP should move to non DFS channel.
167 * This will avoid multiple SAP channel switch if disconnet is followed by
168 * connect.
169 */
170#define ECSA_DFS_CHAN_CHANGE_DEFER_TIME 200
Abhishek Singh78c691f2017-11-30 13:48:44 +0530171
Chet Lanctot186b5732013-03-18 10:26:30 -0700172#ifdef WLAN_FEATURE_11W
173void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
174 tANI_U32 nFrameLength,
175 tANI_U8* pbFrames,
176 tANI_U8 frameType );
177#endif
178
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800179#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700180static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
181 tANI_U8 state,
182 tANI_U16 measInterval );
183static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800184static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
185static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700186
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800187#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700188
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530189static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
190 tCsrRoamInfo *pRoamInfo,
191 tANI_U32 roamId,
192 eRoamCmdStatus roamStatus,
193 eCsrRoamResult roamResult );
194
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530195v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
196 eConnectionState connState )
197{
198 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530199 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
200 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 pHddStaCtx->conn_info.connState = connState;
202}
203
204// returns FALSE if not connected.
205// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
206// returns the connection state. Can specify NULL if you dont' want to get the actual state.
207
Shailender Karmuchia734f332013-04-19 14:02:48 -0700208static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
209 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700210{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700211 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 // get the connection state.
215 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700216 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700218 eConnectionState_IbssConnected == connState ||
219 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700220 {
221 fConnected = VOS_TRUE;
222 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 {
225 fConnected = VOS_FALSE;
226 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700227
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 if ( pConnState )
229 {
230 *pConnState = connState;
231 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 return( fConnected );
234}
235
236v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
237{
238 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700239}
Jeff Johnson295189b2012-06-20 16:38:30 -0700240
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530241eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
242{
243 v_U8_t staChannel = 0;
244
245 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
246 {
247 staChannel = pHddStaCtx->conn_info.operationChannel;
248 }
249
250 if ( staChannel > 0 && staChannel < 14 )
251 return eCSR_BAND_24;
252 else if (staChannel >= 36 && staChannel <= 165 )
253 return eCSR_BAND_5G;
254 else /* If station is not connected return as eCSR_BAND_ALL */
255 return eCSR_BAND_ALL;
256}
257
258
Jeff Johnson295189b2012-06-20 16:38:30 -0700259//TODO - Not used anyhwere. Can be removed.
260#if 0
261//
262v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
263{
264 v_BOOL_t fConnectedInfra = FALSE;
265 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700268 {
269 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 {
271 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700272 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700274
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 return( fConnectedInfra );
276}
277#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700278
Jeff Johnson295189b2012-06-20 16:38:30 -0700279static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
280{
281 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700282
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700284
285 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 {
287 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
288 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700289
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 return( fConnected );
291}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700292
Jeff Johnson295189b2012-06-20 16:38:30 -0700293inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
294{
295 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700296
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700298
299 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 {
301 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
302 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700303
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 return( fConnected );
305}
306
307static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
308{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700309 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 {
311 case eCSR_BSS_TYPE_INFRASTRUCTURE:
312 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
313 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700314
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 case eCSR_BSS_TYPE_IBSS:
316 case eCSR_BSS_TYPE_START_IBSS:
317 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
318 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700319
320 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700322 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 default:
324 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700325 break;
326 }
327
Jeff Johnson295189b2012-06-20 16:38:30 -0700328}
329
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530330/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530331 * hdd_copy_ht_caps()- Populate kernel HT caps structure object
332 * @hdd_ht_cap: HT capabilities of kernel type
333 * @roam_ht_cap: HT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530334 *
335 * Return: None
336 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530337void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
338 tDot11fIEHTCaps *roam_ht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530339{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530340 uint32_t i, temp_ht_cap;
341
342 vos_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
343
344 if (roam_ht_cap->advCodingCap)
345 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
346 if (roam_ht_cap->supportedChannelWidthSet)
347 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
348 temp_ht_cap = roam_ht_cap->mimoPowerSave &
349 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
350 if (temp_ht_cap)
351 hdd_ht_cap->cap_info |=
352 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
353 if (roam_ht_cap->greenField)
354 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
355 if (roam_ht_cap->shortGI20MHz)
356 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
357 if (roam_ht_cap->shortGI40MHz)
358 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
359 if (roam_ht_cap->txSTBC)
360 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
361 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
362 IEEE80211_HT_CAP_RX_STBC_SHIFT);
363 if (temp_ht_cap)
364 hdd_ht_cap->cap_info |=
365 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
366 if (roam_ht_cap->delayedBA)
367 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
368 if (roam_ht_cap->maximalAMSDUsize)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
370 if (roam_ht_cap->dsssCckMode40MHz)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
372 if (roam_ht_cap->psmp)
373 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
374 if (roam_ht_cap->stbcControlFrame)
375 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
376 if (roam_ht_cap->lsigTXOPProtection)
377 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
378
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530379 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
380 if (roam_ht_cap->maxRxAMPDUFactor)
381 hdd_ht_cap->ampdu_params_info |=
382 IEEE80211_HT_AMPDU_PARM_FACTOR;
383 temp_ht_cap = roam_ht_cap->mpduDensity &
384 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
385 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
386 if (temp_ht_cap)
387 hdd_ht_cap->ampdu_params_info |=
388 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
389
390 /* 802.11n HT extended capabilities masks */
391 if (roam_ht_cap->pco)
392 hdd_ht_cap->extended_ht_cap_info |=
393 IEEE80211_HT_EXT_CAP_PCO;
394 temp_ht_cap = roam_ht_cap->transitionTime &
395 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
396 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
397 if (temp_ht_cap)
398 hdd_ht_cap->extended_ht_cap_info |=
399 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
400 temp_ht_cap = roam_ht_cap->mcsFeedback &
401 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
402 if (temp_ht_cap)
403 hdd_ht_cap->extended_ht_cap_info |=
404 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
405
406 /* tx_bf_cap_info capabilities */
407 if (roam_ht_cap->txBF)
408 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
409 if (roam_ht_cap->rxStaggeredSounding)
410 hdd_ht_cap->tx_BF_cap_info |=
411 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
412 if (roam_ht_cap->txStaggeredSounding)
413 hdd_ht_cap->tx_BF_cap_info |=
414 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
415 if (roam_ht_cap->rxZLF)
416 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
417 if (roam_ht_cap->txZLF)
418 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
419 if (roam_ht_cap->implicitTxBF)
420 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
421 temp_ht_cap = roam_ht_cap->calibration &
422 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
423 if (temp_ht_cap)
424 hdd_ht_cap->tx_BF_cap_info |=
425 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
426 if (roam_ht_cap->explicitCSITxBF)
427 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
428 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
429 hdd_ht_cap->tx_BF_cap_info |=
430 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
431 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
432 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
433 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
434 if (temp_ht_cap)
435 hdd_ht_cap->tx_BF_cap_info |=
436 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
437 temp_ht_cap =
438 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
439 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
440 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
441 if (temp_ht_cap)
442 hdd_ht_cap->tx_BF_cap_info |=
443 temp_ht_cap <<
444 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
445 temp_ht_cap =
446 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
447 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
448 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
449 if (temp_ht_cap)
450 hdd_ht_cap->tx_BF_cap_info |=
451 temp_ht_cap <<
452 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
453 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
454 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
455 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
456 if (temp_ht_cap)
457 hdd_ht_cap->tx_BF_cap_info |=
458 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
459 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
460 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
461 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
462 if (temp_ht_cap)
463 hdd_ht_cap->tx_BF_cap_info |=
464 temp_ht_cap <<
465 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
466 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
467 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
468 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
469 if (temp_ht_cap)
470 hdd_ht_cap->tx_BF_cap_info |=
471 temp_ht_cap <<
472 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
473
474 /* antenna selection */
475 if (roam_ht_cap->antennaSelection)
476 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
477 if (roam_ht_cap->explicitCSIFeedbackTx)
478 hdd_ht_cap->antenna_selection_info |=
479 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
480 if (roam_ht_cap->antennaIndicesFeedbackTx)
481 hdd_ht_cap->antenna_selection_info |=
482 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
483 if (roam_ht_cap->explicitCSIFeedback)
484 hdd_ht_cap->antenna_selection_info |=
485 ANTENNA_SEL_INFO_EXP_CSI_FB;
486 if (roam_ht_cap->antennaIndicesFeedback)
487 hdd_ht_cap->antenna_selection_info |=
488 ANTENNA_SEL_INFO_ANT_ID_FB;
489 if (roam_ht_cap->rxAS)
490 hdd_ht_cap->antenna_selection_info |=
491 ANTENNA_SEL_INFO_RX_AS;
492 if (roam_ht_cap->txSoundingPPDUs)
493 hdd_ht_cap->antenna_selection_info |=
494 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
495
496 /* mcs data rate */
497 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
498 hdd_ht_cap->mcs.rx_mask[i] =
499 roam_ht_cap->supportedMCSSet[i];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530500
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530501 hdd_ht_cap->mcs.rx_highest =
502 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
503 ((short) (roam_ht_cap->supportedMCSSet[10]));
504 hdd_ht_cap->mcs.tx_params =
505 roam_ht_cap->supportedMCSSet[12];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530506
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530507}
508
509
510#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
511#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
512#define VHT_CAP_RXSTBC_MASK_SHIFT 8
513#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
514#define VHT_CAP_BEAMFORMEE_STS_MASK \
515 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
516#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
517#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
518 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
519#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
520#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
521 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
522#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
523
524/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530525 * hdd_copy_vht_caps()- Populate kernel VHT caps structure object
526 * @hdd_ht_cap: VHT capabilities of kernel type
527 * @roam_ht_cap: VHT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530528 *
529 * Return: None
530 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530531void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
532 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530533{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530534 uint32_t temp_vht_cap;
535
536 vos_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
537
538 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
539 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
540 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
541 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
542 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
543 if (temp_vht_cap)
544 if (roam_vht_cap->supportedChannelWidthSet &
545 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
546 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
547 hdd_vht_cap->vht_cap_info |=
548 temp_vht_cap <<
549 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
550 if (roam_vht_cap->supportedChannelWidthSet &
551 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
552 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
553 hdd_vht_cap->vht_cap_info |=
554 temp_vht_cap <<
555 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
556 if (roam_vht_cap->ldpcCodingCap)
557 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
558 if (roam_vht_cap->shortGI80MHz)
559 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
560 if (roam_vht_cap->shortGI160and80plus80MHz)
561 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
562 if (roam_vht_cap->txSTBC)
563 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
564 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
565 VHT_CAP_RXSTBC_MASK_SHIFT);
566 if (temp_vht_cap)
567 hdd_vht_cap->vht_cap_info |=
568 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
569 if (roam_vht_cap->suBeamFormerCap)
570 hdd_vht_cap->vht_cap_info |=
571 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
572 if (roam_vht_cap->suBeamformeeCap)
573 hdd_vht_cap->vht_cap_info |=
574 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
575 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
576 (VHT_CAP_BEAMFORMEE_STS_MASK);
577 if (temp_vht_cap)
578 hdd_vht_cap->vht_cap_info |=
579 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
580 temp_vht_cap = roam_vht_cap->numSoundingDim &
581 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
582 if (temp_vht_cap)
583 hdd_vht_cap->vht_cap_info |=
584 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
585 if (roam_vht_cap->muBeamformerCap)
586 hdd_vht_cap->vht_cap_info |=
587 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
588 if (roam_vht_cap->muBeamformeeCap)
589 hdd_vht_cap->vht_cap_info |=
590 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
591 if (roam_vht_cap->vhtTXOPPS)
592 hdd_vht_cap->vht_cap_info |=
593 IEEE80211_VHT_CAP_VHT_TXOP_PS;
594 if (roam_vht_cap->htcVHTCap)
595 hdd_vht_cap->vht_cap_info |=
596 IEEE80211_VHT_CAP_HTC_VHT;
597 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
598 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
599 if (temp_vht_cap)
600 hdd_vht_cap->vht_cap_info |=
601 temp_vht_cap <<
602 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
603 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
604 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
605 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
606 if (temp_vht_cap)
607 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
608 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
609 if (roam_vht_cap->rxAntPattern)
610 hdd_vht_cap->vht_cap_info |=
611 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
612 if (roam_vht_cap->txAntPattern)
613 hdd_vht_cap->vht_cap_info |=
614 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
615 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
616 hdd_vht_cap->supp_mcs.rx_highest =
617 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
618 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
619 hdd_vht_cap->supp_mcs.tx_highest =
620 ((uint16_t)roam_vht_cap->txSupDataRate);
621}
622
623/* ht param */
624#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
625#define HT_PARAM_SERVICE_INT_GRAN 0xe0
626#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
627
628/* operatinon mode */
629#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
630
631/* stbc_param */
632#define HT_STBC_PARAM_MCS 0x007f
633
634/**
635 * hdd_copy_ht_operation()- copy HT operation element from roam info to
636 * hdd station context.
637 * @hdd_sta_ctx: pointer to hdd station context
638 * @roam_info: pointer to roam info
639 *
640 * Return: None
641 */
642static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
643 tCsrRoamInfo *roam_info)
644{
645 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
646 struct ieee80211_ht_operation *hdd_ht_ops =
647 &hdd_sta_ctx->conn_info.ht_operation;
648 uint32_t i, temp_ht_ops;
649
650 vos_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
651
652 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
653
654 /* HT_PARAMS */
655 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
656 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
657 if (temp_ht_ops)
658 hdd_ht_ops->ht_param |= temp_ht_ops;
659 else
660 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
661 if (roam_ht_ops->recommendedTxWidthSet)
662 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
663 if (roam_ht_ops->rifsMode)
664 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
665 if (roam_ht_ops->controlledAccessOnly)
666 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
667 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
668 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
669 if (temp_ht_ops)
670 hdd_ht_ops->ht_param |= temp_ht_ops <<
671 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
672
673 /* operation mode */
674 temp_ht_ops = roam_ht_ops->opMode &
675 IEEE80211_HT_OP_MODE_PROTECTION;
676 switch (temp_ht_ops) {
677 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
678 hdd_ht_ops->operation_mode |=
679 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
680 break;
681 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
682 hdd_ht_ops->operation_mode |=
683 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
684 break;
685 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
686 hdd_ht_ops->operation_mode |=
687 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
688 break;
689 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
690 default:
691 hdd_ht_ops->operation_mode |=
692 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
693 }
694 if (roam_ht_ops->nonGFDevicesPresent)
695 hdd_ht_ops->operation_mode |=
696 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
697 if (roam_ht_ops->transmitBurstLimit)
698 hdd_ht_ops->operation_mode |=
699 HT_OP_MODE_TX_BURST_LIMIT;
700 if (roam_ht_ops->obssNonHTStaPresent)
701 hdd_ht_ops->operation_mode |=
702 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
703
704 /* stbc_param */
705 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
706 HT_STBC_PARAM_MCS;
707 if (temp_ht_ops)
708 hdd_ht_ops->stbc_param |= temp_ht_ops;
709 if (roam_ht_ops->dualCTSProtection)
710 hdd_ht_ops->stbc_param |=
711 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
712 if (roam_ht_ops->secondaryBeacon)
713 hdd_ht_ops->stbc_param |=
714 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
715 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
716 hdd_ht_ops->stbc_param |=
717 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
718 if (roam_ht_ops->pcoActive)
719 hdd_ht_ops->stbc_param |=
720 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
721 if (roam_ht_ops->pcoPhase)
722 hdd_ht_ops->stbc_param |=
723 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
724
725 /* basic MCs set */
726 for (i = 0; i < 16; ++i)
727 hdd_ht_ops->basic_set[i] =
728 roam_ht_ops->basicMCSSet[i];
729}
730
731/**
732 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
733 * hdd station context.
734 * @hdd_sta_ctx: pointer to hdd station context
735 * @roam_info: pointer to roam info
736 *
737 * Return: None
738 */
739static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
740 tCsrRoamInfo *roam_info)
741{
742 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
743 struct ieee80211_vht_operation *hdd_vht_ops =
744 &hdd_sta_ctx->conn_info.vht_operation;
745
746 vos_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
747
748 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
749 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
750 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
751 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
752}
753
754
755/**
756 * hdd_save_bss_info() - save connection info in hdd sta ctx
757 * @adapter: Pointer to adapter
758 * @roam_info: pointer to roam info
759 *
760 * Return: None
761 */
762static void hdd_save_bss_info(hdd_adapter_t *adapter,
763 tCsrRoamInfo *roam_info)
764{
765 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
766
767 hdd_sta_ctx->conn_info.freq = vos_chan_to_freq(
768 hdd_sta_ctx->conn_info.operationChannel);
769 if (roam_info->vht_caps.present) {
770 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530771 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
772 &roam_info->vht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530773 } else {
774 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
775 }
776 if (roam_info->ht_caps.present) {
777 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530778 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps, &roam_info->ht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530779 } else {
780 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
781 }
782 if (roam_info->reassoc)
783 hdd_sta_ctx->conn_info.roam_count++;
784 if (roam_info->hs20vendor_ie.present) {
785 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
786 vos_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
787 &roam_info->hs20vendor_ie,
788 sizeof(roam_info->hs20vendor_ie));
789 } else {
790 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
791 }
792 if (roam_info->ht_operation.present) {
793 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
794 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
795 } else {
796 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
797 }
798 if (roam_info->vht_operation.present) {
799 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
800 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
801 } else {
802 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
803 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +0530804 /* Cache last connection info */
805 vos_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
806 sizeof(connection_info_t));
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530807}
808
Jeff Johnson295189b2012-06-20 16:38:30 -0700809void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
810{
811 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
812 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700813
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700815
816 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700818 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
820 {
821 VOS_ASSERT( pRoamInfo->pBssDesc );
822 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
823
824 // Save the Station ID for this station from the 'Roam Info'.
825 //For IBSS mode, staId is assigned in NEW_PEER_IND
826 //For reassoc, the staID doesn't change and it may be invalid in this structure
827 //so no change here.
828 if( !pRoamInfo->fReassocReq )
829 {
830 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
831 }
832 }
833 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700834 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700836 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 else
838 {
839 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
840 // or we can't function.
841 VOS_ASSERT( 0 );
842 }
843
844 // notify WMM
845 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
846
847 if( !pRoamInfo->u.pConnectedProfile )
848 {
849 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
850 }
851 else
852 {
853 // Get Multicast Encryption Type
854 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
855 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
856 // Get Unicast Encrytion Type
857 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
858 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
859
860 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
861
862 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
863
864 // Save the ssid for the connection
865 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530866
867 // Save dot11mode in which STA associated to AP
868 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530869
870 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 }
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530872 hdd_save_bss_info(pAdapter, pRoamInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700873 }
874
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700876 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
877
Jeff Johnson295189b2012-06-20 16:38:30 -0700878}
879
880#if defined(WLAN_FEATURE_VOWIFI_11R)
881/*
882 * Send the 11R key information to the supplicant.
883 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800884 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 * for the same purpose.)
886 *
887 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
888 * this contains the R1KHID, R0KHID and the MDID.
889 * For FT, this consists of the Reassoc Rsp FTIEs.
890 * This is the Assoc Response.
891 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700892static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 tCsrRoamInfo *pCsrRoamInfo)
894{
895 union iwreq_data wrqu;
896 char *buff;
897 unsigned int len = 0;
898 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700899
900 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 {
902 hddLog(LOGE,
903 "%s: pCsrRoamInfo->nAssocRspLength=%d",
904 __func__, (int)pCsrRoamInfo->nAssocRspLength);
905 return;
906 }
907
Shailender Karmuchia734f332013-04-19 14:02:48 -0700908 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700910 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700912 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 return;
914 }
915
916 // pFTAssocRsp needs to point to the IEs
917 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
918 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
919 (unsigned int)pFTAssocRsp[0],
920 (unsigned int)pFTAssocRsp[1]);
921
922 // We need to send the IEs to the supplicant.
923 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700924 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700926 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 return;
928 }
929
930 // Send the Assoc Resp, the supplicant needs this for initial Auth.
931 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700932 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700934 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
936
937 kfree(buff);
938}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700939#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700940
941#ifdef WLAN_FEATURE_VOWIFI_11R
942
943/*---------------------------------------------------
944 *
945 * Send the FTIEs, RIC IEs during FT. This is eventually
946 * used to send the FT events to the supplicant
947 *
948 * At the reception of Auth2 we send the RIC followed
949 * by the auth response IEs to the supplicant.
950 * Once both are received in the supplicant, an FT
951 * event is generated to the supplicant.
952 *
953 *---------------------------------------------------
954 */
955void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
956{
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 tANI_U16 auth_resp_len = 0;
958 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
960
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530961#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700962 struct cfg80211_ft_event_params ftEvent;
963 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
964 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
965 struct net_device *dev = pAdapter->dev;
966#else
967 char *buff;
968 union iwreq_data wrqu;
969 tANI_U16 str_len;
970#endif
971
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530972#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530973 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
974 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700975
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530976 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
977 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530978 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700979 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530980 hddLog(LOGW,
981 "%s: RIC IEs is of length 0 not sending RIC Information for now",
982 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700983 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700984
985 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530986 ftEvent.ric_ies_len = ric_ies_length;
987 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700988
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530989 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800990 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700991
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530992 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700993 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530994 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700995 return;
996 }
997
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530998 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530999
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301000 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001001
1002 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
1003 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
1004
Jeff Johnson59a121e2013-11-30 09:46:08 -08001005 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
1006 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
1007 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301008 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001009 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
1010 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1011 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001012
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301013 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001014
1015#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301016 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301018 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301020 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 return;
1022 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301023 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001024
Shailender Karmuchia734f332013-04-19 14:02:48 -07001025 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301027 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001028 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301029 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301031 hddLog(LOGW,
1032 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1033 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 }
1035 else
1036 {
1037 wrqu.data.length = str_len + ric_ies_length;
1038 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1039 }
1040
1041 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301042 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301044 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
1045 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301047 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301049 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +05301050 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 return;
1052 }
1053
1054 wrqu.data.length = str_len + auth_resp_len;
1055 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1056
1057 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001058#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001059}
1060
1061#endif /* WLAN_FEATURE_VOWIFI_11R */
1062
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001063#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001064
1065/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001066 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 * (This keeps the supplicant "up to date" on the current channel.)
1068 *
1069 * The current (new AP) channel information is passed in.
1070 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001071static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 tCsrRoamInfo *pCsrRoamInfo)
1073{
1074 union iwreq_data wrqu;
1075 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
Shailender Karmuchia734f332013-04-19 14:02:48 -07001077
1078 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 {
1080 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001081 "%s: pCsrRoamInfo->pBssDesc=%pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 __func__, descriptor);
1083 return;
1084 }
1085
1086 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -08001087 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 memset(&wrqu, '\0', sizeof(wrqu));
1089 wrqu.freq.m = descriptor->channelId;
1090 wrqu.freq.e = 0;
1091 wrqu.freq.i = 0;
1092 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1093}
1094
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001095#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001096
1097void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
1098{
1099 union iwreq_data wrqu;
1100 u8 *pBeaconIes;
1101 u8 currentLen = 0;
1102 char *buff;
1103 int totalIeLen = 0, currentOffset = 0, strLen;
1104
1105 memset(&wrqu, '\0', sizeof(wrqu));
1106
1107 if (0 == pCsrRoamInfo->nBeaconLength)
1108 {
1109 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
1110 return;
1111 }
1112 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001113 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001115 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 return;
1117 }
1118
1119 // pBeaconIes needs to point to the IEs
1120 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
1121 (unsigned int)pBeaconIes[0],
1122 (unsigned int)pBeaconIes[1]);
1123 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001124
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 // We need to send the IEs to the supplicant.
1126 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001127 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001129 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 return;
1131 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001132 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001133
1134 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
1135 currentLen = strLen + 1;
1136
1137 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1138 do
1139 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001140 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 * max size and send it to supplicant. Changes are done in supplicant to handle this */
1142 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
1143 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
1144 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
1145 currentOffset += currentLen;
1146 totalIeLen -= currentLen;
1147 wrqu.data.length = strLen + 1 + currentLen;
1148 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -07001149 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -07001150 else
1151 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
1152
1153 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
1154 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1155 } while (totalIeLen > 0);
1156
1157 kfree(buff);
1158}
1159
1160static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
1161{
1162 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1163 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1164 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1165 union iwreq_data wrqu;
1166 int we_event;
1167 char *msg;
1168 int type = -1;
1169
Shailender Karmuchia734f332013-04-19 14:02:48 -07001170#if defined (WLAN_FEATURE_VOWIFI_11R)
1171 // Added to find the auth type on the fly at run time
1172 // rather than with cfg to see if FT is enabled
1173 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
1175#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001176
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001178 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001180
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
1182 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301183 /* In case of roaming ; We are not doing disconnect.
1184 * If disconnect is not being done for roam; We will not
1185 * decrease count for Active sessions. We should not increase active
1186 * active session in case of roaming.
1187 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +05301188 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +05301189 {
1190 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
1191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
1193 type = WLAN_STA_ASSOC_DONE_IND;
1194
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001195#ifdef WLAN_FEATURE_P2P_DEBUG
1196 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1197 {
1198 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
1199 {
1200 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
1201 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1202 "Connecting state to Connected State for 8-way "
1203 "Handshake");
1204 }
1205 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
1206 {
1207 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
1208 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1209 "Connecting state to P2P Client Connection Completed");
1210 }
1211 }
1212#endif
Yeshwanth Sriram Guntuka0004c0b2017-12-06 14:43:49 +05301213 hddLog(VOS_TRACE_LEVEL_ERROR, MAC_ADDRESS_STR " connected to "
1214 MAC_ADDRESS_STR,
1215 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1216 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
1218
Bhargav Shahd0715912015-10-01 18:17:37 +05301219 hdd_manage_delack_timer(pHddCtx);
1220
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
1222 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
1223 * and fFTEnable is TRUE */
1224#ifdef WLAN_FEATURE_VOWIFI_11R
1225 // Send FT Keys to the supplicant when FT is enabled
1226 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -07001227 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001228#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1230 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
1231#endif
1232 )
1233 {
1234 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
1235 }
1236#endif
1237 }
1238 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
1239 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301240 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -07001241 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301243
1244 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1245 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
1246 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 }
1248 else /* Not Associated */
1249 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1251 "wlan: disconnected");
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 type = WLAN_STA_DISASSOC_DONE_IND;
1253 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +05301254
1255 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001257 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
1259 msg = NULL;
1260 /*During the WLAN uninitialization,supplicant is stopped before the
1261 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301262 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 {
1264 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001265#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001267 {
1268 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1269 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
1271 }
1272#endif
1273 }
1274 send_btc_nlink_msg(type, 0);
1275}
1276
1277void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
1278{
1279 // Remove staId, bssId and peerMacAddress
1280 pHddStaCtx->conn_info.staId [ 0 ] = 0;
1281 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
1282 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
1283
1284 // Clear all security settings
1285 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1286 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1287 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1288
1289 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -07001290 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001291
1292 // Set not-connected state
1293 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -07001294
1295 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
1296}
Katya Nigam47528772015-02-11 12:24:49 +05301297
1298VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
1299{
Katya Nigam1fd24402015-02-16 14:52:19 +05301300 v_U8_t ac;
1301 /**Track whether OS TX queue has been disabled.*/
1302 v_BOOL_t txSuspended[NUM_TX_QUEUES];
1303 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +05301304 v_U8_t i;
1305 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1306 hdd_ibss_peer_info_t *pPeerInfo;
1307
1308 if( NULL == pHddStaCtx )
1309 {
1310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1311 "%s: HDD station context NULL ",__func__);
1312 return VOS_STATUS_E_FAILURE;
1313 }
Katya Nigam1fd24402015-02-16 14:52:19 +05301314
Katya Nigam47528772015-02-11 12:24:49 +05301315 pPeerInfo = &pHddStaCtx->ibss_peer_info;
1316 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
1317 {
1318 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1319 "%s: Deinit station not inited %d", __func__, STAId );
1320 return VOS_STATUS_E_FAILURE;
1321 }
1322
1323 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +05301324
1325 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1326 {
1327 tlAC = hdd_QdiscAcToTlAC[ac];
1328 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
1329 }
1330
Katya Nigam47528772015-02-11 12:24:49 +05301331 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1332
Katya Nigam1fd24402015-02-16 14:52:19 +05301333 /* re-init hdd list, since netdev can still open adapter until
1334 * driver gets unloaded
1335 */
1336 for (i = 0; i < NUM_TX_QUEUES; i ++)
1337 {
1338 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
1339 HDD_TX_QUEUE_MAX_LEN);
1340 }
1341
1342 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1343 {
1344 if (txSuspended[ac])
1345 {
1346 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1347 "%s: TX queue re-enabled", __func__);
1348 netif_wake_subqueue(pAdapter->dev, ac);
1349 }
1350 }
Katya Nigam47528772015-02-11 12:24:49 +05301351 return VOS_STATUS_SUCCESS;
1352}
1353
1354static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1355{
1356 VOS_STATUS vosStatus;
1357
1358 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1359 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1360 {
1361 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1362 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1363 "Status= %d [0x%08X]",
1364 __func__, staId, vosStatus, vosStatus );
1365 }
1366
1367 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
1368 if( VOS_STATUS_E_FAILURE == vosStatus )
1369 {
1370 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1371 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
1372 "Status = %d [0x%08X]",
1373 staId, vosStatus, vosStatus );
1374 }
1375
1376 return( vosStatus );
1377}
1378
1379VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
1380{
1381 v_U8_t i = 0;
1382 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1383 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1384
1385 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
1386 {
1387 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1388 "%s: Reinit station %d", __func__, STAId );
1389 return VOS_STATUS_E_FAILURE;
1390 }
1391
1392 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1393 for (i = 0; i < NUM_TX_QUEUES; i ++)
1394 {
1395 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
1396 }
1397
1398 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
1399 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
1400 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
1401
1402 return VOS_STATUS_SUCCESS;
1403}
1404
1405static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
1406 tCsrRoamInfo *pRoamInfo,
1407 v_U8_t staId,
1408 v_MACADDR_t *pPeerMacAddress,
1409 tSirBssDescription *pBssDesc )
1410{
1411 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1412 WLAN_STADescType staDesc = {0};
1413 eCsrEncryptionType connectedCipherAlgo;
1414 v_BOOL_t fConnected;
1415 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1416 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1417 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1418
1419 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
1420 {
1421 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1422 "clean up old entry for STA %d", staId);
1423 hdd_ibss_DeregisterSTA( pAdapter, staId );
1424 }
1425
1426 staDesc.ucSTAId = staId;
1427 staDesc.wSTAType = WLAN_STA_IBSS;
1428
1429 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1430 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1431 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1432 // pass when making an Infrastructure connection.
1433 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
1434 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
1435 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1436
1437 if (hdd_wmm_is_active(pAdapter))
1438 {
1439 staDesc.ucQosEnabled = 1;
1440 }
1441 else
1442 {
1443 staDesc.ucQosEnabled = 0;
1444 }
1445 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1446 "HDD SOFTAP register TL QoS_enabled=%d",
1447 staDesc.ucQosEnabled );
1448
1449 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1450 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1451 {
1452 staDesc.ucProtectedFrame = 1;
1453 }
1454 else
1455 {
1456 staDesc.ucProtectedFrame = 0;
1457
1458 }
1459
1460 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
1461
1462 // UMA is Not ready yet, Xlation will be done by TL
1463 staDesc.ucSwFrameTXXlation = 1;
1464 staDesc.ucSwFrameRXXlation = 1;
1465 staDesc.ucAddRmvLLC = 1;
1466 // Initialize signatures and state
1467 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1468 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1469 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
1470
1471 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1472
1473 // Register the Station with TL.
1474 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1475 hdd_rx_packet_cbk,
1476 hdd_tx_complete_cbk,
1477 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
1478 pBssDesc->rssi );
1479 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1480 {
1481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1482 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
1483 vosStatus, vosStatus );
1484 return vosStatus;
1485 }
1486
1487 //Timer value should be in milliseconds
1488 if ( pHddCtx->cfg_ini->dynSplitscan &&
1489 ( VOS_TIMER_STATE_RUNNING !=
1490 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1491 {
1492 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1493 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
1494 }
1495
1496 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
1497 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
1498
1499 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
1500 WLANTL_STA_AUTHENTICATED );
1501
1502 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
1503 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1504
1505 return( vosStatus );
1506}
1507
Jeff Johnson295189b2012-06-20 16:38:30 -07001508/* TODO Revist this function. and data path */
1509static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1510{
1511 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -07001512
Katya Nigam47528772015-02-11 12:24:49 +05301513 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -07001514
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1516 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1517 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05301518 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001520 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001521 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 }
1523 return( vosStatus );
1524}
1525
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301526/**
1527 * hdd_print_bss_info() - print bss info
1528 * @hdd_sta_ctx: pointer to hdd station context
1529 *
1530 * Return: None
1531 */
1532void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
1533{
1534 uint32_t *cap_info;
1535
1536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"WIFI DATA LOGGER");
1537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"channel: %d",
1538 hdd_sta_ctx->conn_info.freq);
1539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"dot11mode: %d",
1540 hdd_sta_ctx->conn_info.dot11Mode);
1541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"AKM: %d",
1542 hdd_sta_ctx->conn_info.authType);
1543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ssid: %.*s",
1544 hdd_sta_ctx->conn_info.SSID.SSID.length,
1545 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"roam count: %d",
1547 hdd_sta_ctx->conn_info.roam_count);
1548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ant_info: %d",
1549 hdd_sta_ctx->conn_info.txrate.nss);
1550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate legacy %d",
1551 hdd_sta_ctx->conn_info.txrate.legacy);
1552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate mcs: %d",
1553 hdd_sta_ctx->conn_info.txrate.mcs);
1554 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1555 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ht caps: %x",
1557 *cap_info);
1558 }
1559 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1560 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"vht caps: %x",
1562 *cap_info);
1563 }
1564 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"hs20 info: %x",
1566 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"signal: %d",
1568 hdd_sta_ctx->conn_info.signal);
1569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"noise: %d",
1570 hdd_sta_ctx->conn_info.noise);
1571}
1572
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301573/**
1574 * hdd_check_and_move_if_sap_is_on_dfs_chan() - move the sap to non dfs channel
1575 * @hdd_ctx: pointer to hdd context
1576 * @sta_adapter: pointer to sta adapater
1577 *
1578 * This function is used to check if SAP is operating on DFS channel in stand
1579 * alone mode and move it to non dfs channel
1580 *
1581 * Return: void.
1582 */
1583static void hdd_check_and_move_if_sap_is_on_dfs_chan(hdd_context_t *hdd_ctx,
1584 hdd_adapter_t *sta_adapter)
1585{
1586 hdd_adapter_t *sap_adapter;
1587 ptSapContext sap_ctx;
1588 v_CONTEXT_t vos_ctx;
1589 eNVChannelEnabledType chan_state;
1590
1591 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_ctx)) {
1592 sap_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_SOFTAP);
1593
1594 if (!sap_adapter) {
1595 hddLog(LOG1, FL("SAP not exists, nothing to do"));
1596 return;
1597 }
1598
1599 vos_ctx = hdd_ctx->pvosContext;
1600 if (!vos_ctx) {
1601 hddLog(LOGE, FL("vos_ctx is NULL"));
1602 return;
1603 }
1604 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
1605 if (!sap_ctx) {
1606 hddLog(LOG1, FL("sap_ctx not exists"));
1607 return;
1608 }
1609
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301610 if (sap_ctx->sapsMachine != eSAP_STARTED) {
1611 hddLog(LOG1, FL("SAP is not in eSAP_STARTED state"));
1612 return;
1613 }
1614
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301615 chan_state = vos_nv_getChannelEnabledState(sap_ctx->channel);
1616
1617 hddLog(LOG1, "SAP is operating on channel (%hu), chan_state %d",
1618 sap_ctx->channel, chan_state);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301619 if (vos_nv_getChannelEnabledState(sap_ctx->channel) !=
1620 NV_CHANNEL_DFS) {
1621 hddLog(LOG1, "SAP is on non DFS channel. nothing to do");
1622 return;
1623 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301624
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301625 hddLog(LOG1, "Schedule workqueue to move the SAP to non DFS channel");
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301626 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
1627 msecs_to_jiffies(ECSA_DFS_CHAN_CHANGE_DEFER_TIME));
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301628 }
1629}
Jeff Johnson295189b2012-06-20 16:38:30 -07001630
1631static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1632 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1633 eCsrRoamResult roamResult )
1634{
1635 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07001636 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 struct net_device *dev = pAdapter->dev;
1638 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1639 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -07001640 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301641 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001642
1643 // Sanity check
1644 if(dev == NULL)
1645 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301646 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001647 "%s: net_dev is released return", __func__);
1648 return eHAL_STATUS_FAILURE;
1649 }
1650
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 netif_tx_disable(dev);
1654 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301655 //TxTimeoutCount need to reset in case of disconnect handler
1656 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001657
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301658 wlan_hdd_check_and_stop_mon(pAdapter, false);
1659
Jeff Johnsone7245742012-09-05 17:12:55 -07001660 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301661 /* If only STA mode is on */
1662 if((pHddCtx->concurrency_mode <= 1) &&
1663 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1664 {
1665 pHddCtx->isAmpAllowed = VOS_TRUE;
1666 }
1667
Agarwal Ashish47d18112014-08-04 19:55:07 +05301668 /* Need to apply spin lock before decreasing active sessions
1669 * as there can be chance for double decrement if context switch
1670 * Calls wlan_hdd_disconnect.
1671 */
1672
1673 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301674
1675 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301676 * to kernel. Sending disconnected event to kernel for userspace
1677 * initiated disconnect will be handled by diconnect handler call
1678 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301679 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301680 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301681 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) ||
1682 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301683 {
1684 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1685 FL(" HDD has initiated a disconnect, no need to send"
1686 " disconnect indication to kernel"));
1687 sendDisconInd = FALSE;
1688 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301689 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301691 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301692 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301693 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301694 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1695 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301697 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh78c691f2017-11-30 13:48:44 +05301698 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001700
1701 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001702
1703 // indicate 'disconnect' status to wpa_supplicant...
1704 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 /* indicate disconnected event to nl80211 */
1706 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1707 {
1708 /*During the WLAN uninitialization,supplicant is stopped before the
1709 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301710 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301712 if (sendDisconInd)
1713 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1714 "%s: sent disconnected event to nl80211",
1715 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001716#ifdef WLAN_FEATURE_P2P_DEBUG
1717 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1718 {
1719 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1720 {
1721 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1722 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1723 "and moved to disconnected state");
1724 }
1725 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1726 {
1727 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1728 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1729 "and moved to inactive state");
1730 }
1731 }
1732#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301733 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1734 !pRoamInfo->reasonCode)
1735 wlan_hdd_get_frame_logs(pAdapter,
1736 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301737 /*Only send indication to kernel if not initiated by kernel*/
1738 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301740 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1741 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1742 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301743 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1744 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301745 }
1746 else
1747 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301748 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301749 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301752
1753 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1754 {
1755 hddLog(LOG1,
1756 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1757 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301758 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301759
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 //If the Device Mode is Station
1761 // and the P2P Client is Connected
1762 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001763
1764 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001765 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001766 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 {
1768 //Enable BMPS only of other Session is P2P Client
1769 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001770 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001771
1772 if (NULL != pVosContext)
1773 {
1774 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1775
1776 if(NULL != pHddCtx)
1777 {
1778 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301779 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1780 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301782 if (pHddCtx->hdd_wlan_suspended)
1783 {
1784 hdd_set_pwrparams(pHddCtx);
1785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 }
1789 }
1790 }
1791 }
1792 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001793
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301794 hdd_wmm_adapter_clear(pAdapter);
Kapil Guptae6867482016-06-26 13:31:37 +05301795 /* Clear PER based roam stats */
1796#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1797 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1798 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1799 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1800 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1801 sme_unset_per_roam_rxconfig(pHddCtx->hHal);
1802#endif
Mukul Sharmac159c432014-01-15 15:42:46 +05301803#if defined(WLAN_FEATURE_VOWIFI_11R)
1804 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1805#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301806
1807 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1808 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301809 v_U8_t i;
1810
Katya Nigam63ce1772014-09-26 15:53:49 +05301811 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301812 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301813 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1814 {
1815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301816 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1817 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301818 sta_id, status, status );
1819
1820 status = eHAL_STATUS_FAILURE;
1821 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301822 pHddCtx->sta_to_adapter[sta_id] = NULL;
1823
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301824 /*Clear all the peer sta register with TL.*/
1825 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1826 {
1827 if (0 != pHddStaCtx->conn_info.staId[i])
1828 {
1829 sta_id = pHddStaCtx->conn_info.staId[i];
1830
1831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1832 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301833 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301834 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1835 {
1836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1837 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1838 "Status= %d [0x%x]"),
1839 sta_id, status, status );
1840 status = eHAL_STATUS_FAILURE;
1841 }
1842
Nirav Shah7e3c8132015-06-22 23:51:42 +05301843 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1844 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1845 if (vstatus != VOS_STATUS_SUCCESS) {
1846 hddLog(VOS_TRACE_LEVEL_ERROR,
1847 FL("Not able to remove staid hash %d"),
1848 sta_id);
1849 status = eHAL_STATUS_FAILURE;
1850 } else {
1851 hddLog(VOS_TRACE_LEVEL_INFO,
1852 FL("ibss station removed sta_id %d mac:"
1853 MAC_ADDRESS_STR), sta_id,
1854 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1855 }
1856
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301857 /*set the staid and peer mac as 0, all other reset are
1858 * done in hdd_connRemoveConnectInfo.
1859 */
1860 pHddStaCtx->conn_info.staId[i]= 0;
1861 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1862
1863 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1864 pHddCtx->sta_to_adapter[sta_id] = NULL;
1865 }
1866 }
1867
Katya Nigam63ce1772014-09-26 15:53:49 +05301868 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301869 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301871 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301872 /* clear scan cache for Link Lost */
1873 if (pRoamInfo && !pRoamInfo->reasonCode &&
1874 (eCSR_ROAM_LOSTLINK == roamStatus)) {
1875 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1876 pHddStaCtx->conn_info.bssId);
1877 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1878 pHddStaCtx->conn_info.bssId);
1879 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301880
1881 //We should clear all sta register with TL, for now, only one.
1882 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1883 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1884 {
1885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1886 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1887 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001888 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001889
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301890 status = eHAL_STATUS_FAILURE;
1891 }
1892
1893 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301895
1896#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1897 if (VOS_STATUS_SUCCESS !=
1898 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1899 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1900 {
1901 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1902 "WLANTL_ClearInterfaceStats Failed", __func__);
1903 }
1904 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1905 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1906 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1907 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1908#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Sravan Kumar Kairamf9f95122017-01-18 20:54:05 +05301909 pAdapter->dad = false;
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301910
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 // Clear saved connection information in HDD
1912 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301913
1914 /*
1915 * eConnectionState_Connecting state mean that connection is in progress so
1916 * no need to set state to eConnectionState_NotConnected
1917 */
1918 if ((eConnectionState_Connecting != pHddStaCtx->conn_info.connState)) {
1919 hddLog(LOG1, FL("Set HDD connState to eConnectionState_NotConnected"));
1920 hdd_connSetConnectionState(pHddStaCtx, eConnectionState_NotConnected);
1921 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301922#ifdef WLAN_FEATURE_GTK_OFFLOAD
1923 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1924 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1925 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301926 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1927 sizeof (tSirGtkOffloadParams));
1928 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301929 }
1930#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001931
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001932#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001933 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1934 {
1935 wlan_hdd_tdls_disconnection_callback(pAdapter);
1936 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001937#endif
1938
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 //Unblock anyone waiting for disconnect to complete
1940 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301941 hdd_print_bss_info(pHddStaCtx);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301942
1943 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 return( status );
1945}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301946
1947static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1948 v_U8_t staId)
1949{
1950 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1951 v_SINT_t i;
1952 v_SIZE_t size;
1953 VOS_STATUS status;
1954 v_BOOL_t granted = VOS_FALSE;
1955
1956 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1957 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1958 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1959 {
1960 //Indicate to TL that there is pending data if a queue is non empty
1961 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1962 {
1963 size = 0;
1964 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1965 if (size > 0)
1966 {
1967 if (i != WLANTL_AC_HIGH_PRIO)
1968 {
1969 if (VOS_FALSE ==
1970 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1971 {
1972 hdd_wmm_acquire_access(pAdapter,
1973 (WLANTL_ACEnumType)i, &granted);
1974 pAdapter->psbChanged |= (1 << i);
1975 }
1976 else
1977 granted = VOS_TRUE;
1978 }
1979
1980 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1981 {
1982 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1983 staId, (WLANTL_ACEnumType)i);
1984 if (!VOS_IS_STATUS_SUCCESS(status))
1985 {
1986 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1987 "%s: Failure in indicating pkt to TL for QID=%d",
1988 __func__, i);
1989 }
1990 }
1991 }
1992 }
1993 }
1994}
1995
Jeff Johnson295189b2012-06-20 16:38:30 -07001996static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1997 tCsrRoamInfo *pRoamInfo,
1998 v_U8_t staId,
1999 v_MACADDR_t *pPeerMacAddress,
2000 tSirBssDescription *pBssDesc )
2001{
2002 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2003 WLAN_STADescType staDesc = {0};
2004 eCsrEncryptionType connectedCipherAlgo;
2005 v_BOOL_t fConnected;
2006 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2007 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002008 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002009
2010 if ( NULL == pBssDesc)
2011 {
2012 return VOS_STATUS_E_FAILURE;
2013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 // Get the Station ID from the one saved during the assocation.
2015 staDesc.ucSTAId = staId;
2016
Katya Nigam47528772015-02-11 12:24:49 +05302017 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002018
Katya Nigam47528772015-02-11 12:24:49 +05302019 // grab the bssid from the connection info in the adapter structure and hand that
2020 // over to TL when registering.
2021 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
2022 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002023
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2025
2026 // set the QoS field appropriately
2027 if (hdd_wmm_is_active(pAdapter))
2028 {
2029 staDesc.ucQosEnabled = 1;
2030 }
2031 else
2032 {
2033 staDesc.ucQosEnabled = 0;
2034 }
2035
2036 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2037 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
2038 {
2039 staDesc.ucProtectedFrame = 1;
2040 }
2041 else
2042 {
2043 staDesc.ucProtectedFrame = 0;
2044
2045 }
2046
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002047#ifdef FEATURE_WLAN_ESE
2048 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
2049#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002050
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 /* check whether replay check is valid for the station or not */
2052 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
2053 {
2054 /* Encryption mode is either TKIP or AES
2055 and replay check is valid for only these
2056 two encryption modes */
2057 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2058 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2059 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
2060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 else
2062 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002063 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002065 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2067 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
2068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002069
2070#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002071 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 if (pAdapter->wapi_info.fIsWapiSta)
2073 {
2074 staDesc.ucIsWapiSta = 1;
2075 }
2076 else
2077 {
2078 staDesc.ucIsWapiSta = 0;
2079 }
2080#endif /* FEATURE_WLAN_WAPI */
2081
2082 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2083 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
2084
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 // UMA is Not ready yet, Xlation will be done by TL
2086 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 staDesc.ucSwFrameRXXlation = 1;
2088 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002089 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 staDesc.ucQosEnabled );
2091 // Initialize signatures and state
2092 staDesc.ucUcastSig = pRoamInfo->ucastSig;
2093 staDesc.ucBcastSig = pRoamInfo->bcastSig;
2094 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
2095 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002096 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08002097 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 -07002098 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
2099 hdd_rx_packet_cbk,
2100 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 hdd_tx_fetch_packet_cbk, &staDesc,
2102 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002103
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2105 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002106 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002107 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002109 return vosStatus;
2110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002111
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002112 if ( cfg_param->dynSplitscan &&
2113 ( VOS_TIMER_STATE_RUNNING !=
2114 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
2115 {
2116 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2117 cfg_param->trafficMntrTmrForSplitScan);
2118 }
2119
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302120 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
2121 // then go to 'authenticated'. For all other authentication types
2122 // (those that donot require upper layer authentication) we can put
2123 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002124 if (staDesc.wSTAType != WLAN_STA_IBSS)
2125 VOS_ASSERT( fConnected );
2126
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302127 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002128 {
2129 // Connections that do not need Upper layer auth, transition TL directly
2130 // to 'Authenticated' state.
2131 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
2132 WLANTL_STA_AUTHENTICATED );
2133
2134 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302135
2136 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002137 }
2138 else
2139 {
2140 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302141 "ULA auth StaId= %d. Changing TL state to CONNECTED"
2142 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002143 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05302144 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002145 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 return( vosStatus );
2148}
2149
Jeff Johnson295189b2012-06-20 16:38:30 -07002150static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
2151 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
2152{
2153 unsigned int len = 0;
2154 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002155 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 tANI_U32 rspRsnLength = 0;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302157 struct cfg80211_bss* bss;
2158 tCsrRoamConnectedProfile roam_profile;
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 struct ieee80211_channel *chan;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302160 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002161
Agarwal Ashish51325b52014-06-16 16:50:49 +05302162 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002163 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07002164 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002165 }
2166
Agarwal Ashish51325b52014-06-16 16:50:49 +05302167 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002168 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
2169 goto done;
2170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002171
Agarwal Ashish51325b52014-06-16 16:50:49 +05302172 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002173 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
2174 goto done;
2175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002176
2177 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2178 pCsrRoamInfo->nAssocReqLength);
2179 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002180 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002181
2182 //pFTAssocRsp needs to point to the IEs
2183 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002184 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 (unsigned int)pFTAssocRsp[0],
2186 (unsigned int)pFTAssocRsp[1]);
2187
2188 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08002189 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002192 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002193
Abhishek Singh5a597e62016-12-05 15:16:30 +05302194 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
2195 (int) pCsrRoamInfo->pBssDesc->channelId);
2196 vos_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
2197 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roam_profile);
2198 bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2199 chan, pCsrRoamInfo->bssid,
2200 &roam_profile.SSID.ssId[0],
2201 roam_profile.SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302202 hdd_send_roamed_ind(dev, bss,
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 reqRsnIe, reqRsnLength,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302204 rspRsnIe, rspRsnLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002205
2206done:
2207 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07002208}
Jeff Johnson295189b2012-06-20 16:38:30 -07002209
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302210void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
2211{
2212 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2213 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2214 tCsrRoamInfo roamInfo;
2215 roamInfo.fAuthRequired = FALSE;
2216 vos_mem_copy(roamInfo.bssid,
2217 pHddStaCtx->roam_info.bssid,
2218 WNI_CFG_BSSID_LEN);
2219 vos_mem_copy(roamInfo.peerMac,
2220 pHddStaCtx->roam_info.peerMac,
2221 WNI_CFG_BSSID_LEN);
2222
2223 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
2224 &roamInfo,
2225 pHddStaCtx->roam_info.roamId,
2226 pHddStaCtx->roam_info.roamStatus,
2227 eCSR_ROAM_RESULT_AUTHENTICATED);
2228 if (halStatus != eHAL_STATUS_SUCCESS)
2229 {
2230 hddLog(LOGE, "%s: Set Key complete failure", __func__);
2231 }
2232 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
2233}
2234
Abhishek Singh78c691f2017-11-30 13:48:44 +05302235/**
2236 * hdd_schedule_ecsa_chan_change_work() - schedule ecsa chan change work
2237 * @hal: hal context
2238 * @sta_session_id: sta session id
2239 *
2240 * Return: void.
2241 */
2242static void
2243hdd_schedule_ecsa_chan_change_work(hdd_context_t *hdd_ctx,
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302244 uint8_t sta_session_id)
Abhishek Singh78c691f2017-11-30 13:48:44 +05302245{
2246 v_TIME_t conn_start_time;
2247 int32_t time_diff;
2248
2249 conn_start_time = sme_get_connect_strt_time(hdd_ctx->hHal, sta_session_id);
2250 time_diff = vos_timer_get_system_time() - conn_start_time;
2251
2252 if (time_diff < 0)
2253 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL;
2254 else if (time_diff > ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL)
2255 time_diff = 0;
2256 else
2257 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL - time_diff;
2258
2259 hddLog(LOG1, FL("schedule ecsa_chan_change_work after %d ms"), time_diff);
2260 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
2261 msecs_to_jiffies(time_diff));
2262}
2263
Shailender Karmuchia734f332013-04-19 14:02:48 -07002264static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2265 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 eCsrRoamResult roamResult )
2267{
2268 struct net_device *dev = pAdapter->dev;
2269 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2270 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302271 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05302272 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002273 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2274 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002275#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 int ft_carrier_on = FALSE;
2277#endif
2278 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302279 v_BOOL_t hddDisconInProgress = FALSE;
2280
2281 /* HDD has initiated disconnect, do not send connect result indication
2282 * to kernel as it will be handled by __cfg80211_disconnect.
2283 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05302284 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
2285 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
2286 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2287 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302288 {
2289 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2290 FL(" Disconnect from HDD in progress "));
2291 hddDisconInProgress = TRUE;
2292 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002293
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
2295 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302296 if ( !hddDisconInProgress )
2297 {
2298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05302299 "%s: Set HDD connState to eConnectionState_Associated",
2300 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302301 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
2302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002303
c_hpothu44ff4e02014-05-08 00:13:57 +05302304 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 // Save the connection info from CSR...
2306 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05302307
2308#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2309 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
2310 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
2311 !hddDisconInProgress &&
2312 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
2313 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
2314 sme_set_per_roam_rxconfig(pHddCtx->hHal,
2315 pHddStaCtx->conn_info.staId[0],
2316 pHddCtx->cfg_ini->rateDownThreshold,
2317 pHddCtx->cfg_ini->rateUpThreshold,
2318 pHddCtx->cfg_ini->PERroamTriggerPercent,
2319 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
2320 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
2321#endif
2322
Jeff Johnson295189b2012-06-20 16:38:30 -07002323#ifdef FEATURE_WLAN_WAPI
2324 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
2325 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
2326 {
2327 pAdapter->wapi_info.fIsWapiSta = 1;
2328 }
2329 else
2330 {
2331 pAdapter->wapi_info.fIsWapiSta = 0;
2332 }
2333#endif /* FEATURE_WLAN_WAPI */
2334
2335 // indicate 'connect' status to userspace
2336 hdd_SendAssociationEvent(dev,pRoamInfo);
2337
2338
Shailender Karmuchia734f332013-04-19 14:02:48 -07002339 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 INIT_COMPLETION(pAdapter->linkup_event_var);
2341
2342 /*
2343 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
2344 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 -07002345 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 know that the device is getting activated properly.
2347 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002348#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05302349 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 {
2351#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002352 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 pAdapter->isLinkUpSvcNeeded = TRUE;
2354
Shailender Karmuchia734f332013-04-19 14:02:48 -07002355 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 pAdapter->isLinkUpSvcNeeded = TRUE;
2357
2358 // Switch on the Carrier to activate the device
2359 netif_carrier_on(dev);
2360
2361 // Wait for the Link to up to ensure all the queues are set properly by the kernel
2362 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
2363 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002364 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 {
2366 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
2367 }
2368
2369 // Disable Linkup Event Servicing - no more service required from the net device notifier call
2370 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002371#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002373 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 }
2377#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05302378 /* Check for STAID */
2379 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
2380 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2381 else
2382 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
2384 //For reassoc, the station is already registered, all we need is to change the state
2385 //of the STA in TL.
2386 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05302387 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 if( !pRoamInfo->fReassocReq )
2389 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002390 struct cfg80211_bss *bss;
2391#ifdef WLAN_FEATURE_VOWIFI_11R
2392 u8 *pFTAssocRsp = NULL;
2393 unsigned int assocRsplen = 0;
2394 u8 *pFTAssocReq = NULL;
2395 unsigned int assocReqlen = 0;
2396 struct ieee80211_channel *chan;
2397#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002400
2401 /* add bss_id to cfg80211 data base */
2402 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2403 if (NULL == bss)
2404 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302405 hddLog(LOGE,
2406 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05302407 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302408 if (!hddDisconInProgress) {
2409 /*
2410 * Here driver was not able to update cfg80211 database
2411 * this can happen if connected channel is not valid,
2412 * i.e reg domain was changed during connection.
2413 * Queue disconnect for the session if disconnect is
2414 * not in progress.
2415 */
2416 hddLog(LOGE, FL("Disconnecting..."));
2417 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2418 pAdapter->sessionId,
2419 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 return eHAL_STATUS_FAILURE;
2422 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002423#ifdef WLAN_FEATURE_VOWIFI_11R
2424 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002425 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002427
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002428 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07002429 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002430 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002431 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002432 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002433 // pFTAssocRsp needs to point to the IEs
2434 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2435 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
2436 (unsigned int)pFTAssocRsp[0],
2437 (unsigned int)pFTAssocRsp[1]);
2438 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002439 }
2440 else
2441 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002442 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
2443 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002444 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002445
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002446 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07002447 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002448 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002449 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002450 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002451 if(!ft_carrier_on)
2452 {
2453 // pFTAssocReq needs to point to the IEs
2454 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
2455 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
2456 (unsigned int)pFTAssocReq[0],
2457 (unsigned int)pFTAssocReq[1]);
2458 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
2459 }
2460 else
2461 {
2462 /* This should contain only the FTIEs */
2463 assocReqlen = pRoamInfo->nAssocReqLength;
2464 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002465 }
2466 else
2467 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002468 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
2469 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002470 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002471
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002472 if(ft_carrier_on)
2473 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302474 if ( !hddDisconInProgress )
2475 {
Abhishek Singh5a597e62016-12-05 15:16:30 +05302476 struct cfg80211_bss *roam_bss;
2477
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302478 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002479 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302480 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002481 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302482 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002483 assocRsplen);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302484 if (pHddCtx->cfg_ini &&
2485 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302486 {
2487 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2488 }
Abhishek Singh5a597e62016-12-05 15:16:30 +05302489 roam_bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2490 chan, pRoamInfo->bssid,
2491 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2492 pRoamInfo->u.pConnectedProfile->SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302493 hdd_send_roamed_ind(dev, roam_bss,
Abhishek Singh5a597e62016-12-05 15:16:30 +05302494 pFTAssocReq, assocReqlen,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302495 pFTAssocRsp, assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302496 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302497 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2498 {
2499 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
2500 pRoamInfo->fAuthRequired = FALSE;
2501
2502 vos_mem_copy(pHddStaCtx->roam_info.bssid,
2503 pRoamInfo->bssid,
2504 HDD_MAC_ADDR_LEN);
2505 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
2506 pRoamInfo->peerMac,
2507 HDD_MAC_ADDR_LEN);
2508 pHddStaCtx->roam_info.roamId = roamId;
2509 pHddStaCtx->roam_info.roamStatus = roamStatus;
2510 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
2511 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002512 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302513 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002514 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002515 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002516 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302517 hdd_connect_result(dev, pRoamInfo->bssid, pRoamInfo,
2518 pFTAssocReq, assocReqlen,
2519 pFTAssocRsp, assocRsplen,
2520 WLAN_STATUS_SUCCESS,
2521 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002522 }
2523 }
2524 else
2525#endif
2526 {
2527 /* wpa supplicant expecting WPA/RSN IE in connect result */
2528 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2529 pAdapter->sessionId,
2530 &reqRsnLength,
2531 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002532
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002533 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2534 pAdapter->sessionId,
2535 &rspRsnLength,
2536 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302537 if ( !hddDisconInProgress )
2538 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002539#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302540 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05302541 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302542 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302543 if (pHddCtx->cfg_ini &&
2544 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302545 {
2546 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2547 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302548 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302549 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002550#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002551
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302552 {
2553 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302554 "%s: sending connect indication to nl80211:"
2555 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302556 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302557 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
2558 roamResult, roamStatus);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302559 /* inform connect result to nl80211 */
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302560 hdd_connect_result(dev, pRoamInfo->bssid,
2561 pRoamInfo,
2562 reqRsnIe, reqRsnLength,
2563 rspRsnIe, rspRsnLength,
2564 WLAN_STATUS_SUCCESS,
2565 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302566 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302569 if ( !hddDisconInProgress )
2570 {
2571 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07002572#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302573 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07002574#endif
2575 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302576 // Register the Station with TL after associated...
2577 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 pRoamInfo,
2579 pHddStaCtx->conn_info.staId[ 0 ],
2580 NULL,
2581 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 }
2584 else
2585 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002586 /* wpa supplicant expecting WPA/RSN IE in connect result */
2587 /* in case of reassociation also need to indicate it to supplicant */
2588 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2589 pAdapter->sessionId,
2590 &reqRsnLength,
2591 reqRsnIe);
2592
2593 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302595 if( pRoamInfo->fAuthRequired )
2596 {
2597 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2598 pHddStaCtx->conn_info.staId[ 0 ],
2599 WLANTL_STA_CONNECTED );
2600 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2601 }
2602 else
2603 {
2604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2605 "%s: staId: %d Changing TL state to AUTHENTICATED",
2606 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
2607 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2608 pHddStaCtx->conn_info.staId[ 0 ],
2609 WLANTL_STA_AUTHENTICATED );
2610 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302611 hdd_postTLPacketPendingInd(pAdapter,
2612 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 }
2615
2616 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
2617 {
2618 // perform any WMM-related association processing
2619 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
2620 }
2621 else
2622 {
2623 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002624 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 vosStatus, vosStatus );
2626 }
Chet Lanctot186b5732013-03-18 10:26:30 -07002627#ifdef WLAN_FEATURE_11W
2628 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
2629 sizeof(pAdapter->hdd_stats.hddPmfStats) );
2630#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302631
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05302633 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302634 {
2635 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05302636 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302637 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302638 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302639 {
2640 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
2641 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05302642#ifdef FEATURE_WLAN_TDLS
2643 wlan_hdd_tdls_connection_callback(pAdapter);
2644#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002645 }
2646 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2649
2650 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002651 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302652 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2653 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
2654 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002655 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302656 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2657 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08002658 MAC_ADDR_ARRAY(pWextState->req_bssId),
2659 roamResult, roamStatus);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302660 if (!pHddStaCtx->get_mgmt_log_sent) {
2661 pHddStaCtx->get_mgmt_log_sent = TRUE;
Abhishek Singh611295e2015-07-09 11:11:54 +05302662 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302663 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302664 }
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302665
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302666 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2667 (pRoamInfo &&
2668 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2669 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2670 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
2671 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2672 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2673 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2674 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2675 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05302676 /* Set connection state to eConnectionState_NotConnected only when CSR
2677 * has completed operation - with a ASSOCIATION_FAILURE status
2678 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302679 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05302680 {
2681 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2682 "%s: Set HDD connState to eConnectionState_NotConnected",
2683 __func__);
2684 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
2685 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05302686 if((pHddCtx->concurrency_mode <= 1) &&
2687 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 {
2689 pHddCtx->isAmpAllowed = VOS_TRUE;
2690 }
2691
2692 //If the Device Mode is Station
2693 // and the P2P Client is Connected
2694 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07002695
2696 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07002697 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002698 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2699 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302700 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 {
2702 //Enable BMPS only of other Session is P2P Client
2703 hdd_context_t *pHddCtx = NULL;
2704 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2705
2706 if (NULL != pVosContext)
2707 {
2708 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2709
2710 if(NULL != pHddCtx)
2711 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302712 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302713 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2714 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302715 {
2716 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002717 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302718 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002719 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302720 hdd_enable_bmps_imps(pHddCtx);
2721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 }
2723 }
2724 }
2725
James Zmudafbf5ffc2013-03-25 12:45:35 -07002726 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002727 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302728 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002729 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302730
2731 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2732 {
2733 hddLog(LOG1,
2734 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2735 wlan_hdd_tdls_reenable(pHddCtx);
2736 }
2737
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302738 if (pRoamInfo) {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302739 hddLog(VOS_TRACE_LEVEL_ERROR,
2740 "%s: send connect failure to nl80211:"
2741 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302742 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302743 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302744 roamResult, roamStatus, pRoamInfo->reasonCode);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302745 pHddStaCtx->conn_info.assoc_status_code =
2746 pRoamInfo->statusCode;
2747 } else {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302748 hddLog(VOS_TRACE_LEVEL_ERROR,
2749 "%s: connect failed:"
2750 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302751 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302752 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2753 roamResult, roamStatus);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302754 }
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302755
James Zmudafbf5ffc2013-03-25 12:45:35 -07002756 /* inform association failure event to nl80211 */
2757 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2758 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002759 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302760 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002761 NULL, 0, NULL, 0,
2762 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302763 GFP_KERNEL);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002764 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302765 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002766 NULL, 0, NULL, 0,
2767 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302768 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002769 }
2770 else
2771 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002772 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302773 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002774 NULL, 0, NULL, 0,
2775 pRoamInfo->reasonCode ?
2776 pRoamInfo->reasonCode :
2777 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302778 GFP_KERNEL);
Gao Wu6ca73b32016-05-09 14:35:49 +08002779 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302780 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002781 NULL, 0, NULL, 0,
2782 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302783 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002784 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302785 /*Clear the roam profile*/
2786 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002788
Kumar Anand82c009f2014-05-29 00:29:42 -07002789 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002790
c_hpothu24f40982014-04-18 18:00:36 +05302791 if (pRoamInfo)
2792 {
2793 WLANTL_AssocFailed(pRoamInfo->staId);
2794 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302795
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302796 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 netif_tx_disable(dev);
2798 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002799
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 }
2801
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302802 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302803 {
2804 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2805 if (pHostapdAdapter != NULL)
2806 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302807 /* Restart SAP if its operating channel is different
2808 * from AP channel.
2809 */
2810 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2811 (int)pRoamInfo->pBssDesc->channelId)
2812 {
2813 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2814 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2815 (int)pRoamInfo->pBssDesc->channelId);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302816 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->force_scc_with_ecsa)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302817 {
Abhishek Singh78c691f2017-11-30 13:48:44 +05302818 hdd_schedule_ecsa_chan_change_work(pHddCtx,
2819 pAdapter->sessionId);
2820 }
2821 else
2822 {
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302823 hdd_hostapd_stop(pHostapdAdapter->dev);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302824 if (pHddCtx->cfg_ini &&
2825 pHddCtx->cfg_ini->enable_sap_auth_offload)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302826 hdd_force_scc_restart_sap(pHostapdAdapter,
2827 pHddCtx, (int)pRoamInfo->pBssDesc->channelId);
2828 }
Agrawal Ashish574b3e62017-02-09 18:58:34 +05302829
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302830 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302831 }
2832 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302833 else if (roamStatus == eCSR_ROAM_ASSOCIATION_FAILURE)
2834 {
2835 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
2836 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 return eHAL_STATUS_SUCCESS;
2838}
2839
2840/**============================================================================
2841 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002842 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002844
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002846static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2847 tCsrRoamInfo *pRoamInfo,
2848 tANI_U32 roamId,
2849 eRoamCmdStatus roamStatus,
2850 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002851{
Katya Nigam47528772015-02-11 12:24:49 +05302852 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2853 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2854 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302855 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302856
Jeff Johnson81c17882013-05-03 09:53:35 -07002857 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2858 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2859
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 switch( roamResult )
2861 {
2862 // both IBSS Started and IBSS Join should come in here.
2863 case eCSR_ROAM_RESULT_IBSS_STARTED:
2864 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002865 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002867 if (NULL == pRoamInfo)
2868 {
2869 VOS_ASSERT(0);
2870 return;
2871 }
2872
2873 /* When IBSS Started comes from CSR, we need to move
2874 * connection state to IBSS Disconnected (meaning no peers
2875 * are in the IBSS).
2876 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302877 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2878 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2879 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002880 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2881 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302882 /*notify wmm */
2883 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002884 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002885
Jeff Johnson81c17882013-05-03 09:53:35 -07002886 if (pRoamInfo->pBssDesc)
2887 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302888#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2889 struct ieee80211_channel *chan;
2890 int chan_no;
2891 unsigned int freq;
2892#endif
Katya Nigam47528772015-02-11 12:24:49 +05302893 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2894 IBSS_BROADCAST_STAID,
2895 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002896
2897 /* we created the IBSS, notify supplicant */
2898 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2899 MAC_ADDRESS_STR,
2900 __func__, pAdapter->dev->name,
2901 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2902
2903 /* we must first give cfg80211 the BSS information */
2904 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2905 if (NULL == bss)
2906 {
2907 hddLog(VOS_TRACE_LEVEL_ERROR,
2908 "%s: %s: unable to create IBSS entry",
2909 __func__, pAdapter->dev->name);
2910 return;
2911 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302912#ifdef WLAN_FEATURE_RMC
2913 netif_carrier_on(pAdapter->dev);
2914 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2915 netif_tx_start_all_queues(pAdapter->dev);
2916#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302917#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2918 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002919
Anand N Sunkadfec40682015-07-29 09:51:17 +05302920 if (chan_no <= 14)
2921 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302922 HDD_NL80211_BAND_2GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302923 else
2924 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302925 HDD_NL80211_BAND_5GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302926
2927 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2928
2929 if (chan)
2930 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2931 chan, GFP_KERNEL);
2932 else
2933 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2934 pAdapter->dev->name,
2935 (int)pRoamInfo->pBssDesc->channelId);
2936#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002937 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302938#endif
Yue Maf49ba872013-08-19 12:04:25 -07002939 cfg80211_put_bss(
2940#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2941 pHddCtx->wiphy,
2942#endif
2943 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002944 }
Katya Nigam47528772015-02-11 12:24:49 +05302945 else
2946 {
2947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2948 "%s: NULL Bss Desc",__func__);
2949 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302950
2951 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2952 * in IBSS_COALESCED will remove the BC key.
2953 */
2954 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2955 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2956 == pHddStaCtx->ibss_enc_key.encType
2957 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2958 == pHddStaCtx->ibss_enc_key.encType
2959 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2960 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2961 {
2962 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2963 VOS_STATUS vosStatus;
2964
2965 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2966
2967 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2968 grpmacaddr, WNI_CFG_BSSID_LEN);
2969 hddLog(VOS_TRACE_LEVEL_INFO,
2970 FL(" SET GTK in case of COALESCED"));
2971 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2972 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2973 if ( VOS_STATUS_SUCCESS != vosStatus )
2974 {
2975 hddLog(VOS_TRACE_LEVEL_ERROR,
2976 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2977 }
2978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 break;
2980 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002981
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2983 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002984 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2985 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 break;
2987 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002988
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002990 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2991 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002993 }
2994
Jeff Johnson81c17882013-05-03 09:53:35 -07002995 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002996}
2997
2998/**============================================================================
2999 *
3000 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
3001 This information is passed to iwconfig later. The peer that joined
3002 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003003 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003005
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05303007static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07003008{
3009 int fSuccess = FALSE;
3010 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303011 VOS_STATUS status;
3012 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003013
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3015 {
3016 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
3017 {
3018 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003019
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003021
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 fSuccess = TRUE;
3023 break;
3024 }
3025 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003026
Nirav Shah7e3c8132015-06-22 23:51:42 +05303027 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
3028 if (status != VOS_STATUS_SUCCESS) {
3029 hddLog(VOS_TRACE_LEVEL_ERROR,
3030 FL("Not able to add staid hash %d"), staId);
3031 return FALSE;
3032 }
3033
3034 hddLog(VOS_TRACE_LEVEL_INFO,
3035 FL("New station added sta_id %d mac:"
3036 MAC_ADDRESS_STR), staId,
3037 MAC_ADDR_ARRAY(peerMacAddress->bytes));
3038
Shailender Karmuchia734f332013-04-19 14:02:48 -07003039 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07003040}
3041/**============================================================================
3042 *
3043 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003044 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003046
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07003048static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003049{
3050 int fSuccess = FALSE;
3051 int idx = 0;
3052 v_U8_t valid_idx = 0;
3053 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07003054 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003055 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05303056 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003057
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3059 {
3060 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
3061 {
3062 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303063 status = hdd_sta_id_hash_remove_entry(pAdapter,
3064 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
3065 if (status != VOS_STATUS_SUCCESS) {
3066 hddLog(VOS_TRACE_LEVEL_ERROR,
3067 FL("Not able to remove staid hash %d"), staId );
3068 fSuccess = FALSE;
3069 } else {
3070 hddLog(VOS_TRACE_LEVEL_INFO,
3071 FL("station removed sta_id %d mac:"
3072 MAC_ADDRESS_STR), staId,
3073 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07003074
Nirav Shah7e3c8132015-06-22 23:51:42 +05303075 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07003076
Nirav Shah7e3c8132015-06-22 23:51:42 +05303077 fSuccess = TRUE;
3078 // Note the deleted Index, if its 0 we need special handling
3079 del_idx = idx;
3080 empty_slots++;
3081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 }
3083 else
3084 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003085 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 {
3087 valid_idx = idx;
3088 }
Ravi Joshi8a934352013-09-25 16:46:58 -07003089 else
3090 {
3091 // Found an empty slot
3092 empty_slots++;
3093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 }
3095 }
3096
Ravi Joshi8a934352013-09-25 16:46:58 -07003097 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
3098 {
3099 // Last peer departed, set the IBSS state appropriately
3100 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003101 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07003102 "Last IBSS Peer Departed!!!" );
3103 }
3104
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 // Find next active staId, to have a valid sta trigger for TL.
3106 if (fSuccess == TRUE)
3107 {
3108 if (del_idx == 0)
3109 {
3110 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
3111 {
3112 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
3113 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
3114 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
3115
3116 pHddStaCtx->conn_info.staId[valid_idx] = 0;
3117 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
3118 }
3119 }
3120 }
3121 return( fSuccess );
3122}
3123
3124/**============================================================================
3125 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003126 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003128
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 ===========================================================================*/
3130static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
3131{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003132 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05303133 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3134 "%s: IBSS Connect Indication from SME!!! "
3135 "Set HDD connState to eConnectionState_IbssConnected",
3136 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
3138 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
3139
3140 // Save the connection info from CSR...
3141 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
3142
3143 // Send the bssid address to the wext.
3144 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003146 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3147 if (NULL == bss)
3148 {
3149 hddLog(VOS_TRACE_LEVEL_ERROR,
3150 "%s: %s: unable to create IBSS entry",
3151 __func__, pAdapter->dev->name);
3152 return eHAL_STATUS_FAILURE;
3153 }
Yue Maf49ba872013-08-19 12:04:25 -07003154 cfg80211_put_bss(
3155#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3156 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
3157#endif
3158 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07003159
3160 return( eHAL_STATUS_SUCCESS );
3161}
Mukul Sharmad2589a52014-04-23 21:06:25 +05303162
3163/**============================================================================
3164 *
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003166
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003168static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3169 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 eCsrRoamResult roamResult )
3171{
3172 eCsrEncryptionType connectedCipherAlgo;
3173 v_BOOL_t fConnected = FALSE;
3174 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3175 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303176 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303178 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07003180
3181 if (NULL == pRoamInfo)
3182 {
3183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
3184 return eHAL_STATUS_FAILURE;
3185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003187 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 // not require upper layer authentication) we can put TL directly into 'authenticated'
3189 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3191 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
3192 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003193
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3195 if( fConnected )
3196 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003197 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
3198 {
3199 v_U8_t staId;
3200
3201 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
3202
3203 if ( 0 == memcmp( pRoamInfo->peerMac,
3204 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
3205 {
3206 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3207 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05303208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3209 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003210 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3211 }
3212 else
3213 {
3214 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
3215 (v_MACADDR_t*)pRoamInfo->peerMac,
3216 &staId);
3217 if ( VOS_STATUS_SUCCESS == vosStatus )
3218 {
3219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3220 "WLAN TL STA Ptk Installed for STAID=%d", staId);
3221 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3222 staId);
3223 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3224 }
3225 }
3226 }
3227 else
3228 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05303229 WLANTL_GetSTAState(pHddCtx->pvosContext,
3230 pHddStaCtx->conn_info.staId[0],
3231 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303232 // TODO: Considering getting a state machine in HDD later.
3233 // This routine is invoked twice. 1)set PTK 2)set GTK.
3234 // The folloing if statement will be TRUE when setting GTK.
3235 // At this time we don't handle the state in detail.
3236 // Related CR: 174048 - TL not in authenticated state
3237 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
3238 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
3239 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303240
3241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
3242 "for StaId=%d. Changing TL state to AUTHENTICATED from"
3243 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303244
3245 // Connections that do not need Upper layer authentication,
3246 // transition TL to 'Authenticated' state after the keys are set.
3247 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3248 pHddStaCtx->conn_info.staId[ 0 ],
3249 WLANTL_STA_AUTHENTICATED );
3250
3251 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303252
3253 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3254 hdd_postTLPacketPendingInd(pAdapter,
3255 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05303256 //Need to call offload because when roaming happen at that time fwr
3257 //clean offload info as part of the DelBss
3258 // No need to configure offload if host was not suspended
3259 spin_lock(&pHddCtx->filter_lock);
3260 if(pHddCtx->hdd_wlan_suspended)
3261 {
3262 spin_unlock(&pHddCtx->filter_lock);
3263 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
3264 }
3265 else
3266 {
3267 spin_unlock(&pHddCtx->filter_lock);
3268 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303269 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3270 {
3271 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
3272 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303273 }
3274 else
3275 {
3276 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3277 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303278
3279 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
3280 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
3281 {
3282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
3283 " for StaId=%d. Due to OSEN, Changing TL state to"
3284 "AUTHENTICATED from state:%d",
3285 pHddStaCtx->conn_info.staId[0], prevTLState);
3286
3287 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3288 pHddStaCtx->conn_info.staId[ 0 ],
3289 WLANTL_STA_AUTHENTICATED );
3290
3291 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
3292
3293 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3294 hdd_postTLPacketPendingInd(pAdapter,
3295 pHddStaCtx->conn_info.staId[0]);
3296 }
3297
3298
3299
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303300 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3301 {
3302 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
3303 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303304 }
3305
3306 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303309 else
3310 {
3311 // possible disassoc after issuing set key and waiting set key complete
3312 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3313 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003314
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 EXIT();
3316 return( eHAL_STATUS_SUCCESS );
3317}
3318/**============================================================================
3319 *
3320 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
3321 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003322static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07003324{
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3326
3327 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3328 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
3329 {
3330 struct iw_michaelmicfailure msg;
3331 union iwreq_data wreq;
3332 memset(&msg, '\0', sizeof(msg));
3333 msg.src_addr.sa_family = ARPHRD_ETHER;
3334 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08003335 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
3336 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07003337
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3339 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003340 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 msg.flags = IW_MICFAILURE_PAIRWISE;
3342 memset(&wreq, 0, sizeof(wreq));
3343 wreq.data.length = sizeof(msg);
3344 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003346 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3348 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
3349 NL80211_KEYTYPE_GROUP :
3350 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07003351 pRoamInfo->u.pMICFailureInfo->keyId,
3352 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003354
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003356
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 return( eHAL_STATUS_SUCCESS );
3358}
3359
3360/**============================================================================
3361 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003362 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003364
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003366static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3367 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 eCsrRoamResult roamResult )
3369{
3370 VOS_STATUS vosStatus;
3371
3372 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3373 switch( roamResult )
3374 {
3375 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3376 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003377 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303378 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003379
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3381 "IBSS New Peer indication from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003382 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3383 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003385
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3387
Shailender Karmuchia734f332013-04-19 14:02:48 -07003388 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
3389 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
3390 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
3391
3392 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05303393 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 pRoamInfo,
3395 pRoamInfo->staId,
3396 (v_MACADDR_t *)pRoamInfo->peerMac,
3397 pRoamInfo->pBssDesc );
3398 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3399 {
3400 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003401 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 vosStatus, vosStatus );
3403 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05303404 if (!roamSaveIbssStation(pAdapter,
3405 pRoamInfo->staId,
3406 (v_MACADDR_t *)pRoamInfo->peerMac))
3407 {
3408 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
3409 break;
3410 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003411 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303412
3413 staInfo = vos_mem_malloc(sizeof(*staInfo));
3414 if (staInfo == NULL) {
3415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3416 "memory allocation for station_info failed");
3417 return eHAL_STATUS_FAILED_ALLOC;
3418 }
3419
3420 memset(staInfo, 0, sizeof(*staInfo));
3421 staInfo->filled = 0;
3422 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003423
3424 cfg80211_new_sta(pAdapter->dev,
3425 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303426 staInfo, GFP_KERNEL);
3427 vos_mem_free(staInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003428
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003429 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3430 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3431 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3432 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
3433 {
3434 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05303435
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003436 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3437 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
3438
3439 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003440 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003441 pHddStaCtx->ibss_enc_key.encType);
3442
3443 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3444 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3445
3446 if ( VOS_STATUS_SUCCESS != vosStatus )
3447 {
3448 hddLog(VOS_TRACE_LEVEL_ERROR,
3449 "%s: sme_RoamSetKey failed, returned %d",
3450 __func__, vosStatus);
3451 return VOS_STATUS_E_FAILURE;
3452 }
3453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303455 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 netif_tx_start_all_queues(pAdapter->dev);
3457 break;
3458 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003459
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3461 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003462
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003464
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3468 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003469 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003470
Ravi Joshicc57ed42013-10-12 16:31:25 -07003471 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 {
3473 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3474 "IBSS peer departed by cannot find peer in our registration table with TL" );
3475 }
3476
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303477 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3478 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003479 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3480 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
3481 pRoamInfo->staId );
3482
Katya Nigam47528772015-02-11 12:24:49 +05303483 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003484
3485 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003486 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003487
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003488 cfg80211_del_sta(pAdapter->dev,
3489 (const u8 *)&pRoamInfo->peerMac,
3490 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 break;
3492 }
3493 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3494 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
3496 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303498 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 netif_tx_disable(pAdapter->dev);
3500 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05303501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3502 "%s: Set HDD connState to eConnectionState_NotConnected",
3503 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003505
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 // Send the bssid address to the wext.
3507 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
3508 // clean up data path
3509 hdd_disconnect_tx_rx(pAdapter);
3510 break;
3511 }
3512 default:
3513 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003514
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003516
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 return( eHAL_STATUS_SUCCESS );
3518}
3519
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003520#ifdef FEATURE_WLAN_TDLS
3521/**============================================================================
3522 *
3523 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
3524 TL the new STA. This is called as part of ADD_STA in the TDLS setup
3525 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07003526
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003527 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303528VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
3529#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3530 const tANI_U8 *peerMac,
3531#else
3532 tANI_U8 *peerMac,
3533#endif
3534 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003535{
3536 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003537 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003538 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3539 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003540 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
3541 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003542 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3543 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003544
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003545 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3546 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003547 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003548 "%s not connected. ignored", __func__);
3549 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003550 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003551
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003552 /*
3553 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3554 * be peer MAC, here we are wokrking on direct Link
3555 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003556 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003557
3558 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003559
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003560 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003561 sizeof(tSirMacAddr) );
3562
3563 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
3564 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
3565
3566 /* set the QoS field appropriately ..*/
3567 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
3568 : (staDesc.ucQosEnabled = 0) ;
3569
3570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08003571 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003572
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003573 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003574
3575 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003576 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003577
Shailender Karmuchia734f332013-04-19 14:02:48 -07003578 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003579 * UMA is ready we inform TL to do frame translation.
3580 */
3581 staDesc.ucSwFrameTXXlation = 1;
3582 staDesc.ucSwFrameRXXlation = 1;
3583 staDesc.ucAddRmvLLC = 1;
3584
3585 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003586 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003587
3588 /* tdls Direct Link do not need bcastSig */
3589 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003590
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003591 if(staDesc.ucProtectedFrame)
3592 staDesc.ucIsReplayCheckValid = VOS_TRUE;
3593 else
3594 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003595
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303596 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003597
Shailender Karmuchia734f332013-04-19 14:02:48 -07003598 /* Register the Station with TL... */
3599 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
3600 hdd_rx_packet_cbk,
3601 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003602 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003603
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003604 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3605 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003606 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003607 "%s: WLANTL_RegisterSTAClient() failed to register. "
3608 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003609 return vosStatus;
3610 }
3611
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003612 if ( cfg_param->dynSplitscan &&
3613 ( VOS_TIMER_STATE_RUNNING !=
3614 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
3615 {
3616 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
3617 cfg_param->trafficMntrTmrForSplitScan);
3618 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003619 return( vosStatus );
3620}
3621
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303622VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003623{
3624 VOS_STATUS vosStatus;
3625 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
3626 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3627 {
3628 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3629 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003630 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003631 __func__, staId, vosStatus, vosStatus );
3632 }
3633 return( vosStatus );
3634}
3635
3636
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003637/*
3638 * HDD interface between SME and TL to ensure TDLS client registration with
3639 * TL in case of new TDLS client is added and deregistration at the time
3640 * TDLS client is deleted.
3641 */
3642
Shailender Karmuchia734f332013-04-19 14:02:48 -07003643eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
3644 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003645 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07003646 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003647 eCsrRoamResult roamResult)
3648{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003649 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003650 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003651 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003652
Kaushik, Sushant8489f472014-01-27 11:41:22 +05303653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08003654 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
3655 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
3656 "ADD_TDLS_PEER" :
3657 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
3658 "DEL_TDLS_PEER" :
3659 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
3660 "DEL_TDLS_PEER_IND" :
3661 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3662 "DEL_ALL_TDLS_PEER_IND" :
3663 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
3664 "UPDATE_TDLS_PEER" :
3665 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303666 "LINK_ESTABLISH_REQ_RSP" :
3667 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
3668 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08003669 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003670 switch( roamResult )
3671 {
3672 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3673 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003674 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3675 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303676 hddTdlsPeer_t *curr_peer;
3677
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003679 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05303680 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303681
3682 mutex_lock(&pHddCtx->tdls_lock);
3683 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3684 pRoamInfo->peerMac, FALSE);
3685 if (NULL != curr_peer)
3686 curr_peer->link_status = eTDLS_LINK_TEARING;
3687 else
3688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3689 "%s %d curr_peer is Null", __func__,__LINE__);
3690 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003691 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003692 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003693 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003694
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003695 /* check if there is available index for this new TDLS STA */
3696 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3697 {
3698 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3699 {
3700 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3701 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3702
3703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003704 ("TDLS: STA IDX at %d is %d "
3705 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003706 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003707 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003708
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003709 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003710 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3711 status = eHAL_STATUS_SUCCESS ;
3712 break ;
3713 }
3714 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003715 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003716 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003717 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003718 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3719 "wlan_hdd_tdls_set_sta_id() failed");
3720 return VOS_FALSE;
3721 }
3722
3723 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303724 /* store the ucast signature , if required for further reference. */
3725
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003726 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303727 /* start TDLS client registration with TL */
3728 status = hdd_roamRegisterTDLSSTA( pAdapter,
3729 pRoamInfo->peerMac,
3730 pRoamInfo->staId,
3731 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303732 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003733 }
3734 else
3735 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003736 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003738 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003739 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003740 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003741 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003742 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003743 break ;
3744 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003745 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3746 {
3747 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3748 {
3749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3750 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3751 }
3752 /* store the ucast signature which will be used later when
3753 * registering to TL
3754 */
3755 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3756 complete(&pAdapter->tdls_add_station_comp);
3757 break;
3758 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303759 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3760 {
3761 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3762 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303763 hddTdlsPeer_t *curr_peer;
3764
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3766 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303767
3768 mutex_lock(&pHddCtx->tdls_lock);
3769 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3770 pRoamInfo->peerMac, FALSE);
3771 if (curr_peer)
3772 curr_peer->link_status = eTDLS_LINK_TEARING;
3773 else
3774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3775 "%s %d curr_peer is Null",__func__,__LINE__);
3776 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303777 }
3778 complete(&pAdapter->tdls_link_establish_req_comp);
3779 break;
3780 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303781 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3782 {
3783 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3785 "%s: Channel switch request failed. %d", __func__,
3786 pRoamInfo->statusCode);
3787 else
3788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3789 "%s: Channel switch request Success", __func__);
3790 break;
3791 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003792 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003793 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003794 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003795 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003796 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003797 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3798 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003799 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003801 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3802
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303803 mutex_lock(&pHddCtx->tdls_lock);
3804 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3805 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303806 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003807 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3809 " Current status for peer" MAC_ADDRESS_STR "is %d",
3810 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303811 if (TDLS_IS_CONNECTED(curr_peer) ||
3812 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303813 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303814 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303815 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3816 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303817 else
3818 mutex_unlock(&pHddCtx->tdls_lock);
3819
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303820 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003821 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303822 else
3823 mutex_unlock(&pHddCtx->tdls_lock);
3824
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303825 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003826 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303827 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003828
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003829 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3830 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3831 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003832 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003833 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003834 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003835 break ;
3836 }
3837 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003838 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003839 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003840 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003841 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3842 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003843 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003844 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3845 "%s: Sending teardown to supplicant with reason code %u",
3846 __func__, pRoamInfo->reasonCode);
3847
3848#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303849 mutex_lock(&pHddCtx->tdls_lock);
3850 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3851 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003852 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303853 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3854 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303855 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003856#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003857 status = eHAL_STATUS_SUCCESS ;
3858 break ;
3859 }
3860 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3861 {
3862 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003863 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003864 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003865 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3866 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003867 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003869 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003870 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003871 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303872
3873 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003874 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303875 mutex_unlock(&pHddCtx->tdls_lock);
3876
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003877 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3878 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003879
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003880 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003881 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003882 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3883 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003884
3885 status = eHAL_STATUS_SUCCESS ;
3886 }
3887 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303888 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003889 break ;
3890 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003891 default:
3892 {
3893 break ;
3894 }
3895 }
3896
3897 return status ;
3898}
3899#endif
3900
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303901void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003902{
3903 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3904 hdd_context_t *pHddCtx = NULL;
3905 int ret;
3906
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303907 ENTER();
3908
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003909 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3910 {
3911 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003912 "%s: Bad param, pAdapter [%pK]",
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003913 __func__, pAdapter);
3914 return;
3915 }
3916
3917 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3918 ret = wlan_hdd_validate_context(pHddCtx);
3919 if (0 != ret)
3920 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003921 return;
3922 }
3923
3924 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3925 {
3926 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3927 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303928
3929 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003930}
3931
Shailender Karmuchia734f332013-04-19 14:02:48 -07003932eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3934{
3935 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3936 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303937 hdd_wext_state_t *pWextState = NULL;
3938 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003939 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303940 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003941 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003942
3943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003944 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003945 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003946
3947 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303948 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003949 {
3950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303951 "invalid adapter or adapter has invalid magic");
3952 return eHAL_STATUS_FAILURE;
3953 }
3954
3955 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3956 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3957
3958 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3959 {
3960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3961 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003962 return eHAL_STATUS_FAILURE;
3963 }
3964
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303965 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3966 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 switch( roamStatus )
3968 {
3969 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303970 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3971 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003973
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003974#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3975 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003977 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 * interface down */
3979 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303980 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3981 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303982 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3984 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3985 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3987 }
3988 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303989 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 break;
3991
3992 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003993 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003995 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 // eCSR_ROAM_SHOULD_ROAM will be received.
3997 // Where in we will not mark the link down
3998 // Also we want to stop tx at this point when we will be
3999 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004000 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 {
4002 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304003 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05304005 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4006 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
4007 {
4008 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
4009 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004010 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304011 * Deregister this STA with TL, but do not flush the packets
4012 * for this STA from wmm_tx_queue. Since there is no valid STA
4013 * for these packets they will not be transmitted. Eventually
4014 * after the reassociation is successful, these packets will be
4015 * transmitted after registering STA with TL again. This ensures
4016 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004017 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304018 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
4019 pHddStaCtx->conn_info.staId[0]);
4020 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004021 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4023 FL("WLANTL_ClearSTAClient failed for staID %d."
4024 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
4025 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004026 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
4029 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004030 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 break;
4032#endif
4033
4034 case eCSR_ROAM_SHOULD_ROAM:
4035 // Dont need to do anything
4036 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 struct net_device *dev = pAdapter->dev;
4038 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4039 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304040 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004042#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 if (pHddStaCtx->ft_carrier_on == FALSE)
4044 {
4045#endif
4046 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004047#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 }
4049#endif
4050
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004051#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 //We should clear all sta register with TL, for now, only one.
4053 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
4054 if ( !VOS_IS_STATUS_SUCCESS(status ) )
4055 {
4056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4057 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
4058 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004059 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004061#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 }
4063 break;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05304064 case eCSR_ROAM_LOSTLINK_DETECTED:
4065 {
4066 if (wlan_hdd_check_and_stop_mon(pAdapter, false))
4067 halStatus = eHAL_STATUS_FAILURE;
4068 }
4069 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 case eCSR_ROAM_LOSTLINK:
4071 case eCSR_ROAM_DISASSOCIATED:
4072 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4074 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05304075 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4077 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07004078 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4079 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304080 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07004081 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08004082
4083 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
4084 pHddCtx->configuredMcastBcastFilter =
4085 pHddCtx->sus_res_mcastbcast_filter;
4086 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
4087 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304088
Amar Singhald53568e2013-09-26 11:03:45 -07004089 hddLog(VOS_TRACE_LEVEL_INFO,
4090 "offload: disassociation happening, restoring configuredMcastBcastFilter");
4091 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
4092 pHddCtx->configuredMcastBcastFilter);
4093 hddLog(VOS_TRACE_LEVEL_INFO,
4094 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4096 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004097#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304098 /* Call to clear any MC Addr List filter applied after
4099 * successful connection.
4100 */
4101 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004102#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 }
4104 break;
4105 case eCSR_ROAM_IBSS_LEAVE:
4106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4107 "****eCSR_ROAM_IBSS_LEAVE****");
4108 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4109 break;
4110 case eCSR_ROAM_ASSOCIATION_COMPLETION:
4111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4112 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304113 // To Do - address probable memory leak with WEP encryption upon successful association
4114 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304116 //Clear saved connection information in HDD
4117 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304119 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004120
4121 break;
4122 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004123 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 pRoamInfo, roamId, roamStatus, roamResult );
4125 break;
4126 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07004127 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
4128 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 break;
4130
4131 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
4132 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004134
4135 case eCSR_ROAM_MIC_ERROR_IND:
4136 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4137 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05304138 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
4139 {
4140 /*
4141 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
4142 * adding the 100 value.
4143 */
4144 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
4145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4146 "%s : Rssi on Disconnect : %d",
4147 __func__, pAdapter->rssi_on_disconnect);
4148 break;
4149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004151 {
4152 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4153
4154 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004155 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304156 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304157 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004158 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004159 /* Send DTIM period to the FW; only if the wlan is already
4160 in suspend. This is the case with roaming (reassoc),
4161 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
4162 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
4163 before the ENTER_BMPS_REQ ensures Listen Interval is
4164 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004165 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004166
4167 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004168 if due to unexpected scenario, if we are in BMPS,
4169 then trigger Exit and Enter BMPS to take DTIM period
4170 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004171 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
4172 {
4173 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
4174
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004175 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4176 iw_full_power_cbfn, pAdapter,
4177 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004178 }
4179 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304180
4181 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304182 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
4183 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304184 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304185 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304186 {
4187 hddLog( LOG1, FL("Device in full power."
4188 "Stop and start traffic timer for roaming"));
4189 pmcStopTrafficTimer(pHddCtx->hHal);
4190 if (pmcStartTrafficTimer(pHddCtx->hHal,
4191 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
4192 {
4193 hddLog(LOGP, FL("Cannot start traffic timer"));
4194 }
4195 }
4196
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004197 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304198 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304199 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304200 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 break;
4203#ifdef WLAN_FEATURE_VOWIFI_11R
4204 case eCSR_ROAM_FT_RESPONSE:
4205 hdd_SendFTEvent(pAdapter);
4206 break;
4207#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004208#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004209 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004210 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07004211 {
4212 /* Notify the supplicant of a new candidate */
4213 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
4214 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004215 break;
4216#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004217
Yue Maef608272013-04-08 23:09:17 -07004218#ifdef FEATURE_WLAN_LFR_METRICS
4219 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4220 /* This event is to notify pre-auth initiation */
4221 if (VOS_STATUS_SUCCESS !=
4222 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
4223 {
4224 halStatus = eHAL_STATUS_FAILURE;
4225 }
4226 break;
4227 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4228 /* This event will notify pre-auth completion in case of success */
4229 if (VOS_STATUS_SUCCESS !=
4230 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4231 pRoamInfo, 1))
4232 {
4233 halStatus = eHAL_STATUS_FAILURE;
4234 }
4235 break;
4236 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4237 /* This event will notify pre-auth completion in case of failure. */
4238 if (VOS_STATUS_SUCCESS !=
4239 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4240 pRoamInfo, 0))
4241 {
4242 halStatus = eHAL_STATUS_FAILURE;
4243 }
4244 break;
4245 case eCSR_ROAM_HANDOVER_SUCCESS:
4246 /* This event is to notify handover success.
4247 It will be only invoked on success */
4248 if (VOS_STATUS_SUCCESS !=
4249 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
4250 {
4251 halStatus = eHAL_STATUS_FAILURE;
4252 }
4253 break;
4254#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 case eCSR_ROAM_REMAIN_CHAN_READY:
4256 hdd_remainChanReadyHandler( pAdapter );
4257 break;
4258 case eCSR_ROAM_SEND_ACTION_CNF:
4259 hdd_sendActionCnf( pAdapter,
4260 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
4261 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004262#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08004263 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004264 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08004265 roamId, roamStatus, roamResult );
4266 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004267 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4268 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
4269 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004270#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004271#ifdef WLAN_FEATURE_11W
4272 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4273 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
4274 pRoamInfo->pbFrames,
4275 pRoamInfo->frameType);
4276 break;
4277#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004278#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004279 case eCSR_ROAM_TSM_IE_IND:
4280 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
4281 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
4282 break;
4283
4284 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4285 {
4286 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
4287 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
4288 {
4289 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
4290 }
4291 break;
4292 }
4293
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004294 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004295 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004296 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004297 break;
4298 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004299
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004300 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004301 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004302 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004303 break;
4304 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004305#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05304306 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
4307 {
4308 pAdapter->maxRateFlags = roamResult;
4309 break;
4310 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304311 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4312 if (pRoamInfo && pRoamInfo->pBssDesc) {
4313 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4314 pRoamInfo->pBssDesc);
4315 if (bss_status)
4316 cfg80211_put_bss(
4317#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4318 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4319#endif
4320 bss_status);
4321 else
4322 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
4323 }
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304324 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4325 {
4326 hdd_adapter_t *pHostapdAdapter = NULL;
4327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4328 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4329
4330 if (!pHddCtx || !pHddStaCtx) {
4331 hddLog(LOG1, FL("Invalid pHddCtx or pHddStaCtx"));
4332 break;
4333 }
4334
4335 hddLog(LOG1, FL("eCSR_ROAM_STA_CHANNEL_SWITCH: new channel %hu"),
4336 pRoamInfo->chan_info.chan_id);
4337
4338 pHddStaCtx->conn_info.operationChannel =
4339 pRoamInfo->chan_info.chan_id;
4340
4341 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
4342 if (pHostapdAdapter &&
4343 (test_bit(SOFTAP_BSS_STARTED,
4344 &pHostapdAdapter->event_flags)))
4345 {
4346 /* Restart SAP if its operating channel is different
4347 * from AP channel.
4348 */
4349 hddLog(VOS_TRACE_LEVEL_INFO,"SAP chan %d, STA chan %d, force_scc_with_ecsa %d",
4350 pHostapdAdapter->sessionCtx.ap.operatingChannel,
4351 pRoamInfo->chan_info.chan_id,
4352 pHddCtx->cfg_ini->force_scc_with_ecsa);
4353 if ((pHddCtx->cfg_ini->force_scc_with_ecsa ) &&
4354 (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
4355 pRoamInfo->chan_info.chan_id))
4356 {
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05304357 schedule_delayed_work(&pHddCtx->ecsa_chan_change_work, 0);
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304358 }
4359 else
4360 hddLog(LOG1, FL("SAP restart not required"));
4361 } else
4362 hddLog(LOG1, FL("SAP not active, nothing to do"));
4363 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304364 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05304365 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 break;
4367 }
4368 return( halStatus );
4369}
Shailender Karmuchia734f332013-04-19 14:02:48 -07004370eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004371{
4372 eCsrAuthType auth_type;
4373 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004374 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 {
4376 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004377 } else
4378 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 {
4380 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004381 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004382#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004383 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 {
4385 // Check for 11r FT Authentication with PSK
4386 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004387 } else
4388 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 {
4390 // Check for 11R FT Authentication with 802.1X
4391 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004392 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004393#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004394#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004395 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 {
4397 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4398 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004399#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07004400#ifdef WLAN_FEATURE_11W
4401 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
4402 {
4403 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4404 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304405 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
4406 {
4407 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4408 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004409#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004410 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4412 }
4413 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004414}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004415
Shailender Karmuchia734f332013-04-19 14:02:48 -07004416eCsrAuthType
4417hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004418{
4419 eCsrAuthType auth_type;
4420 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004421 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 {
4423 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004424 } else
4425 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 {
4427 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004428 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004429#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004430 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 {
4432 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004433 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004434#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004435 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4437 }
4438 hddLog(LOG1, FL("auth_type: %d"), auth_type);
4439 return auth_type;
4440}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004441
Shailender Karmuchia734f332013-04-19 14:02:48 -07004442eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004443hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004444{
4445 eCsrEncryptionType cipher_type;
4446 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004447 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 {
4449 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004450 }
4451 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 {
4453 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004454 }
4455 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 {
4457 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004458 }
4459 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 {
4461 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004462 }
4463 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
4464 {
4465 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4466 }
4467 else
4468 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4470 }
4471 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4472 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004473}
Jeff Johnson295189b2012-06-20 16:38:30 -07004474/* To find if the MAC address is NULL */
4475static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
4476{
4477 int i;
4478 for (i = 0; i < length; i++)
4479 {
4480 if (0x00 != (macAddr[i]))
4481 {
4482 return FALSE;
4483 }
4484 }
4485 return TRUE;
4486} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08004487
Shailender Karmuchia734f332013-04-19 14:02:48 -07004488eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004489hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004490{
4491 eCsrEncryptionType cipher_type;
4492 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004493 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 {
4495 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004496 } else
4497 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 {
4499 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004500 } else
4501 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 {
4503 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004504 } else
4505 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 {
4507 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004508 } else
4509 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004511 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4512 } else
4513 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4515 }
4516 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4517 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004518}
Jeff Johnson295189b2012-06-20 16:38:30 -07004519
Shailender Karmuchia734f332013-04-19 14:02:48 -07004520static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
4521 struct ether_addr *pBssid,
4522 eCsrEncryptionType *pEncryptType,
4523 eCsrEncryptionType *mcEncryptType,
4524 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004525#ifdef WLAN_FEATURE_11W
4526 u_int8_t *pMfpRequired,
4527 u_int8_t *pMfpCapable,
4528#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004529 u_int16_t gen_ie_len,
4530 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07004531{
4532 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004533 eHalStatus result;
4534 tDot11fIERSN dot11RSNIE;
4535 tDot11fIEWPA dot11WPAIE;
4536 tANI_U32 i;
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304537 tANI_U32 status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004538 tANI_U8 *pRsnIe;
4539 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07004541 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004542
4543 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
4544 flag to 0 */
4545 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
4546 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
4547
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07004549 if ( gen_ie[0] == DOT11F_EID_RSN)
4550 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07004552 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
4554 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304555 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
4556 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 return -EINVAL;
4558 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004559 // Skip past the EID byte and length byte
4560 pRsnIe = gen_ie + 2;
4561 RSNIeLen = gen_ie_len - 2;
4562 // Unpack the RSN IE
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304563 status = dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
Shailender Karmuchia734f332013-04-19 14:02:48 -07004564 pRsnIe,
4565 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 &dot11RSNIE);
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304567 if (DOT11F_FAILED(status))
4568 {
4569 hddLog(LOGE,
4570 FL("Parse failure in hdd_ProcessGENIE (0x%08x)"),
4571 status);
4572 return -EINVAL;
4573 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004574 // Copy out the encryption and authentication types
4575 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004576 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004577 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004578 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004579 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 but probably I suspect we can do something different*/
4581 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07004582 // Just translate the FIRST one
4583 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
4584 //dot11RSNIE.pwise_cipher_suite_count
4585 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
4586 //dot11RSNIE.gp_cipher_suite_count
4587 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07004588#ifdef WLAN_FEATURE_11W
4589 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
4590 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
4591#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07004593 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004595 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304597 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 break;
4599 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004600 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304602 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 break;
4604 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004605 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 // For right now, I assume setASSOCIATE() has passed in the bssid.
4607 vos_mem_copy(PMKIDCache[i].BSSID,
4608 pBssid, ETHER_ADDR_LEN);
4609 vos_mem_copy(PMKIDCache[i].PMKID,
4610 dot11RSNIE.pmkid[i],
4611 CSR_RSN_PMKID_SIZE);
4612 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004613
4614 if (updatePMKCache)
4615 {
4616 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004617 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004618 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07004619 // Finally set the PMKSA ID Cache in CSR
4620 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
4621 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304622 dot11RSNIE.pmkid_count,
4623 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07004624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 }
4626 else if (gen_ie[0] == DOT11F_EID_WPA)
4627 {
4628 // Validity checks
4629 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
4630 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
4631 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304632 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
4633 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 return -EINVAL;
4635 }
4636 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07004637 pRsnIe = gen_ie + 2 + 4;
4638 RSNIeLen = gen_ie_len - (2 + 4);
4639 // Unpack the WPA IE
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304640 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304641 pRsnIe, RSNIeLen, &dot11WPAIE);
4642 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304643 {
4644 hddLog(LOGE,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304645 FL("Invalid RSN IE: parse status %d"), status);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304646 return -EINVAL;
4647 }
4648
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 // Copy out the encryption and authentication types
4650 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004651 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004653 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 //dot11WPAIE.auth_suite_count
4655 // Just translate the FIRST one
4656 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
4657 //dot11WPAIE.unicast_cipher_count
4658 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
4659 //dot11WPAIE.unicast_cipher_count
4660 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
4661 }
4662 else
4663 {
4664 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004665 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 }
4667 return 0;
4668}
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304669
4670/**
4671 * hdd_set_def_rsne_override() - set default encryption type and auth type
4672 * in profile.
4673 * @roam_profile: pointer to adapter
4674 * @auth_type: pointer to auth type
4675 *
4676 * Set default value of encryption type and auth type in profile to
4677 * search the AP using filter, as in force_rsne_override the RSNIE can be
4678 * currupt and we might not get the proper encryption type and auth type
4679 * while parsing the RSNIE.
4680 *
4681 * Return: void
4682 */
4683static void hdd_set_def_rsne_override(
4684 tCsrRoamProfile *roam_profile, eCsrAuthType *auth_type)
4685{
4686 hddLog( LOG1, FL("Set def values in roam profile"));
4687 roam_profile->MFPCapable = roam_profile->MFPEnabled;
4688 roam_profile->EncryptionType.numEntries = 2;
4689 roam_profile->mcEncryptionType.numEntries = 2;
4690 /* Use the cipher type in the RSN IE */
4691 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
4692 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
4693 roam_profile->mcEncryptionType.encryptionType[0] =
4694 eCSR_ENCRYPT_TYPE_AES;
4695 roam_profile->mcEncryptionType.encryptionType[1] =
4696 eCSR_ENCRYPT_TYPE_TKIP;
4697 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
4698}
4699
Jeff Johnson295189b2012-06-20 16:38:30 -07004700int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
4701{
4702 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4703 v_U32_t status = 0;
4704 eCsrEncryptionType RSNEncryptType;
4705 eCsrEncryptionType mcRSNEncryptType;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304706 hdd_context_t *hdd_ctx;
Chet Lanctot186b5732013-03-18 10:26:30 -07004707#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304708 u_int8_t RSNMfpRequired = 0;
4709 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07004710#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 struct ether_addr bSsid; // MAC address of assoc peer
4712 // MAC address of assoc peer
4713 // But, this routine is only called when we are NOT associated.
4714 vos_mem_copy(bSsid.ether_addr_octet,
4715 pWextState->roamProfile.BSSIDs.bssid,
4716 sizeof(bSsid.ether_addr_octet));
4717 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
4718 {
4719 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07004720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 else
4722 {
4723 return 0;
4724 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304725
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 // The actual processing may eventually be more extensive than this.
4727 // Right now, just consume any PMKIDs that are sent in by the app.
4728 status = hdd_ProcessGENIE(pAdapter,
4729 &bSsid, // MAC address of assoc peer
4730 &RSNEncryptType,
4731 &mcRSNEncryptType,
4732 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004733#ifdef WLAN_FEATURE_11W
4734 &RSNMfpRequired,
4735 &RSNMfpCapable,
4736#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 pWextState->WPARSNIE[1]+2,
4738 pWextState->WPARSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304739
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 if (status == 0)
4741 {
4742 // Now copy over all the security attributes you have parsed out
4743 pWextState->roamProfile.EncryptionType.numEntries = 1;
4744 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004745
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
4747 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07004748
Shailender Karmuchi642e9812013-05-30 14:34:49 -07004749 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
4750 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
4751 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
4752 {
4753 /*For wpa none supplicant sends the WPA IE with unicast cipher as
4754 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
4755 either AES/TKIP based on group cipher configuration
4756 mentioned in the wpa_supplicant.conf.*/
4757
4758 /*Set the unicast cipher same as multicast cipher*/
4759 pWextState->roamProfile.EncryptionType.encryptionType[0]
4760 = mcRSNEncryptType;
4761 }
4762
Chet Lanctot186b5732013-03-18 10:26:30 -07004763#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304764 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
4765 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07004766 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
4767 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
4768#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304769 hddLog( LOG1,
4770 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
4771 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304773
4774 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4775 if (hdd_ctx->force_rsne_override &&
4776 (pWextState->WPARSNIE[0] == DOT11F_EID_RSN)) {
4777 hddLog(LOG1,
4778 FL("Test mode enabled set def Auth and enc type. RSN IE passed in connect req:"));
4779 vos_trace_hex_dump(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4780 pWextState->roamProfile.pRSNReqIE,
4781 pWextState->roamProfile.nRSNReqIELength);
4782
4783 pWextState->roamProfile.force_rsne_override = true;
4784 hddLog(LOG1,
4785 FL("MFPEnabled %d"), pWextState->roamProfile.MFPEnabled);
4786 /*
4787 * Reset MFPEnabled if testmode RSNE passed doesnt have MFPR
4788 * or MFPC bit set
4789 */
4790 if (pWextState->roamProfile.MFPEnabled &&
4791 !(pWextState->roamProfile.MFPRequired ||
4792 pWextState->roamProfile.MFPCapable)) {
4793 hddLog( LOG1,FL("Reset MFPEnabled"));
4794 pWextState->roamProfile.MFPEnabled = 0;
4795 }
4796
4797 /* If parsing failed set the def value for the roam profile */
4798 if (status)
4799 hdd_set_def_rsne_override(&pWextState->roamProfile,
4800 RSNAuthType);
4801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 return 0;
4803}
4804int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
4805{
4806 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4807 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
4808 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4809 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004810
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004812 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004813
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 switch( pHddStaCtx->conn_info.authType)
4815 {
4816 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004817#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 case eCSR_AUTH_TYPE_CCKM_WPA:
4819 case eCSR_AUTH_TYPE_CCKM_RSN:
4820#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004821 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4822
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004824 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004826
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004827#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004828 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4829 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4830 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004831 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004832 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4833 } else
4834 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004835 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004836 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 } else
4838#endif
4839 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4840 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004841 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4842 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4844 == IW_AUTH_KEY_MGMT_PSK) {
4845 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004846 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 }
4850 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004851#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004852 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4853 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4854 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004855 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004856 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004858 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004859 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004860 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 } else
4862#endif
4863
4864#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004865 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4866 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004868 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004869 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004870 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4872 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004873 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 } else
4875#endif
4876
Chet Lanctot186b5732013-03-18 10:26:30 -07004877#ifdef WLAN_FEATURE_11W
4878 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4879 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4880 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304881 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4882 pRoamProfile->AuthType.authType[0] =
4883 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4884 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004885#endif
4886
Shailender Karmuchia734f332013-04-19 14:02:48 -07004887 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004889 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4890 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4892 == IW_AUTH_KEY_MGMT_PSK) {
4893 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004894 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004898 break;
4899
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004901
4902 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 break;
4904 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004905
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004906#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004907 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004908#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4910 break;
4911 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004912
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004914 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004915
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 EXIT();
4917 return 0;
4918}
4919
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05304920/**
4921 * hdd_rx_fwd_eapol() - forward cached eapol frames
4922 * @vosContext : pointer to vos global context
4923 * @pVosPacket: pointer to vos packet
4924 *
4925 * Return: None
4926 *
4927 */
4928void hdd_assoc_registerFwdEapolCB(void *pContext)
4929{
4930 WLANTL_RegisterFwdEapol(pContext, hdd_rx_fwd_eapol);
4931}
4932
Jeff Johnson295189b2012-06-20 16:38:30 -07004933/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004934
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304935 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004937 to the CSR roam profile.
4938
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 \param - dev - Pointer to the net device.
4940 - info - Pointer to the iw_request_info.
4941 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004942 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004944
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 --------------------------------------------------------------------------*/
4946
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304947int __iw_set_essid(struct net_device *dev,
4948 struct iw_request_info *info,
4949 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004950{
4951 v_U32_t status = 0;
4952 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304953 hdd_adapter_t *pAdapter;
4954 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 v_U32_t roamId;
4956 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304958 tHalHandle hHal;
4959 hdd_station_ctx_t *pHddStaCtx;
4960 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004961
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304963 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4964 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304967 "%s: Adapter is NULL",__func__);
4968 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 }
4970
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304971 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4972 ret = wlan_hdd_validate_context(pHddCtx);
4973 if (0 != ret)
4974 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304975 return ret;
4976 }
4977
4978 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4979 if (NULL == hHal)
4980 {
4981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4982 "%s: Hal Context is NULL",__func__);
4983 return -EINVAL;
4984 }
4985 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4986 if (NULL == pHddStaCtx)
4987 {
4988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4989 "%s: STA Context is NULL",__func__);
4990 return -EINVAL;
4991 }
4992 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4993 if (NULL == pWextState)
4994 {
4995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4996 "%s: pWextState is NULL",__func__);
4997 return -EINVAL;
4998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
5000 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
5001 return -EBUSY;
5002 }
5003 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
5004 return -EINVAL;
5005 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005006
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305007 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
5008 return -EINVAL;
5009
Agrawal Ashishc407f192017-01-23 17:18:35 +05305010 /*Try disconnecting if already in connected state*/
5011 status = wlan_hdd_try_disconnect(pAdapter);
5012 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 {
Agrawal Ashishc407f192017-01-23 17:18:35 +05305014 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
5015 " connection"));
5016 return -EALREADY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 }
5018 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07005019 /** when cfg80211 defined, wpa_supplicant wext driver uses
5020 zero-length, null-string ssid for force disconnection.
5021 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 driver MUST return success */
5023 if ( 0 == wrqu->essid.length ) {
5024 return 0;
5025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005026
5027 status = hdd_wmm_get_uapsd_mask(pAdapter,
5028 &pWextState->roamProfile.uapsd_mask);
5029 if (VOS_STATUS_SUCCESS != status)
5030 {
5031 pWextState->roamProfile.uapsd_mask = 0;
5032 }
5033 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005034
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005036
5037 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
5039 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
5040 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005041
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 //set gen ie
5043 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5044
5045 //set auth
5046 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5047 }
5048#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005049 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 if (pAdapter->wapi_info.nWapiMode)
5051 {
5052 switch (pAdapter->wapi_info.wapiAuthMode)
5053 {
5054 case WAPI_AUTH_MODE_PSK:
5055 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005056 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 pRoamProfile->AuthType.numEntries = 1;
5058 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5059 break;
5060 }
5061 case WAPI_AUTH_MODE_CERT:
5062 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005063 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 pRoamProfile->AuthType.numEntries = 1;
5065 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5066 break;
5067 }
5068 } // End of switch
5069 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5070 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5071 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005072 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 pRoamProfile->EncryptionType.numEntries = 1;
5074 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5075 pRoamProfile->mcEncryptionType.numEntries = 1;
5076 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5077 }
5078 }
5079#endif /* FEATURE_WLAN_WAPI */
5080 /* if previous genIE is not NULL, update AssocIE */
5081 if (0 != pWextState->genIE.length)
5082 {
5083 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
5084 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
5085 pWextState->genIE.length);
5086 pWextState->assocAddIE.length = pWextState->genIE.length;
5087 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5088 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5089
5090 /* clear previous genIE after use it */
5091 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
5092 }
5093
5094 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
5095 pWextState->roamProfile.bWPSAssociation = FALSE;
5096
5097 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5098 pWextState->roamProfile.nAddIEAssocLength))
5099 pWextState->roamProfile.bWPSAssociation = TRUE;
5100
5101
5102 // Disable auto BMPS entry by PMC until DHCP is done
5103 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
5104
Shailender Karmuchia734f332013-04-19 14:02:48 -07005105 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005107
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005108 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
5109 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005110 hdd_select_cbmode(pAdapter,
5111 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
5112 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305113 /*
5114 * Change conn_state to connecting before sme_RoamConnect(),
5115 * because sme_RoamConnect() has a direct path to call
5116 * hdd_smeRoamCallback(), which will change the conn_state
5117 * If direct path, conn_state will be accordingly changed
5118 * to NotConnected or Associated by either
5119 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
5120 * in sme_RoamCallback()
5121 * if sme_RomConnect is to be queued,
5122 * Connecting state will remain until it is completed.
5123 *
5124 * If connection state is not changed,
5125 * connection state will remain in eConnectionState_NotConnected state.
5126 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
5127 * if conn state is eConnectionState_NotConnected.
5128 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5129 * informed of connect result indication which is an issue.
5130 */
5131 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5132 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
5133 {
5134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5135 FL("Set HDD connState to eConnectionState_Connecting"));
5136 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5137 eConnectionState_Connecting);
5138 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005139 status = sme_RoamConnect( hHal,pAdapter->sessionId,
5140 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305141
5142 if ((eHAL_STATUS_SUCCESS != status) &&
5143 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5144 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5145 {
5146 hddLog(VOS_TRACE_LEVEL_ERROR,
5147 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
5148 pAdapter->sessionId, status);
5149 /* change back to NotAssociated */
5150 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5151 eConnectionState_NotConnected);
5152 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005153 pRoamProfile->ChannelInfo.ChannelList = NULL;
5154 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005155
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005156 EXIT();
5157 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005158}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005159
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305160int iw_set_essid(struct net_device *dev,
5161 struct iw_request_info *info,
5162 union iwreq_data *wrqu, char *extra)
5163{
5164 int ret;
5165
5166 vos_ssr_protect(__func__);
5167 ret = __iw_set_essid(dev, info, wrqu, extra);
5168 vos_ssr_unprotect(__func__);
5169
5170 return ret;
5171}
5172
Jeff Johnson295189b2012-06-20 16:38:30 -07005173/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005174
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305175 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005177
Jeff Johnson295189b2012-06-20 16:38:30 -07005178 \param - dev - Pointer to the net device.
5179 - info - Pointer to the iw_request_info.
5180 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005181 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005183
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305185int __iw_get_essid(struct net_device *dev,
5186 struct iw_request_info *info,
5187 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005188{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305189 hdd_adapter_t *pAdapter;
5190 hdd_context_t *pHddCtx;
5191 hdd_wext_state_t *wextBuf;
5192 hdd_station_ctx_t *pHddStaCtx;
5193 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305194
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 ENTER();
5196
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305197 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5198 if (NULL == pAdapter)
5199 {
5200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5201 "%s: Adapter is NULL",__func__);
5202 return -EINVAL;
5203 }
5204
5205 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5206 ret = wlan_hdd_validate_context(pHddCtx);
5207 if (0 != ret)
5208 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305209 return ret;
5210 }
5211
5212 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5213 if (NULL == pHddStaCtx)
5214 {
5215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5216 "%s: STA Context is NULL",__func__);
5217 return -EINVAL;
5218 }
5219
5220 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5221 if (NULL == wextBuf)
5222 {
5223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5224 "%s: wextBuf is NULL",__func__);
5225 return -EINVAL;
5226 }
5227
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5229 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5230 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
5231 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
5232 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
5233 {
5234 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5235 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
5236 dwrq->flags = 1;
5237 } else {
5238 memset(extra, 0, dwrq->length);
5239 dwrq->length = 0;
5240 dwrq->flags = 0;
5241 }
5242 EXIT();
5243 return 0;
5244}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305245
5246int iw_get_essid(struct net_device *dev,
5247 struct iw_request_info *info,
5248 struct iw_point *dwrq, char *extra)
5249{
5250 int ret;
5251
5252 vos_ssr_protect(__func__);
5253 ret = __iw_get_essid(dev, info, dwrq, extra);
5254 vos_ssr_unprotect(__func__);
5255
5256 return ret;
5257}
Jeff Johnson295189b2012-06-20 16:38:30 -07005258/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005259
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305260 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005262
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 \param - dev - Pointer to the net device.
5264 - info - Pointer to the iw_request_info.
5265 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005266 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005268
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305270int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
5271 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005272{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305273 hdd_adapter_t *pAdapter;
5274 hdd_context_t *pHddCtx;
5275 hdd_wext_state_t *pWextState;
5276 hdd_station_ctx_t *pHddStaCtx;
5277 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005278 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305280 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005281
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005283
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305284 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5285 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005286 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5288 "%s: Adapter is NULL",__func__);
5289 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005290 }
5291
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305292 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5293 ret = wlan_hdd_validate_context(pHddCtx);
5294 if (0 != ret)
5295 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305296 return ret;
5297 }
5298
5299 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5300 if (NULL == pHddStaCtx)
5301 {
5302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5303 "%s: STA Context is NULL",__func__);
5304 return -EINVAL;
5305 }
5306
5307 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5308 if (NULL == pWextState)
5309 {
5310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5311 "%s: pWextState is NULL",__func__);
5312 return -EINVAL;
5313 }
5314
5315 pRoamProfile = &pWextState->roamProfile;
5316
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 switch(wrqu->param.flags & IW_AUTH_INDEX)
5318 {
5319 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005320
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005322
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005324
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 case IW_AUTH_CIPHER_PAIRWISE:
5326 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005327 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005329 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5331 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5334 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005335 }
5336
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005338
5339 if( (IW_AUTH_KEY_MGMT_802_1X
5340 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
5342 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005343 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 else
5345 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005346 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005349
5350 if( ( IW_AUTH_KEY_MGMT_802_1X
5351 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005352 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5353 /*Dynamic WEP key*/
5354 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5355 else
5356 /*Static WEP key*/
5357 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005358
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 }
5360 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005361
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005363 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 return -EINVAL;
5365 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005366
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 pRoamProfile->EncryptionType.numEntries = 1;
5368 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 break;
5371 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005372 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5374 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5375 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005376
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5378 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5379 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005380
5381 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5383 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005384
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005386
5387 if( ( IW_AUTH_KEY_MGMT_802_1X
5388 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5389 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5390
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005392
5393 else
5394 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005396
5397 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
5398 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005400 if( ( IW_AUTH_KEY_MGMT_802_1X
5401 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5403 {
5404 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5405 }
5406 else
5407 {
5408 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5409 }
5410 }
5411 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005412
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005414 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 return -EINVAL;
5416 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005417
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 pRoamProfile->mcEncryptionType.numEntries = 1;
5419 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
5420 }
5421 break;
5422
5423 case IW_AUTH_80211_AUTH_ALG:
5424 {
5425 /*Save the auth algo here and set auth type to SME Roam profile
5426 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005427 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005429
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5431 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5432
5433 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
5434 /*Not supported*/
5435 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5436 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5437 }
5438 break;
5439
5440 case IW_AUTH_KEY_MGMT:
5441 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005442#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005443#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5444 /*Check for CCKM AKM type */
5445 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005446 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
5447 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005448 /* Set the CCKM bit in authKeyMgmt */
5449 /* Right now, this breaks all ref to authKeyMgmt because our
5450 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 */
5452 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5453 /*Set the key management to 802.1X*/
5454 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005455 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5457 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
5458 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5459 /*Save the key management*/
5460 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5461 //pWextState->authKeyMgmt = wrqu->param.value;
5462 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5463 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5464 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5465 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
5466 /*Save the key management anyway*/
5467 pWextState->authKeyMgmt = wrqu->param.value;
5468 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
5469 /*Save the key management*/
5470 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5471 //pWextState->authKeyMgmt = wrqu->param.value;
5472 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5473 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5474 }
5475#else
5476 /*Save the key management*/
5477 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005478#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 }
5480 break;
5481
5482 case IW_AUTH_TKIP_COUNTERMEASURES:
5483 {
5484 if(wrqu->param.value) {
5485 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5486 "Counter Measure started %d", wrqu->param.value);
5487 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
5488 }
5489 else {
5490 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5491 "Counter Measure stopped=%d", wrqu->param.value);
5492 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
5493 }
5494 }
5495 break;
5496 case IW_AUTH_DROP_UNENCRYPTED:
5497 case IW_AUTH_WPA_ENABLED:
5498 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5499 case IW_AUTH_ROAMING_CONTROL:
5500 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005501
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005503
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005504 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 wrqu->param.flags & IW_AUTH_INDEX);
5506 break;
5507 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005508
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 EXIT();
5510 return 0;
5511}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305512
5513int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5514 union iwreq_data *wrqu, char *extra)
5515{
5516 int ret;
5517
5518 vos_ssr_protect(__func__);
5519 ret = __iw_set_auth(dev, info, wrqu, extra);
5520 vos_ssr_unprotect(__func__);
5521
5522 return ret;
5523}
5524
Jeff Johnson295189b2012-06-20 16:38:30 -07005525/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005526
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305527 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005529
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 \param - dev - Pointer to the net device.
5531 - info - Pointer to the iw_request_info.
5532 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005533 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005535
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305537int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5538 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005539{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305540 hdd_adapter_t* pAdapter;
5541 hdd_wext_state_t *pWextState;
5542 tCsrRoamProfile *pRoamProfile;
5543 hdd_context_t *pHddCtx;
5544 int ret = 0;
5545
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005547
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305548 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5549 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005550 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5552 "%s: Adapter is NULL",__func__);
5553 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005554 }
5555
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305556 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5557 ret = wlan_hdd_validate_context(pHddCtx);
5558 if (0 != ret)
5559 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305560 return ret;
5561 }
5562
5563 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5564 if (NULL == pWextState)
5565 {
5566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5567 "%s: pWextState is NULL",__func__);
5568 return -EINVAL;
5569 }
5570 pRoamProfile = &pWextState->roamProfile;
5571
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 switch(pRoamProfile->negotiatedAuthType)
5573 {
5574 case eCSR_AUTH_TYPE_WPA_NONE:
5575 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5576 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
5577 break;
5578 case eCSR_AUTH_TYPE_WPA:
5579 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5580 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
5581 break;
5582#ifdef WLAN_FEATURE_VOWIFI_11R
5583 case eCSR_AUTH_TYPE_FT_RSN:
5584#endif
5585 case eCSR_AUTH_TYPE_RSN:
5586 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5587 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
5588 break;
5589 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5590 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5591 break;
5592 case eCSR_AUTH_TYPE_SHARED_KEY:
5593 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
5594 break;
5595 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005596 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5598 break;
5599 case eCSR_AUTH_TYPE_AUTOSWITCH:
5600 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5601 break;
5602 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305603 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5605 return -EIO;
5606#ifdef WLAN_FEATURE_VOWIFI_11R
5607 case eCSR_AUTH_TYPE_FT_RSN_PSK:
5608#endif
5609 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07005610#ifdef WLAN_FEATURE_11W
5611 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05305612 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07005613#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05305614 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5616 return -EIO;
5617 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305618 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5620 return -EIO;
5621 }
5622 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
5623 {
5624 switch(pRoamProfile->negotiatedUCEncryptionType)
5625 {
5626 case eCSR_ENCRYPT_TYPE_NONE:
5627 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5628 break;
5629 case eCSR_ENCRYPT_TYPE_WEP40:
5630 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5631 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5632 break;
5633 case eCSR_ENCRYPT_TYPE_TKIP:
5634 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5635 break;
5636 case eCSR_ENCRYPT_TYPE_WEP104:
5637 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5638 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5639 break;
5640 case eCSR_ENCRYPT_TYPE_AES:
5641 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5642 break;
5643 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305644 hddLog(LOG1, "%s called with unknown auth type %d ",
5645 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 return -EIO;
5647 }
5648 }
5649
Shailender Karmuchia734f332013-04-19 14:02:48 -07005650 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 {
5652 switch(pRoamProfile->negotiatedMCEncryptionType)
5653 {
5654 case eCSR_ENCRYPT_TYPE_NONE:
5655 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5656 break;
5657 case eCSR_ENCRYPT_TYPE_WEP40:
5658 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5659 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5660 break;
5661 case eCSR_ENCRYPT_TYPE_TKIP:
5662 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5663 break;
5664 case eCSR_ENCRYPT_TYPE_WEP104:
5665 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5666 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5667 break;
5668 case eCSR_ENCRYPT_TYPE_AES:
5669 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5670 break;
5671 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305672 hddLog(LOG1, "%s called with unknown auth type %d ",
5673 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 return -EIO;
5675 }
5676 }
5677
5678 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005679 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 EXIT();
5681 return 0;
5682}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305683
5684int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5685 union iwreq_data *wrqu,char *extra)
5686{
5687 int ret;
5688
5689 vos_ssr_protect(__func__);
5690 ret = __iw_get_auth(dev, info, wrqu, extra);
5691 vos_ssr_unprotect(__func__);
5692
5693 return ret;
5694}
5695
Jeff Johnson295189b2012-06-20 16:38:30 -07005696/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005697
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305698 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07005699 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005701
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 \param - dev - Pointer to the net device.
5703 - info - Pointer to the iw_request_info.
5704 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005705 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005707
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305709int __iw_set_ap_address(struct net_device *dev,
5710 struct iw_request_info *info,
5711 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005712{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305713 hdd_station_ctx_t *pHddStaCtx;
5714 hdd_adapter_t *pAdapter;
5715 hdd_context_t *pHddCtx;
5716 v_U8_t *pMacAddress = NULL;
5717 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305718
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305720
5721 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5722 if (NULL == pAdapter)
5723 {
5724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5725 "%s: Adapter is NULL", __func__);
5726 return -EINVAL;
5727 }
5728 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5729 ret = wlan_hdd_validate_context(pHddCtx);
5730 if (0 != ret)
5731 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305732 return ret;
5733 }
5734 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5735 if (NULL == pHddStaCtx)
5736 {
5737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5738 "%s: pHddStaCtx is NULL", __func__);
5739 return -EINVAL;
5740 }
5741
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08005743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
5744 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07005745 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07005746
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305747 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 return 0;
5749}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305750
5751int iw_set_ap_address(struct net_device *dev,
5752 struct iw_request_info *info,
5753 union iwreq_data *wrqu, char *extra)
5754{
5755 int ret;
5756
5757 vos_ssr_protect(__func__);
5758 ret = __iw_set_ap_address(dev, info, wrqu, extra);
5759 vos_ssr_unprotect(__func__);
5760
5761 return ret;
5762}
5763
Jeff Johnson295189b2012-06-20 16:38:30 -07005764/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005765
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305766 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 This function returns the BSSID to the wpa_supplicant
5768 \param - dev - Pointer to the net device.
5769 - info - Pointer to the iw_request_info.
5770 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005771 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005773
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305775int __iw_get_ap_address(struct net_device *dev,
5776 struct iw_request_info *info,
5777 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005778{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305779 hdd_station_ctx_t *pHddStaCtx;
5780 hdd_adapter_t *pAdapter;
5781 hdd_context_t *pHddCtx;
5782 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305783
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 ENTER();
5785
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305786 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5787 if (NULL == pAdapter)
5788 {
5789 hddLog(VOS_TRACE_LEVEL_ERROR,
5790 "%s: Adapter is NULL", __func__);
5791 return -EINVAL;
5792 }
5793 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5794 ret = wlan_hdd_validate_context(pHddCtx);
5795 if (0 != ret)
5796 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305797 return ret;
5798 }
5799 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5800 if (NULL == pHddStaCtx)
5801 {
5802 hddLog(VOS_TRACE_LEVEL_ERROR,
5803 "%s: pHddStaCtx is NULL", __func__);
5804 return -EINVAL;
5805 }
5806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
5808 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
5809 {
Jeff Johnson4416a782013-03-25 14:17:50 -07005810 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 }
5812 else
5813 {
5814 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
5815 }
5816 EXIT();
5817 return 0;
5818}
Jeff Johnsond13512a2012-07-17 11:42:19 -07005819
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305820int iw_get_ap_address(struct net_device *dev,
5821 struct iw_request_info *info,
5822 union iwreq_data *wrqu, char *extra)
5823{
5824 int ret;
5825
5826 vos_ssr_protect(__func__);
5827 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5828 vos_ssr_unprotect(__func__);
5829
5830 return ret;
5831}
5832
Chet Lanctot186b5732013-03-18 10:26:30 -07005833#ifdef WLAN_FEATURE_11W
5834/**---------------------------------------------------------------------------
5835
5836 \brief hdd_indicateUnprotMgmtFrame -
5837 This function forwards the unprotected management frame to the supplicant
5838 \param - pAdapter - Pointer to HDD adapter
5839 - nFrameLength - Length of the unprotected frame being passed
5840 - pbFrames - Pointer to the frame buffer
5841 - frameType - 802.11 frame type
5842 \return - nothing
5843
5844 --------------------------------------------------------------------------*/
5845void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5846 tANI_U32 nFrameLength,
5847 tANI_U8* pbFrames,
5848 tANI_U8 frameType )
5849{
5850 tANI_U8 type = 0;
5851 tANI_U8 subType = 0;
5852
5853 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5854 __func__, frameType, nFrameLength);
5855
5856 /* Sanity Checks */
5857 if (NULL == pAdapter)
5858 {
5859 hddLog( LOGE, FL("pAdapter is NULL"));
5860 return;
5861 }
5862
5863 if (NULL == pAdapter->dev)
5864 {
5865 hddLog( LOGE, FL("pAdapter->dev is NULL"));
5866 return;
5867 }
5868
5869 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5870 {
5871 hddLog( LOGE, FL("pAdapter has invalid magic"));
5872 return;
5873 }
5874
5875 if( !nFrameLength )
5876 {
5877 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
5878 return;
5879 }
5880
5881 if (NULL == pbFrames) {
5882 hddLog( LOGE, FL("pbFrames is NULL"));
5883 return;
5884 }
5885
5886 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5887 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5888
5889 /* Get pAdapter from Destination mac address of the frame */
5890 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5891 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305892#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5893 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5894#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005895 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305896#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005897 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5898 }
5899 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5900 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305901#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5902 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5903#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005904 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305905#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005906 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5907 }
5908 else
5909 {
5910 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5911 return;
5912 }
5913}
5914#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005915
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005916#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005917void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5918 tANI_U8 state,
5919 tANI_U16 measInterval )
5920{
5921 union iwreq_data wrqu;
5922 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005923 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005924
5925 if (NULL == pAdapter)
5926 return;
5927
5928 // create the event
5929 memset(&wrqu, '\0', sizeof(wrqu));
5930 memset(buf, '\0', sizeof(buf));
5931
5932 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5933 tid, state, measInterval);
5934
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005935 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005936
5937 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005938 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005939 // send the event
5940 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5941}
5942
5943void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5944{
5945 union iwreq_data wrqu;
5946 char buf[IW_CUSTOM_MAX + 1];
5947 char *pos = buf;
5948 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5949
5950 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5951 return;
5952
5953 // create the event
5954 memset(&wrqu, '\0', sizeof(wrqu));
5955 memset(buf, '\0', sizeof(buf));
5956
5957 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305958 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
5959 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
5960 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
5961 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005962
5963 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
5964 pos += nBytes;
5965 freeBytes -= nBytes;
5966
5967 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5968 pos += WNI_CFG_BSSID_LEN;
5969 freeBytes -= WNI_CFG_BSSID_LEN;
5970
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005971 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5972 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005973
5974 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005975 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005976
5977 // send the event
5978 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5979}
5980
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005981void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005982{
5983 union iwreq_data wrqu;
5984 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005985 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005986
5987 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5988 return;
5989
5990 // create the event
5991 memset(&wrqu, '\0', sizeof(wrqu));
5992 memset(buf, '\0', sizeof(buf));
5993
5994 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5995
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005996 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005997
5998 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005999 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006000
6001 // send the event
6002 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6003}
6004
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006005void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
6006 const tANI_U16 measurementToken,
6007 const tANI_BOOLEAN flag,
6008 const tANI_U8 numBss)
6009{
6010 union iwreq_data wrqu;
6011 char buf[IW_CUSTOM_MAX];
6012 char *pos = buf;
6013 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6014
6015 memset(&wrqu, '\0', sizeof(wrqu));
6016 memset(buf, '\0', sizeof(buf));
6017
6018 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
6019 numBss);
6020
6021 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
6022 flag, numBss);
6023
6024 wrqu.data.pointer = buf;
6025 wrqu.data.length = nBytes;
6026 // send the event
6027 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6028}
6029
6030
6031static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006032 const tCsrRoamInfo *pRoamInfo)
6033{
6034 union iwreq_data wrqu;
6035 char buf[IW_CUSTOM_MAX + 1];
6036 char *pos = buf;
6037 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6038 tANI_U8 i = 0, len = 0;
6039 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
6040 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006041 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
6042 tANI_U8 ieLenByte = 1;
6043 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
6044#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006045
6046 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6047 return;
6048
6049 /* Custom event can pass maximum of 256 bytes of data,
6050 based on the IE len we need to identify how many BSS info can
6051 be filled in to custom event data */
6052 /*
6053 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
6054 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
6055 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
6056 */
6057
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006058 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006059 {
6060 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
6061 /* If the measurement is none and no scan results found,
6062 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006063 hdd_indicateEseBcnReportNoResults(pAdapter,
6064 pRoamInfo->pEseBcnReportRsp->measurementToken,
6065 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006066 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006067 }
6068 else
6069 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006070 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006071 {
6072 memset(&wrqu, '\0', sizeof(wrqu));
6073 memset(buf, '\0', sizeof(buf));
6074 tot_bcn_ieLen = 0;
6075 sendBss = 0;
6076 pos = buf;
6077 freeBytes = IW_CUSTOM_MAX;
6078
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006079 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006080 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006081 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
6082 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006083 {
6084 break;
6085 }
6086 tot_bcn_ieLen += len;
6087 sendBss++;
6088 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
6089 "IeLength(%d) Length of Ie(%d) totLen(%d)",
6090 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006091 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006092 tot_bcn_ieLen);
6093 }
6094
6095 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
6096 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006097 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6098 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006099
6100 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006101 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6102 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006103 pos += nBytes;
6104 freeBytes -= nBytes;
6105
6106 /* Copy total Beacon report data length */
6107 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
6108 pos += sizeof(tot_bcn_ieLen);
6109 freeBytes -= sizeof(tot_bcn_ieLen);
6110
6111 for (i = 0; i < sendBss; i++)
6112 {
6113 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306114 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
6115 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006116 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006117 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
6118 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
6119 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
6120 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
6121 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
6122 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
6123 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
6124 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
6125 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
6126 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
6127 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
6128 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
6129 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
6130 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
6131 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
6132 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006133
6134 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006135 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
6136 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006137 pos += len;
6138 freeBytes -= len;
6139
6140 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006141 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006142 vos_mem_copy(pos, (char*)&len, sizeof(len));
6143 pos += sizeof(len);
6144 freeBytes -= sizeof(len);
6145
6146 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006147 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006148 pos += len;
6149 freeBytes -= len;
6150 }
6151
6152 wrqu.data.pointer = buf;
6153 wrqu.data.length = strlen(buf);
6154
6155 // send the event
6156 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6157 lastSent += sendBss;
6158 }
6159 }
6160}
6161
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006162#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006163
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306164hdd_adapter_t *hdd_get_sta_connection_in_progress(hdd_context_t *hdd_ctx)
6165{
6166 hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
6167 hdd_adapter_t *adapter = NULL;
6168 VOS_STATUS status;
6169 hdd_station_ctx_t *hdd_sta_ctx;
6170
6171 if (!hdd_ctx) {
6172 hddLog(LOGE, FL("HDD context is NULL"));
6173 return NULL;
6174 }
6175
6176 status = hdd_get_front_adapter(hdd_ctx, &adapter_node);
6177 while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
6178 adapter = adapter_node->pAdapter;
6179 if (!adapter)
6180 goto end;
6181
6182 if ((WLAN_HDD_INFRA_STATION == adapter->device_mode) ||
6183 (WLAN_HDD_P2P_CLIENT == adapter->device_mode) ||
6184 (WLAN_HDD_P2P_DEVICE == adapter->device_mode)) {
6185 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6186 if (eConnectionState_Connecting ==
6187 hdd_sta_ctx->conn_info.connState) {
6188 hddLog(LOG1, FL("session_id %d: Connection is in progress"),
6189 adapter->sessionId);
6190 return adapter;
6191 } else if ((eConnectionState_Associated ==
6192 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +05306193 sme_is_sta_key_exchange_in_progress(
6194 hdd_ctx->hHal, adapter->sessionId)) {
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306195 hddLog(LOG1, FL("session_id %d: Key exchange is in progress"),
6196 adapter->sessionId);
6197 return adapter;
6198 }
6199 }
6200end:
6201 status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next);
6202 adapter_node = next;
6203 }
6204 return NULL;
6205}
6206