blob: b47942ac3c60f0da9f7fe6e5367cabbdbbf5dfc4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhe6137b82019-03-22 20:06:09 +05302 * Copyright (c) 2012-2019 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
Abhinav Kumar4d44f632019-08-02 13:55:54 +0530155#ifdef WLAN_FEATURE_SAE
156v_U8_t ccp_rsn_oui_80[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x08};
157v_U8_t ccp_rsn_oui_90[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x09};
158#endif
159
Shailender Karmuchia734f332013-04-19 14:02:48 -0700160#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700161// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700162#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
163#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700164#endif
165
166#define BEACON_FRAME_IES_OFFSET 12
167
Abhishek Singh78c691f2017-11-30 13:48:44 +0530168/* The time after add bss, in which SAP should start ECSA to move to SCC */
169#define ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL 1500
Abhishek Singh10e17cf2018-03-12 14:34:22 +0530170/*
171 * Time in ms after disconnect, in which the SAP should move to non DFS channel.
172 * This will avoid multiple SAP channel switch if disconnet is followed by
173 * connect.
174 */
175#define ECSA_DFS_CHAN_CHANGE_DEFER_TIME 200
Abhishek Singh78c691f2017-11-30 13:48:44 +0530176
Chet Lanctot186b5732013-03-18 10:26:30 -0700177#ifdef WLAN_FEATURE_11W
178void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
179 tANI_U32 nFrameLength,
180 tANI_U8* pbFrames,
181 tANI_U8 frameType );
182#endif
183
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800184#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700185static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
186 tANI_U8 state,
187 tANI_U16 measInterval );
188static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800189static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
190static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700191
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800192#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700193
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530194static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
195 tCsrRoamInfo *pRoamInfo,
196 tANI_U32 roamId,
197 eRoamCmdStatus roamStatus,
198 eCsrRoamResult roamResult );
199
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530200v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
201 eConnectionState connState )
202{
203 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530204 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
205 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 pHddStaCtx->conn_info.connState = connState;
207}
208
209// returns FALSE if not connected.
210// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
211// returns the connection state. Can specify NULL if you dont' want to get the actual state.
212
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
214 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700215{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700216 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 // get the connection state.
220 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700221 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700223 eConnectionState_IbssConnected == connState ||
224 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 {
226 fConnected = VOS_TRUE;
227 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700228 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 {
230 fConnected = VOS_FALSE;
231 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 if ( pConnState )
234 {
235 *pConnState = connState;
236 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 return( fConnected );
239}
240
241v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
242{
243 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700244}
Jeff Johnson295189b2012-06-20 16:38:30 -0700245
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530246eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
247{
248 v_U8_t staChannel = 0;
249
250 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
251 {
252 staChannel = pHddStaCtx->conn_info.operationChannel;
253 }
254
255 if ( staChannel > 0 && staChannel < 14 )
256 return eCSR_BAND_24;
257 else if (staChannel >= 36 && staChannel <= 165 )
258 return eCSR_BAND_5G;
259 else /* If station is not connected return as eCSR_BAND_ALL */
260 return eCSR_BAND_ALL;
261}
262
263
Jeff Johnson295189b2012-06-20 16:38:30 -0700264//TODO - Not used anyhwere. Can be removed.
265#if 0
266//
267v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
268{
269 v_BOOL_t fConnectedInfra = FALSE;
270 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700271
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700273 {
274 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 {
276 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700277 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700279
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 return( fConnectedInfra );
281}
282#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700283
Jeff Johnson295189b2012-06-20 16:38:30 -0700284static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
285{
286 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700287
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700289
290 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 {
292 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
293 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700294
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 return( fConnected );
296}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700297
Jeff Johnson295189b2012-06-20 16:38:30 -0700298inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
299{
300 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700301
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700303
304 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 {
306 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
307 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 return( fConnected );
310}
311
312static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
313{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700314 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 {
316 case eCSR_BSS_TYPE_INFRASTRUCTURE:
317 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
318 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700319
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 case eCSR_BSS_TYPE_IBSS:
321 case eCSR_BSS_TYPE_START_IBSS:
322 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
323 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700324
325 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700327 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 default:
329 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700330 break;
331 }
332
Jeff Johnson295189b2012-06-20 16:38:30 -0700333}
334
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530335/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530336 * hdd_copy_ht_caps()- Populate kernel HT caps structure object
337 * @hdd_ht_cap: HT capabilities of kernel type
338 * @roam_ht_cap: HT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530339 *
340 * Return: None
341 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530342void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
343 tDot11fIEHTCaps *roam_ht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530344{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530345 uint32_t i, temp_ht_cap;
346
347 vos_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
348
349 if (roam_ht_cap->advCodingCap)
350 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
351 if (roam_ht_cap->supportedChannelWidthSet)
352 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
353 temp_ht_cap = roam_ht_cap->mimoPowerSave &
354 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
355 if (temp_ht_cap)
356 hdd_ht_cap->cap_info |=
357 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
358 if (roam_ht_cap->greenField)
359 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
360 if (roam_ht_cap->shortGI20MHz)
361 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
362 if (roam_ht_cap->shortGI40MHz)
363 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
364 if (roam_ht_cap->txSTBC)
365 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
366 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
367 IEEE80211_HT_CAP_RX_STBC_SHIFT);
368 if (temp_ht_cap)
369 hdd_ht_cap->cap_info |=
370 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
371 if (roam_ht_cap->delayedBA)
372 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
373 if (roam_ht_cap->maximalAMSDUsize)
374 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
375 if (roam_ht_cap->dsssCckMode40MHz)
376 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
377 if (roam_ht_cap->psmp)
378 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
379 if (roam_ht_cap->stbcControlFrame)
380 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
381 if (roam_ht_cap->lsigTXOPProtection)
382 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
383
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530384 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
385 if (roam_ht_cap->maxRxAMPDUFactor)
386 hdd_ht_cap->ampdu_params_info |=
387 IEEE80211_HT_AMPDU_PARM_FACTOR;
388 temp_ht_cap = roam_ht_cap->mpduDensity &
389 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
390 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
391 if (temp_ht_cap)
392 hdd_ht_cap->ampdu_params_info |=
393 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
394
395 /* 802.11n HT extended capabilities masks */
396 if (roam_ht_cap->pco)
397 hdd_ht_cap->extended_ht_cap_info |=
398 IEEE80211_HT_EXT_CAP_PCO;
399 temp_ht_cap = roam_ht_cap->transitionTime &
400 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
401 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
402 if (temp_ht_cap)
403 hdd_ht_cap->extended_ht_cap_info |=
404 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
405 temp_ht_cap = roam_ht_cap->mcsFeedback &
406 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
407 if (temp_ht_cap)
408 hdd_ht_cap->extended_ht_cap_info |=
409 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
410
411 /* tx_bf_cap_info capabilities */
412 if (roam_ht_cap->txBF)
413 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
414 if (roam_ht_cap->rxStaggeredSounding)
415 hdd_ht_cap->tx_BF_cap_info |=
416 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
417 if (roam_ht_cap->txStaggeredSounding)
418 hdd_ht_cap->tx_BF_cap_info |=
419 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
420 if (roam_ht_cap->rxZLF)
421 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
422 if (roam_ht_cap->txZLF)
423 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
424 if (roam_ht_cap->implicitTxBF)
425 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
426 temp_ht_cap = roam_ht_cap->calibration &
427 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
428 if (temp_ht_cap)
429 hdd_ht_cap->tx_BF_cap_info |=
430 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
431 if (roam_ht_cap->explicitCSITxBF)
432 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
433 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
434 hdd_ht_cap->tx_BF_cap_info |=
435 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
436 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
437 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
438 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
439 if (temp_ht_cap)
440 hdd_ht_cap->tx_BF_cap_info |=
441 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
442 temp_ht_cap =
443 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
444 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
445 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
446 if (temp_ht_cap)
447 hdd_ht_cap->tx_BF_cap_info |=
448 temp_ht_cap <<
449 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
450 temp_ht_cap =
451 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
452 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
453 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
454 if (temp_ht_cap)
455 hdd_ht_cap->tx_BF_cap_info |=
456 temp_ht_cap <<
457 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
458 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
459 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
460 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
461 if (temp_ht_cap)
462 hdd_ht_cap->tx_BF_cap_info |=
463 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
464 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
465 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
466 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
467 if (temp_ht_cap)
468 hdd_ht_cap->tx_BF_cap_info |=
469 temp_ht_cap <<
470 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
471 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
472 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
473 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
474 if (temp_ht_cap)
475 hdd_ht_cap->tx_BF_cap_info |=
476 temp_ht_cap <<
477 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
478
479 /* antenna selection */
480 if (roam_ht_cap->antennaSelection)
481 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
482 if (roam_ht_cap->explicitCSIFeedbackTx)
483 hdd_ht_cap->antenna_selection_info |=
484 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
485 if (roam_ht_cap->antennaIndicesFeedbackTx)
486 hdd_ht_cap->antenna_selection_info |=
487 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
488 if (roam_ht_cap->explicitCSIFeedback)
489 hdd_ht_cap->antenna_selection_info |=
490 ANTENNA_SEL_INFO_EXP_CSI_FB;
491 if (roam_ht_cap->antennaIndicesFeedback)
492 hdd_ht_cap->antenna_selection_info |=
493 ANTENNA_SEL_INFO_ANT_ID_FB;
494 if (roam_ht_cap->rxAS)
495 hdd_ht_cap->antenna_selection_info |=
496 ANTENNA_SEL_INFO_RX_AS;
497 if (roam_ht_cap->txSoundingPPDUs)
498 hdd_ht_cap->antenna_selection_info |=
499 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
500
501 /* mcs data rate */
502 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
503 hdd_ht_cap->mcs.rx_mask[i] =
504 roam_ht_cap->supportedMCSSet[i];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530505
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530506 hdd_ht_cap->mcs.rx_highest =
507 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
508 ((short) (roam_ht_cap->supportedMCSSet[10]));
509 hdd_ht_cap->mcs.tx_params =
510 roam_ht_cap->supportedMCSSet[12];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530511
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530512}
513
514
515#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
516#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
517#define VHT_CAP_RXSTBC_MASK_SHIFT 8
518#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
519#define VHT_CAP_BEAMFORMEE_STS_MASK \
520 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
521#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
522#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
523 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
524#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
525#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
526 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
527#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
528
529/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530530 * hdd_copy_vht_caps()- Populate kernel VHT caps structure object
531 * @hdd_ht_cap: VHT capabilities of kernel type
532 * @roam_ht_cap: VHT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530533 *
534 * Return: None
535 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530536void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
537 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530538{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530539 uint32_t temp_vht_cap;
540
541 vos_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
542
543 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
544 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
545 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
546 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
547 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
548 if (temp_vht_cap)
549 if (roam_vht_cap->supportedChannelWidthSet &
550 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
551 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
552 hdd_vht_cap->vht_cap_info |=
553 temp_vht_cap <<
554 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
555 if (roam_vht_cap->supportedChannelWidthSet &
556 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
557 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
558 hdd_vht_cap->vht_cap_info |=
559 temp_vht_cap <<
560 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
561 if (roam_vht_cap->ldpcCodingCap)
562 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
563 if (roam_vht_cap->shortGI80MHz)
564 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
565 if (roam_vht_cap->shortGI160and80plus80MHz)
566 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
567 if (roam_vht_cap->txSTBC)
568 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
569 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
570 VHT_CAP_RXSTBC_MASK_SHIFT);
571 if (temp_vht_cap)
572 hdd_vht_cap->vht_cap_info |=
573 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
574 if (roam_vht_cap->suBeamFormerCap)
575 hdd_vht_cap->vht_cap_info |=
576 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
577 if (roam_vht_cap->suBeamformeeCap)
578 hdd_vht_cap->vht_cap_info |=
579 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
580 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
581 (VHT_CAP_BEAMFORMEE_STS_MASK);
582 if (temp_vht_cap)
583 hdd_vht_cap->vht_cap_info |=
584 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
585 temp_vht_cap = roam_vht_cap->numSoundingDim &
586 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
587 if (temp_vht_cap)
588 hdd_vht_cap->vht_cap_info |=
589 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
590 if (roam_vht_cap->muBeamformerCap)
591 hdd_vht_cap->vht_cap_info |=
592 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
593 if (roam_vht_cap->muBeamformeeCap)
594 hdd_vht_cap->vht_cap_info |=
595 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
596 if (roam_vht_cap->vhtTXOPPS)
597 hdd_vht_cap->vht_cap_info |=
598 IEEE80211_VHT_CAP_VHT_TXOP_PS;
599 if (roam_vht_cap->htcVHTCap)
600 hdd_vht_cap->vht_cap_info |=
601 IEEE80211_VHT_CAP_HTC_VHT;
602 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
603 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
604 if (temp_vht_cap)
605 hdd_vht_cap->vht_cap_info |=
606 temp_vht_cap <<
607 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
608 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
609 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
610 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
611 if (temp_vht_cap)
612 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
613 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
614 if (roam_vht_cap->rxAntPattern)
615 hdd_vht_cap->vht_cap_info |=
616 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
617 if (roam_vht_cap->txAntPattern)
618 hdd_vht_cap->vht_cap_info |=
619 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
620 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
621 hdd_vht_cap->supp_mcs.rx_highest =
622 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
623 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
624 hdd_vht_cap->supp_mcs.tx_highest =
625 ((uint16_t)roam_vht_cap->txSupDataRate);
626}
627
628/* ht param */
629#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
630#define HT_PARAM_SERVICE_INT_GRAN 0xe0
631#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
632
633/* operatinon mode */
634#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
635
636/* stbc_param */
637#define HT_STBC_PARAM_MCS 0x007f
638
639/**
640 * hdd_copy_ht_operation()- copy HT operation element from roam info to
641 * hdd station context.
642 * @hdd_sta_ctx: pointer to hdd station context
643 * @roam_info: pointer to roam info
644 *
645 * Return: None
646 */
647static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
648 tCsrRoamInfo *roam_info)
649{
650 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
651 struct ieee80211_ht_operation *hdd_ht_ops =
652 &hdd_sta_ctx->conn_info.ht_operation;
653 uint32_t i, temp_ht_ops;
654
655 vos_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
656
657 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
658
659 /* HT_PARAMS */
660 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
661 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
662 if (temp_ht_ops)
663 hdd_ht_ops->ht_param |= temp_ht_ops;
664 else
665 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
666 if (roam_ht_ops->recommendedTxWidthSet)
667 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
668 if (roam_ht_ops->rifsMode)
669 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
670 if (roam_ht_ops->controlledAccessOnly)
671 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
672 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
673 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
674 if (temp_ht_ops)
675 hdd_ht_ops->ht_param |= temp_ht_ops <<
676 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
677
678 /* operation mode */
679 temp_ht_ops = roam_ht_ops->opMode &
680 IEEE80211_HT_OP_MODE_PROTECTION;
681 switch (temp_ht_ops) {
682 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
683 hdd_ht_ops->operation_mode |=
684 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
685 break;
686 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
687 hdd_ht_ops->operation_mode |=
688 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
689 break;
690 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
691 hdd_ht_ops->operation_mode |=
692 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
693 break;
694 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
695 default:
696 hdd_ht_ops->operation_mode |=
697 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
698 }
699 if (roam_ht_ops->nonGFDevicesPresent)
700 hdd_ht_ops->operation_mode |=
701 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
702 if (roam_ht_ops->transmitBurstLimit)
703 hdd_ht_ops->operation_mode |=
704 HT_OP_MODE_TX_BURST_LIMIT;
705 if (roam_ht_ops->obssNonHTStaPresent)
706 hdd_ht_ops->operation_mode |=
707 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
708
709 /* stbc_param */
710 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
711 HT_STBC_PARAM_MCS;
712 if (temp_ht_ops)
713 hdd_ht_ops->stbc_param |= temp_ht_ops;
714 if (roam_ht_ops->dualCTSProtection)
715 hdd_ht_ops->stbc_param |=
716 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
717 if (roam_ht_ops->secondaryBeacon)
718 hdd_ht_ops->stbc_param |=
719 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
720 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
721 hdd_ht_ops->stbc_param |=
722 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
723 if (roam_ht_ops->pcoActive)
724 hdd_ht_ops->stbc_param |=
725 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
726 if (roam_ht_ops->pcoPhase)
727 hdd_ht_ops->stbc_param |=
728 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
729
730 /* basic MCs set */
731 for (i = 0; i < 16; ++i)
732 hdd_ht_ops->basic_set[i] =
733 roam_ht_ops->basicMCSSet[i];
734}
735
736/**
737 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
738 * hdd station context.
739 * @hdd_sta_ctx: pointer to hdd station context
740 * @roam_info: pointer to roam info
741 *
742 * Return: None
743 */
744static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
745 tCsrRoamInfo *roam_info)
746{
747 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
748 struct ieee80211_vht_operation *hdd_vht_ops =
749 &hdd_sta_ctx->conn_info.vht_operation;
750
751 vos_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
752
753 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
754 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
755 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
756 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
757}
758
759
760/**
761 * hdd_save_bss_info() - save connection info in hdd sta ctx
762 * @adapter: Pointer to adapter
763 * @roam_info: pointer to roam info
764 *
765 * Return: None
766 */
767static void hdd_save_bss_info(hdd_adapter_t *adapter,
768 tCsrRoamInfo *roam_info)
769{
770 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
771
772 hdd_sta_ctx->conn_info.freq = vos_chan_to_freq(
773 hdd_sta_ctx->conn_info.operationChannel);
774 if (roam_info->vht_caps.present) {
775 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530776 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
777 &roam_info->vht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530778 } else {
779 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
780 }
781 if (roam_info->ht_caps.present) {
782 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530783 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps, &roam_info->ht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530784 } else {
785 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
786 }
787 if (roam_info->reassoc)
788 hdd_sta_ctx->conn_info.roam_count++;
789 if (roam_info->hs20vendor_ie.present) {
790 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
791 vos_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
792 &roam_info->hs20vendor_ie,
793 sizeof(roam_info->hs20vendor_ie));
794 } else {
795 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
796 }
797 if (roam_info->ht_operation.present) {
798 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
799 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
800 } else {
801 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
802 }
803 if (roam_info->vht_operation.present) {
804 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
805 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
806 } else {
807 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
808 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +0530809 /* Cache last connection info */
810 vos_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
811 sizeof(connection_info_t));
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530812}
813
Jeff Johnson295189b2012-06-20 16:38:30 -0700814void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
815{
816 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
817 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700818
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700820
821 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700823 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
825 {
826 VOS_ASSERT( pRoamInfo->pBssDesc );
827 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
828
829 // Save the Station ID for this station from the 'Roam Info'.
830 //For IBSS mode, staId is assigned in NEW_PEER_IND
831 //For reassoc, the staID doesn't change and it may be invalid in this structure
832 //so no change here.
833 if( !pRoamInfo->fReassocReq )
834 {
835 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
836 }
837 }
838 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700839 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700841 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 else
843 {
844 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
845 // or we can't function.
846 VOS_ASSERT( 0 );
847 }
848
849 // notify WMM
850 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
851
852 if( !pRoamInfo->u.pConnectedProfile )
853 {
854 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
855 }
856 else
857 {
858 // Get Multicast Encryption Type
859 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
860 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
861 // Get Unicast Encrytion Type
862 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
863 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
864
865 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
866
867 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
868
869 // Save the ssid for the connection
870 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530871
872 // Save dot11mode in which STA associated to AP
873 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530874
875 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 }
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530877 hdd_save_bss_info(pAdapter, pRoamInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700878 }
879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700881 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
882
Jeff Johnson295189b2012-06-20 16:38:30 -0700883}
884
885#if defined(WLAN_FEATURE_VOWIFI_11R)
886/*
887 * Send the 11R key information to the supplicant.
888 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800889 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 * for the same purpose.)
891 *
892 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
893 * this contains the R1KHID, R0KHID and the MDID.
894 * For FT, this consists of the Reassoc Rsp FTIEs.
895 * This is the Assoc Response.
896 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700897static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 tCsrRoamInfo *pCsrRoamInfo)
899{
900 union iwreq_data wrqu;
901 char *buff;
902 unsigned int len = 0;
903 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700904
905 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 {
907 hddLog(LOGE,
908 "%s: pCsrRoamInfo->nAssocRspLength=%d",
909 __func__, (int)pCsrRoamInfo->nAssocRspLength);
910 return;
911 }
912
Shailender Karmuchia734f332013-04-19 14:02:48 -0700913 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700915 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700917 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 return;
919 }
920
921 // pFTAssocRsp needs to point to the IEs
922 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
923 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
924 (unsigned int)pFTAssocRsp[0],
925 (unsigned int)pFTAssocRsp[1]);
926
927 // We need to send the IEs to the supplicant.
928 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700929 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700931 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 return;
933 }
934
935 // Send the Assoc Resp, the supplicant needs this for initial Auth.
936 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700937 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700939 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
941
942 kfree(buff);
943}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700944#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700945
946#ifdef WLAN_FEATURE_VOWIFI_11R
947
948/*---------------------------------------------------
949 *
950 * Send the FTIEs, RIC IEs during FT. This is eventually
951 * used to send the FT events to the supplicant
952 *
953 * At the reception of Auth2 we send the RIC followed
954 * by the auth response IEs to the supplicant.
955 * Once both are received in the supplicant, an FT
956 * event is generated to the supplicant.
957 *
958 *---------------------------------------------------
959 */
960void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
961{
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 tANI_U16 auth_resp_len = 0;
963 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
965
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530966#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700967 struct cfg80211_ft_event_params ftEvent;
968 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
969 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
970 struct net_device *dev = pAdapter->dev;
971#else
972 char *buff;
973 union iwreq_data wrqu;
974 tANI_U16 str_len;
975#endif
976
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530977#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530978 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
979 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700980
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530981 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
982 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530983 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700984 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530985 hddLog(LOGW,
986 "%s: RIC IEs is of length 0 not sending RIC Information for now",
987 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700988 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700989
990 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530991 ftEvent.ric_ies_len = ric_ies_length;
992 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700993
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530994 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800995 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700996
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530997 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700998 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530999 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001000 return;
1001 }
1002
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301003 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301004
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301005 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001006
1007 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
1008 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
1009
Jeff Johnson59a121e2013-11-30 09:46:08 -08001010 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
1011 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
1012 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301013 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001014 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
1015 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1016 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001017
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301018 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001019
1020#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301021 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301023 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301025 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 return;
1027 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301028 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001029
Shailender Karmuchia734f332013-04-19 14:02:48 -07001030 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301032 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001033 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301034 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301036 hddLog(LOGW,
1037 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1038 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 }
1040 else
1041 {
1042 wrqu.data.length = str_len + ric_ies_length;
1043 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1044 }
1045
1046 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301047 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301049 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
1050 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001051
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301052 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301054 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +05301055 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 return;
1057 }
1058
1059 wrqu.data.length = str_len + auth_resp_len;
1060 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1061
1062 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001063#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001064}
1065
1066#endif /* WLAN_FEATURE_VOWIFI_11R */
1067
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001068#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001069
1070/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001071 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 * (This keeps the supplicant "up to date" on the current channel.)
1073 *
1074 * The current (new AP) channel information is passed in.
1075 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001076static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 tCsrRoamInfo *pCsrRoamInfo)
1078{
1079 union iwreq_data wrqu;
1080 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001081
Shailender Karmuchia734f332013-04-19 14:02:48 -07001082
1083 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 {
1085 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001086 "%s: pCsrRoamInfo->pBssDesc=%pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 __func__, descriptor);
1088 return;
1089 }
1090
1091 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -08001092 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 memset(&wrqu, '\0', sizeof(wrqu));
1094 wrqu.freq.m = descriptor->channelId;
1095 wrqu.freq.e = 0;
1096 wrqu.freq.i = 0;
1097 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1098}
1099
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001100#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001101
1102void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
1103{
1104 union iwreq_data wrqu;
1105 u8 *pBeaconIes;
1106 u8 currentLen = 0;
1107 char *buff;
1108 int totalIeLen = 0, currentOffset = 0, strLen;
1109
1110 memset(&wrqu, '\0', sizeof(wrqu));
1111
1112 if (0 == pCsrRoamInfo->nBeaconLength)
1113 {
1114 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
1115 return;
1116 }
1117 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001118 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001120 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 return;
1122 }
1123
1124 // pBeaconIes needs to point to the IEs
1125 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
1126 (unsigned int)pBeaconIes[0],
1127 (unsigned int)pBeaconIes[1]);
1128 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001129
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 // We need to send the IEs to the supplicant.
1131 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001132 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001134 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 return;
1136 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001137 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001138
1139 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
1140 currentLen = strLen + 1;
1141
1142 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1143 do
1144 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001145 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 * max size and send it to supplicant. Changes are done in supplicant to handle this */
1147 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
1148 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
1149 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
1150 currentOffset += currentLen;
1151 totalIeLen -= currentLen;
1152 wrqu.data.length = strLen + 1 + currentLen;
1153 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -07001154 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 else
1156 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
1157
1158 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
1159 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1160 } while (totalIeLen > 0);
1161
1162 kfree(buff);
1163}
1164
1165static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
1166{
1167 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1168 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1169 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1170 union iwreq_data wrqu;
1171 int we_event;
1172 char *msg;
1173 int type = -1;
1174
Shailender Karmuchia734f332013-04-19 14:02:48 -07001175#if defined (WLAN_FEATURE_VOWIFI_11R)
1176 // Added to find the auth type on the fly at run time
1177 // rather than with cfg to see if FT is enabled
1178 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
1180#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001181
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001183 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001185
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
1187 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301188 /* In case of roaming ; We are not doing disconnect.
1189 * If disconnect is not being done for roam; We will not
1190 * decrease count for Active sessions. We should not increase active
1191 * active session in case of roaming.
1192 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +05301193 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +05301194 {
1195 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
1196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
1198 type = WLAN_STA_ASSOC_DONE_IND;
1199
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001200#ifdef WLAN_FEATURE_P2P_DEBUG
1201 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1202 {
1203 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
1204 {
1205 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
1206 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1207 "Connecting state to Connected State for 8-way "
1208 "Handshake");
1209 }
1210 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
1211 {
1212 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
1213 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1214 "Connecting state to P2P Client Connection Completed");
1215 }
1216 }
1217#endif
Yeshwanth Sriram Guntuka0004c0b2017-12-06 14:43:49 +05301218 hddLog(VOS_TRACE_LEVEL_ERROR, MAC_ADDRESS_STR " connected to "
1219 MAC_ADDRESS_STR,
1220 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1221 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
1223
Bhargav Shahd0715912015-10-01 18:17:37 +05301224 hdd_manage_delack_timer(pHddCtx);
1225
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
1227 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
1228 * and fFTEnable is TRUE */
1229#ifdef WLAN_FEATURE_VOWIFI_11R
1230 // Send FT Keys to the supplicant when FT is enabled
1231 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -07001232 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001233#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1235 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
1236#endif
1237 )
1238 {
1239 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
1240 }
1241#endif
1242 }
1243 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
1244 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301245 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -07001246 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301248
1249 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1250 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
1251 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 }
1253 else /* Not Associated */
1254 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301255 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1256 "wlan: disconnected");
gaurank kathpalia51801582019-04-05 13:56:55 +05301257 if (pHddCtx->btCoexModeSet) {
1258 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1259 FL("Wlan disconnected, sending DHCP stop indication"));
1260 pHddCtx->btCoexModeSet = FALSE;
1261 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
1262 pAdapter->sessionId);
1263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 type = WLAN_STA_DISASSOC_DONE_IND;
1265 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +05301266
1267 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001269 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001270
1271 msg = NULL;
1272 /*During the WLAN uninitialization,supplicant is stopped before the
1273 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301274 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 {
1276 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001277#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001279 {
1280 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1281 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
1283 }
1284#endif
1285 }
1286 send_btc_nlink_msg(type, 0);
1287}
1288
1289void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
1290{
1291 // Remove staId, bssId and peerMacAddress
1292 pHddStaCtx->conn_info.staId [ 0 ] = 0;
1293 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
1294 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
1295
1296 // Clear all security settings
1297 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1298 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1299 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1300
1301 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -07001302 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001303
1304 // Set not-connected state
1305 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -07001306
1307 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
1308}
Katya Nigam47528772015-02-11 12:24:49 +05301309
1310VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
1311{
Katya Nigam1fd24402015-02-16 14:52:19 +05301312 v_U8_t ac;
1313 /**Track whether OS TX queue has been disabled.*/
1314 v_BOOL_t txSuspended[NUM_TX_QUEUES];
1315 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +05301316 v_U8_t i;
1317 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1318 hdd_ibss_peer_info_t *pPeerInfo;
1319
1320 if( NULL == pHddStaCtx )
1321 {
1322 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1323 "%s: HDD station context NULL ",__func__);
1324 return VOS_STATUS_E_FAILURE;
1325 }
Katya Nigam1fd24402015-02-16 14:52:19 +05301326
Katya Nigam47528772015-02-11 12:24:49 +05301327 pPeerInfo = &pHddStaCtx->ibss_peer_info;
1328 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
1329 {
1330 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1331 "%s: Deinit station not inited %d", __func__, STAId );
1332 return VOS_STATUS_E_FAILURE;
1333 }
1334
1335 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +05301336
1337 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1338 {
1339 tlAC = hdd_QdiscAcToTlAC[ac];
1340 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
1341 }
1342
Katya Nigam47528772015-02-11 12:24:49 +05301343 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1344
Katya Nigam1fd24402015-02-16 14:52:19 +05301345 /* re-init hdd list, since netdev can still open adapter until
1346 * driver gets unloaded
1347 */
1348 for (i = 0; i < NUM_TX_QUEUES; i ++)
1349 {
1350 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
1351 HDD_TX_QUEUE_MAX_LEN);
1352 }
1353
1354 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1355 {
1356 if (txSuspended[ac])
1357 {
1358 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1359 "%s: TX queue re-enabled", __func__);
1360 netif_wake_subqueue(pAdapter->dev, ac);
1361 }
1362 }
Katya Nigam47528772015-02-11 12:24:49 +05301363 return VOS_STATUS_SUCCESS;
1364}
1365
1366static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1367{
1368 VOS_STATUS vosStatus;
1369
1370 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1371 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1372 {
1373 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1374 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1375 "Status= %d [0x%08X]",
1376 __func__, staId, vosStatus, vosStatus );
1377 }
1378
1379 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
1380 if( VOS_STATUS_E_FAILURE == vosStatus )
1381 {
1382 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1383 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
1384 "Status = %d [0x%08X]",
1385 staId, vosStatus, vosStatus );
1386 }
1387
1388 return( vosStatus );
1389}
1390
1391VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
1392{
1393 v_U8_t i = 0;
1394 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1395 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1396
1397 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
1398 {
1399 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1400 "%s: Reinit station %d", __func__, STAId );
1401 return VOS_STATUS_E_FAILURE;
1402 }
1403
1404 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1405 for (i = 0; i < NUM_TX_QUEUES; i ++)
1406 {
1407 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
1408 }
1409
1410 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
1411 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
1412 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
1413
1414 return VOS_STATUS_SUCCESS;
1415}
1416
1417static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
1418 tCsrRoamInfo *pRoamInfo,
1419 v_U8_t staId,
1420 v_MACADDR_t *pPeerMacAddress,
1421 tSirBssDescription *pBssDesc )
1422{
1423 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1424 WLAN_STADescType staDesc = {0};
1425 eCsrEncryptionType connectedCipherAlgo;
1426 v_BOOL_t fConnected;
1427 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1428 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1429 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1430
1431 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
1432 {
1433 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1434 "clean up old entry for STA %d", staId);
1435 hdd_ibss_DeregisterSTA( pAdapter, staId );
1436 }
1437
1438 staDesc.ucSTAId = staId;
1439 staDesc.wSTAType = WLAN_STA_IBSS;
1440
1441 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1442 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1443 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1444 // pass when making an Infrastructure connection.
1445 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
1446 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
1447 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1448
1449 if (hdd_wmm_is_active(pAdapter))
1450 {
1451 staDesc.ucQosEnabled = 1;
1452 }
1453 else
1454 {
1455 staDesc.ucQosEnabled = 0;
1456 }
1457 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1458 "HDD SOFTAP register TL QoS_enabled=%d",
1459 staDesc.ucQosEnabled );
1460
1461 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1462 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1463 {
1464 staDesc.ucProtectedFrame = 1;
1465 }
1466 else
1467 {
1468 staDesc.ucProtectedFrame = 0;
1469
1470 }
1471
1472 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
1473
1474 // UMA is Not ready yet, Xlation will be done by TL
1475 staDesc.ucSwFrameTXXlation = 1;
1476 staDesc.ucSwFrameRXXlation = 1;
1477 staDesc.ucAddRmvLLC = 1;
1478 // Initialize signatures and state
1479 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1480 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1481 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
1482
1483 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1484
1485 // Register the Station with TL.
1486 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1487 hdd_rx_packet_cbk,
1488 hdd_tx_complete_cbk,
1489 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
1490 pBssDesc->rssi );
1491 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1492 {
1493 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1494 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
1495 vosStatus, vosStatus );
1496 return vosStatus;
1497 }
1498
1499 //Timer value should be in milliseconds
1500 if ( pHddCtx->cfg_ini->dynSplitscan &&
1501 ( VOS_TIMER_STATE_RUNNING !=
1502 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1503 {
1504 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1505 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
1506 }
1507
1508 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
1509 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
1510
1511 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
1512 WLANTL_STA_AUTHENTICATED );
1513
1514 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
1515 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1516
1517 return( vosStatus );
1518}
1519
Jeff Johnson295189b2012-06-20 16:38:30 -07001520/* TODO Revist this function. and data path */
1521static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1522{
1523 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -07001524
Katya Nigam47528772015-02-11 12:24:49 +05301525 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -07001526
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1528 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1529 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05301530 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001532 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001533 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 }
1535 return( vosStatus );
1536}
1537
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301538/**
1539 * hdd_print_bss_info() - print bss info
1540 * @hdd_sta_ctx: pointer to hdd station context
1541 *
1542 * Return: None
1543 */
1544void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
1545{
1546 uint32_t *cap_info;
1547
1548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"WIFI DATA LOGGER");
1549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"channel: %d",
1550 hdd_sta_ctx->conn_info.freq);
1551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"dot11mode: %d",
1552 hdd_sta_ctx->conn_info.dot11Mode);
1553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"AKM: %d",
1554 hdd_sta_ctx->conn_info.authType);
1555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ssid: %.*s",
1556 hdd_sta_ctx->conn_info.SSID.SSID.length,
1557 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"roam count: %d",
1559 hdd_sta_ctx->conn_info.roam_count);
1560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ant_info: %d",
1561 hdd_sta_ctx->conn_info.txrate.nss);
1562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate legacy %d",
1563 hdd_sta_ctx->conn_info.txrate.legacy);
1564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate mcs: %d",
1565 hdd_sta_ctx->conn_info.txrate.mcs);
1566 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1567 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ht caps: %x",
1569 *cap_info);
1570 }
1571 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1572 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"vht caps: %x",
1574 *cap_info);
1575 }
1576 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"hs20 info: %x",
1578 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"signal: %d",
1580 hdd_sta_ctx->conn_info.signal);
1581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"noise: %d",
1582 hdd_sta_ctx->conn_info.noise);
1583}
1584
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301585/**
1586 * hdd_check_and_move_if_sap_is_on_dfs_chan() - move the sap to non dfs channel
1587 * @hdd_ctx: pointer to hdd context
1588 * @sta_adapter: pointer to sta adapater
1589 *
1590 * This function is used to check if SAP is operating on DFS channel in stand
1591 * alone mode and move it to non dfs channel
1592 *
1593 * Return: void.
1594 */
1595static void hdd_check_and_move_if_sap_is_on_dfs_chan(hdd_context_t *hdd_ctx,
1596 hdd_adapter_t *sta_adapter)
1597{
1598 hdd_adapter_t *sap_adapter;
1599 ptSapContext sap_ctx;
1600 v_CONTEXT_t vos_ctx;
1601 eNVChannelEnabledType chan_state;
1602
1603 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_ctx)) {
1604 sap_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_SOFTAP);
1605
1606 if (!sap_adapter) {
1607 hddLog(LOG1, FL("SAP not exists, nothing to do"));
1608 return;
1609 }
1610
1611 vos_ctx = hdd_ctx->pvosContext;
1612 if (!vos_ctx) {
1613 hddLog(LOGE, FL("vos_ctx is NULL"));
1614 return;
1615 }
1616 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
1617 if (!sap_ctx) {
1618 hddLog(LOG1, FL("sap_ctx not exists"));
1619 return;
1620 }
1621
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301622 if (sap_ctx->sapsMachine != eSAP_STARTED) {
1623 hddLog(LOG1, FL("SAP is not in eSAP_STARTED state"));
1624 return;
1625 }
1626
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301627 chan_state = vos_nv_getChannelEnabledState(sap_ctx->channel);
1628
1629 hddLog(LOG1, "SAP is operating on channel (%hu), chan_state %d",
1630 sap_ctx->channel, chan_state);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301631 if (vos_nv_getChannelEnabledState(sap_ctx->channel) !=
1632 NV_CHANNEL_DFS) {
1633 hddLog(LOG1, "SAP is on non DFS channel. nothing to do");
1634 return;
1635 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301636
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301637 hddLog(LOG1, "Schedule workqueue to move the SAP to non DFS channel");
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301638 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
1639 msecs_to_jiffies(ECSA_DFS_CHAN_CHANGE_DEFER_TIME));
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301640 }
1641}
Jeff Johnson295189b2012-06-20 16:38:30 -07001642
1643static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1644 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1645 eCsrRoamResult roamResult )
1646{
1647 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07001648 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 struct net_device *dev = pAdapter->dev;
1650 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1651 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -07001652 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301653 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001654
1655 // Sanity check
1656 if(dev == NULL)
1657 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301658 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001659 "%s: net_dev is released return", __func__);
1660 return eHAL_STATUS_FAILURE;
1661 }
1662
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301664 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 netif_tx_disable(dev);
1666 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301667 //TxTimeoutCount need to reset in case of disconnect handler
1668 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001669
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301670 wlan_hdd_check_and_stop_mon(pAdapter, false);
1671
Jeff Johnsone7245742012-09-05 17:12:55 -07001672 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301673 /* If only STA mode is on */
1674 if((pHddCtx->concurrency_mode <= 1) &&
1675 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1676 {
1677 pHddCtx->isAmpAllowed = VOS_TRUE;
1678 }
1679
Agarwal Ashish47d18112014-08-04 19:55:07 +05301680 /* Need to apply spin lock before decreasing active sessions
1681 * as there can be chance for double decrement if context switch
1682 * Calls wlan_hdd_disconnect.
1683 */
1684
1685 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301686
1687 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301688 * to kernel. Sending disconnected event to kernel for userspace
1689 * initiated disconnect will be handled by diconnect handler call
1690 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301691 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301692 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301693 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) ||
1694 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301695 {
1696 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1697 FL(" HDD has initiated a disconnect, no need to send"
1698 " disconnect indication to kernel"));
1699 sendDisconInd = FALSE;
1700 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301701 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301704 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301705 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301706 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1707 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301709 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh78c691f2017-11-30 13:48:44 +05301710 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001712
1713 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001714
1715 // indicate 'disconnect' status to wpa_supplicant...
1716 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 /* indicate disconnected event to nl80211 */
1718 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1719 {
1720 /*During the WLAN uninitialization,supplicant is stopped before the
1721 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301722 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301724 if (sendDisconInd)
1725 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1726 "%s: sent disconnected event to nl80211",
1727 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001728#ifdef WLAN_FEATURE_P2P_DEBUG
1729 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1730 {
1731 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1732 {
1733 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1734 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1735 "and moved to disconnected state");
1736 }
1737 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1738 {
1739 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1740 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1741 "and moved to inactive state");
1742 }
1743 }
1744#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301745 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1746 !pRoamInfo->reasonCode)
1747 wlan_hdd_get_frame_logs(pAdapter,
1748 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301749 /*Only send indication to kernel if not initiated by kernel*/
1750 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301752 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1753 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1754 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301755 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1756 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301757 }
1758 else
1759 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301760 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301761 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301764
1765 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1766 {
1767 hddLog(LOG1,
1768 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1769 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301770 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301771
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 //If the Device Mode is Station
1773 // and the P2P Client is Connected
1774 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001775
1776 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001777 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001778 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 {
1780 //Enable BMPS only of other Session is P2P Client
1781 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001782 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001783
1784 if (NULL != pVosContext)
1785 {
1786 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1787
1788 if(NULL != pHddCtx)
1789 {
1790 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301791 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1792 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301794 if (pHddCtx->hdd_wlan_suspended)
1795 {
1796 hdd_set_pwrparams(pHddCtx);
1797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 }
1801 }
1802 }
1803 }
1804 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001805
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301806 hdd_wmm_adapter_clear(pAdapter);
Kapil Guptae6867482016-06-26 13:31:37 +05301807 /* Clear PER based roam stats */
1808#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1809 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1810 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1811 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1812 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1813 sme_unset_per_roam_rxconfig(pHddCtx->hHal);
1814#endif
Mukul Sharmac159c432014-01-15 15:42:46 +05301815#if defined(WLAN_FEATURE_VOWIFI_11R)
1816 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1817#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301818
1819 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1820 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301821 v_U8_t i;
1822
Katya Nigam63ce1772014-09-26 15:53:49 +05301823 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301824 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301825 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1826 {
1827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301828 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1829 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301830 sta_id, status, status );
1831
1832 status = eHAL_STATUS_FAILURE;
1833 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301834 pHddCtx->sta_to_adapter[sta_id] = NULL;
1835
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301836 /*Clear all the peer sta register with TL.*/
1837 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1838 {
1839 if (0 != pHddStaCtx->conn_info.staId[i])
1840 {
1841 sta_id = pHddStaCtx->conn_info.staId[i];
1842
1843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1844 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301845 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301846 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1847 {
1848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1849 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1850 "Status= %d [0x%x]"),
1851 sta_id, status, status );
1852 status = eHAL_STATUS_FAILURE;
1853 }
1854
Nirav Shah7e3c8132015-06-22 23:51:42 +05301855 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1856 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1857 if (vstatus != VOS_STATUS_SUCCESS) {
1858 hddLog(VOS_TRACE_LEVEL_ERROR,
1859 FL("Not able to remove staid hash %d"),
1860 sta_id);
1861 status = eHAL_STATUS_FAILURE;
1862 } else {
1863 hddLog(VOS_TRACE_LEVEL_INFO,
1864 FL("ibss station removed sta_id %d mac:"
1865 MAC_ADDRESS_STR), sta_id,
1866 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1867 }
1868
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301869 /*set the staid and peer mac as 0, all other reset are
1870 * done in hdd_connRemoveConnectInfo.
1871 */
1872 pHddStaCtx->conn_info.staId[i]= 0;
1873 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1874
1875 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1876 pHddCtx->sta_to_adapter[sta_id] = NULL;
1877 }
1878 }
1879
Katya Nigam63ce1772014-09-26 15:53:49 +05301880 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301881 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301883 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301884 /* clear scan cache for Link Lost */
1885 if (pRoamInfo && !pRoamInfo->reasonCode &&
1886 (eCSR_ROAM_LOSTLINK == roamStatus)) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05301887 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301888 pHddStaCtx->conn_info.bssId);
1889 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1890 pHddStaCtx->conn_info.bssId);
1891 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301892
1893 //We should clear all sta register with TL, for now, only one.
1894 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1895 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1896 {
1897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1898 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1899 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001900 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001901
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301902 status = eHAL_STATUS_FAILURE;
1903 }
1904
1905 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301907
1908#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1909 if (VOS_STATUS_SUCCESS !=
1910 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1911 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1912 {
1913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1914 "WLANTL_ClearInterfaceStats Failed", __func__);
1915 }
1916 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1917 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1918 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1919 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1920#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Sravan Kumar Kairamf9f95122017-01-18 20:54:05 +05301921 pAdapter->dad = false;
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301922
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 // Clear saved connection information in HDD
1924 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301925
1926 /*
1927 * eConnectionState_Connecting state mean that connection is in progress so
1928 * no need to set state to eConnectionState_NotConnected
1929 */
1930 if ((eConnectionState_Connecting != pHddStaCtx->conn_info.connState)) {
1931 hddLog(LOG1, FL("Set HDD connState to eConnectionState_NotConnected"));
1932 hdd_connSetConnectionState(pHddStaCtx, eConnectionState_NotConnected);
1933 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301934#ifdef WLAN_FEATURE_GTK_OFFLOAD
1935 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1936 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1937 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301938 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1939 sizeof (tSirGtkOffloadParams));
1940 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301941 }
1942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001943
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001944#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001945 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1946 {
1947 wlan_hdd_tdls_disconnection_callback(pAdapter);
1948 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001949#endif
1950
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 //Unblock anyone waiting for disconnect to complete
1952 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301953 hdd_print_bss_info(pHddStaCtx);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301954
1955 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 return( status );
1957}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301958
1959static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1960 v_U8_t staId)
1961{
1962 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1963 v_SINT_t i;
1964 v_SIZE_t size;
1965 VOS_STATUS status;
1966 v_BOOL_t granted = VOS_FALSE;
1967
1968 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1969 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1970 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1971 {
1972 //Indicate to TL that there is pending data if a queue is non empty
1973 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1974 {
1975 size = 0;
1976 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1977 if (size > 0)
1978 {
1979 if (i != WLANTL_AC_HIGH_PRIO)
1980 {
1981 if (VOS_FALSE ==
1982 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1983 {
1984 hdd_wmm_acquire_access(pAdapter,
1985 (WLANTL_ACEnumType)i, &granted);
1986 pAdapter->psbChanged |= (1 << i);
1987 }
1988 else
1989 granted = VOS_TRUE;
1990 }
1991
1992 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1993 {
1994 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1995 staId, (WLANTL_ACEnumType)i);
1996 if (!VOS_IS_STATUS_SUCCESS(status))
1997 {
1998 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1999 "%s: Failure in indicating pkt to TL for QID=%d",
2000 __func__, i);
2001 }
2002 }
2003 }
2004 }
2005 }
2006}
2007
Jeff Johnson295189b2012-06-20 16:38:30 -07002008static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
2009 tCsrRoamInfo *pRoamInfo,
2010 v_U8_t staId,
2011 v_MACADDR_t *pPeerMacAddress,
2012 tSirBssDescription *pBssDesc )
2013{
2014 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2015 WLAN_STADescType staDesc = {0};
2016 eCsrEncryptionType connectedCipherAlgo;
2017 v_BOOL_t fConnected;
2018 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2019 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002020 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002021
2022 if ( NULL == pBssDesc)
2023 {
2024 return VOS_STATUS_E_FAILURE;
2025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 // Get the Station ID from the one saved during the assocation.
2027 staDesc.ucSTAId = staId;
2028
Katya Nigam47528772015-02-11 12:24:49 +05302029 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002030
Katya Nigam47528772015-02-11 12:24:49 +05302031 // grab the bssid from the connection info in the adapter structure and hand that
2032 // over to TL when registering.
2033 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
2034 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002035
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2037
2038 // set the QoS field appropriately
2039 if (hdd_wmm_is_active(pAdapter))
2040 {
2041 staDesc.ucQosEnabled = 1;
2042 }
2043 else
2044 {
2045 staDesc.ucQosEnabled = 0;
2046 }
2047
2048 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2049 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
2050 {
2051 staDesc.ucProtectedFrame = 1;
2052 }
2053 else
2054 {
2055 staDesc.ucProtectedFrame = 0;
2056
2057 }
2058
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002059#ifdef FEATURE_WLAN_ESE
2060 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
2061#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002062
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 /* check whether replay check is valid for the station or not */
2064 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
2065 {
2066 /* Encryption mode is either TKIP or AES
2067 and replay check is valid for only these
2068 two encryption modes */
2069 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2070 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2071 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
2072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 else
2074 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002075 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002077 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2079 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
2080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002081
2082#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002083 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 if (pAdapter->wapi_info.fIsWapiSta)
2085 {
2086 staDesc.ucIsWapiSta = 1;
2087 }
2088 else
2089 {
2090 staDesc.ucIsWapiSta = 0;
2091 }
2092#endif /* FEATURE_WLAN_WAPI */
2093
2094 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2095 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
2096
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 // UMA is Not ready yet, Xlation will be done by TL
2098 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 staDesc.ucSwFrameRXXlation = 1;
2100 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002101 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 staDesc.ucQosEnabled );
2103 // Initialize signatures and state
2104 staDesc.ucUcastSig = pRoamInfo->ucastSig;
2105 staDesc.ucBcastSig = pRoamInfo->bcastSig;
2106 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
2107 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002108 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08002109 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 -07002110 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
2111 hdd_rx_packet_cbk,
2112 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07002113 hdd_tx_fetch_packet_cbk, &staDesc,
2114 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002115
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2117 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002119 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002121 return vosStatus;
2122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002123
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002124 if ( cfg_param->dynSplitscan &&
2125 ( VOS_TIMER_STATE_RUNNING !=
2126 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
2127 {
2128 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2129 cfg_param->trafficMntrTmrForSplitScan);
2130 }
2131
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302132 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
2133 // then go to 'authenticated'. For all other authentication types
2134 // (those that donot require upper layer authentication) we can put
2135 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002136 if (staDesc.wSTAType != WLAN_STA_IBSS)
2137 VOS_ASSERT( fConnected );
2138
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302139 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002140 {
2141 // Connections that do not need Upper layer auth, transition TL directly
2142 // to 'Authenticated' state.
2143 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
2144 WLANTL_STA_AUTHENTICATED );
2145
2146 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302147
2148 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002149 }
2150 else
2151 {
2152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302153 "ULA auth StaId= %d. Changing TL state to CONNECTED"
2154 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002155 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05302156 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002157 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 return( vosStatus );
2160}
2161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
2163 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
2164{
2165 unsigned int len = 0;
2166 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002167 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 tANI_U32 rspRsnLength = 0;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302169 struct cfg80211_bss* bss;
2170 tCsrRoamConnectedProfile roam_profile;
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 struct ieee80211_channel *chan;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302172 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002173
Agarwal Ashish51325b52014-06-16 16:50:49 +05302174 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002175 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07002176 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002177 }
2178
Agarwal Ashish51325b52014-06-16 16:50:49 +05302179 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002180 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
2181 goto done;
2182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002183
Agarwal Ashish51325b52014-06-16 16:50:49 +05302184 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002185 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
2186 goto done;
2187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002188
2189 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2190 pCsrRoamInfo->nAssocReqLength);
2191 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002192 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002193
2194 //pFTAssocRsp needs to point to the IEs
2195 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002196 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 (unsigned int)pFTAssocRsp[0],
2198 (unsigned int)pFTAssocRsp[1]);
2199
2200 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08002201 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002204 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002205
Abhishek Singh5a597e62016-12-05 15:16:30 +05302206 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
2207 (int) pCsrRoamInfo->pBssDesc->channelId);
2208 vos_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
2209 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roam_profile);
2210 bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2211 chan, pCsrRoamInfo->bssid,
2212 &roam_profile.SSID.ssId[0],
2213 roam_profile.SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302214 hdd_send_roamed_ind(dev, bss,
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 reqRsnIe, reqRsnLength,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302216 rspRsnIe, rspRsnLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002217
2218done:
2219 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07002220}
Jeff Johnson295189b2012-06-20 16:38:30 -07002221
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302222void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
2223{
2224 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2225 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2226 tCsrRoamInfo roamInfo;
2227 roamInfo.fAuthRequired = FALSE;
2228 vos_mem_copy(roamInfo.bssid,
2229 pHddStaCtx->roam_info.bssid,
2230 WNI_CFG_BSSID_LEN);
2231 vos_mem_copy(roamInfo.peerMac,
2232 pHddStaCtx->roam_info.peerMac,
2233 WNI_CFG_BSSID_LEN);
2234
2235 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
2236 &roamInfo,
2237 pHddStaCtx->roam_info.roamId,
2238 pHddStaCtx->roam_info.roamStatus,
2239 eCSR_ROAM_RESULT_AUTHENTICATED);
2240 if (halStatus != eHAL_STATUS_SUCCESS)
2241 {
2242 hddLog(LOGE, "%s: Set Key complete failure", __func__);
2243 }
2244 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
2245}
2246
Abhishek Singh78c691f2017-11-30 13:48:44 +05302247/**
2248 * hdd_schedule_ecsa_chan_change_work() - schedule ecsa chan change work
2249 * @hal: hal context
2250 * @sta_session_id: sta session id
2251 *
2252 * Return: void.
2253 */
2254static void
2255hdd_schedule_ecsa_chan_change_work(hdd_context_t *hdd_ctx,
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302256 uint8_t sta_session_id)
Abhishek Singh78c691f2017-11-30 13:48:44 +05302257{
2258 v_TIME_t conn_start_time;
2259 int32_t time_diff;
2260
2261 conn_start_time = sme_get_connect_strt_time(hdd_ctx->hHal, sta_session_id);
2262 time_diff = vos_timer_get_system_time() - conn_start_time;
2263
2264 if (time_diff < 0)
2265 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL;
2266 else if (time_diff > ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL)
2267 time_diff = 0;
2268 else
2269 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL - time_diff;
2270
2271 hddLog(LOG1, FL("schedule ecsa_chan_change_work after %d ms"), time_diff);
2272 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
2273 msecs_to_jiffies(time_diff));
2274}
2275
Shailender Karmuchia734f332013-04-19 14:02:48 -07002276static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2277 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 eCsrRoamResult roamResult )
2279{
2280 struct net_device *dev = pAdapter->dev;
2281 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2282 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302283 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05302284 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002285 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2286 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002287#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 int ft_carrier_on = FALSE;
2289#endif
2290 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302291 v_BOOL_t hddDisconInProgress = FALSE;
2292
2293 /* HDD has initiated disconnect, do not send connect result indication
2294 * to kernel as it will be handled by __cfg80211_disconnect.
2295 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05302296 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
2297 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
2298 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2299 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302300 {
2301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2302 FL(" Disconnect from HDD in progress "));
2303 hddDisconInProgress = TRUE;
2304 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002305
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
2307 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302308 if ( !hddDisconInProgress )
2309 {
2310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05302311 "%s: Set HDD connState to eConnectionState_Associated",
2312 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302313 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
2314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002315
c_hpothu44ff4e02014-05-08 00:13:57 +05302316 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 // Save the connection info from CSR...
2318 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05302319
2320#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2321 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
2322 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
2323 !hddDisconInProgress &&
2324 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
2325 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
2326 sme_set_per_roam_rxconfig(pHddCtx->hHal,
2327 pHddStaCtx->conn_info.staId[0],
2328 pHddCtx->cfg_ini->rateDownThreshold,
2329 pHddCtx->cfg_ini->rateUpThreshold,
2330 pHddCtx->cfg_ini->PERroamTriggerPercent,
2331 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
2332 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
2333#endif
2334
Jeff Johnson295189b2012-06-20 16:38:30 -07002335#ifdef FEATURE_WLAN_WAPI
2336 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
2337 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
2338 {
2339 pAdapter->wapi_info.fIsWapiSta = 1;
2340 }
2341 else
2342 {
2343 pAdapter->wapi_info.fIsWapiSta = 0;
2344 }
2345#endif /* FEATURE_WLAN_WAPI */
2346
2347 // indicate 'connect' status to userspace
2348 hdd_SendAssociationEvent(dev,pRoamInfo);
2349
2350
Shailender Karmuchia734f332013-04-19 14:02:48 -07002351 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 INIT_COMPLETION(pAdapter->linkup_event_var);
2353
2354 /*
2355 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
2356 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 -07002357 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 know that the device is getting activated properly.
2359 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002360#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05302361 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 {
2363#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002364 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 pAdapter->isLinkUpSvcNeeded = TRUE;
2366
Shailender Karmuchia734f332013-04-19 14:02:48 -07002367 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 pAdapter->isLinkUpSvcNeeded = TRUE;
2369
2370 // Switch on the Carrier to activate the device
2371 netif_carrier_on(dev);
2372
2373 // Wait for the Link to up to ensure all the queues are set properly by the kernel
2374 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
2375 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002376 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 {
2378 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
2379 }
2380
2381 // Disable Linkup Event Servicing - no more service required from the net device notifier call
2382 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002383#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002385 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 }
2389#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05302390 /* Check for STAID */
2391 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
2392 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2393 else
2394 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002395
2396 //For reassoc, the station is already registered, all we need is to change the state
2397 //of the STA in TL.
2398 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05302399 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 if( !pRoamInfo->fReassocReq )
2401 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002402 struct cfg80211_bss *bss;
2403#ifdef WLAN_FEATURE_VOWIFI_11R
2404 u8 *pFTAssocRsp = NULL;
2405 unsigned int assocRsplen = 0;
2406 u8 *pFTAssocReq = NULL;
2407 unsigned int assocReqlen = 0;
2408 struct ieee80211_channel *chan;
2409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002412
2413 /* add bss_id to cfg80211 data base */
2414 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2415 if (NULL == bss)
2416 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302417 hddLog(LOGE,
2418 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05302419 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302420 if (!hddDisconInProgress) {
2421 /*
2422 * Here driver was not able to update cfg80211 database
2423 * this can happen if connected channel is not valid,
2424 * i.e reg domain was changed during connection.
2425 * Queue disconnect for the session if disconnect is
2426 * not in progress.
2427 */
2428 hddLog(LOGE, FL("Disconnecting..."));
2429 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2430 pAdapter->sessionId,
2431 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 return eHAL_STATUS_FAILURE;
2434 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002435#ifdef WLAN_FEATURE_VOWIFI_11R
2436 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002437 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002439
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002440 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07002441 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002442 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002443 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002444 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002445 // pFTAssocRsp needs to point to the IEs
2446 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2447 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
2448 (unsigned int)pFTAssocRsp[0],
2449 (unsigned int)pFTAssocRsp[1]);
2450 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002451 }
2452 else
2453 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002454 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
2455 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002456 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002457
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002458 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07002459 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002460 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002461 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002462 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002463 if(!ft_carrier_on)
2464 {
2465 // pFTAssocReq needs to point to the IEs
2466 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
2467 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
2468 (unsigned int)pFTAssocReq[0],
2469 (unsigned int)pFTAssocReq[1]);
2470 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
2471 }
2472 else
2473 {
2474 /* This should contain only the FTIEs */
2475 assocReqlen = pRoamInfo->nAssocReqLength;
2476 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002477 }
2478 else
2479 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002480 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
2481 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002482 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002483
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002484 if(ft_carrier_on)
2485 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302486 if ( !hddDisconInProgress )
2487 {
Abhishek Singh5a597e62016-12-05 15:16:30 +05302488 struct cfg80211_bss *roam_bss;
2489
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302490 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002491 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302492 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002493 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302494 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002495 assocRsplen);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302496 if (pHddCtx->cfg_ini &&
2497 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302498 {
2499 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2500 }
Abhishek Singh5a597e62016-12-05 15:16:30 +05302501 roam_bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2502 chan, pRoamInfo->bssid,
2503 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2504 pRoamInfo->u.pConnectedProfile->SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302505 hdd_send_roamed_ind(dev, roam_bss,
Abhishek Singh5a597e62016-12-05 15:16:30 +05302506 pFTAssocReq, assocReqlen,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302507 pFTAssocRsp, assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302508 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302509 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2510 {
2511 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
2512 pRoamInfo->fAuthRequired = FALSE;
2513
2514 vos_mem_copy(pHddStaCtx->roam_info.bssid,
2515 pRoamInfo->bssid,
2516 HDD_MAC_ADDR_LEN);
2517 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
2518 pRoamInfo->peerMac,
2519 HDD_MAC_ADDR_LEN);
2520 pHddStaCtx->roam_info.roamId = roamId;
2521 pHddStaCtx->roam_info.roamStatus = roamStatus;
2522 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
2523 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002524 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302525 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002526 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002527 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002528 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302529 hdd_connect_result(dev, pRoamInfo->bssid, pRoamInfo,
2530 pFTAssocReq, assocReqlen,
2531 pFTAssocRsp, assocRsplen,
2532 WLAN_STATUS_SUCCESS,
2533 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002534 }
2535 }
2536 else
2537#endif
2538 {
2539 /* wpa supplicant expecting WPA/RSN IE in connect result */
2540 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2541 pAdapter->sessionId,
2542 &reqRsnLength,
2543 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002544
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002545 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2546 pAdapter->sessionId,
2547 &rspRsnLength,
2548 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302549 if ( !hddDisconInProgress )
2550 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002551#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302552 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05302553 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302554 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302555 if (pHddCtx->cfg_ini &&
2556 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302557 {
2558 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2559 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302560 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302561 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002562#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002563
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302564 {
2565 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302566 "%s: sending connect indication to nl80211:"
2567 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302568 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302569 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
2570 roamResult, roamStatus);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302571 /* inform connect result to nl80211 */
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302572 hdd_connect_result(dev, pRoamInfo->bssid,
2573 pRoamInfo,
2574 reqRsnIe, reqRsnLength,
2575 rspRsnIe, rspRsnLength,
2576 WLAN_STATUS_SUCCESS,
2577 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302578 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302581 if ( !hddDisconInProgress )
2582 {
2583 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07002584#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302585 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07002586#endif
2587 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302588 // Register the Station with TL after associated...
2589 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 pRoamInfo,
2591 pHddStaCtx->conn_info.staId[ 0 ],
2592 NULL,
2593 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 }
2596 else
2597 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002598 /* wpa supplicant expecting WPA/RSN IE in connect result */
2599 /* in case of reassociation also need to indicate it to supplicant */
2600 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2601 pAdapter->sessionId,
2602 &reqRsnLength,
2603 reqRsnIe);
2604
2605 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302607 if( pRoamInfo->fAuthRequired )
2608 {
2609 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2610 pHddStaCtx->conn_info.staId[ 0 ],
2611 WLANTL_STA_CONNECTED );
2612 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2613 }
2614 else
2615 {
2616 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2617 "%s: staId: %d Changing TL state to AUTHENTICATED",
2618 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
2619 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2620 pHddStaCtx->conn_info.staId[ 0 ],
2621 WLANTL_STA_AUTHENTICATED );
2622 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302623 hdd_postTLPacketPendingInd(pAdapter,
2624 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 }
2627
2628 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
2629 {
2630 // perform any WMM-related association processing
2631 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
2632 }
2633 else
2634 {
2635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002636 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 vosStatus, vosStatus );
2638 }
Chet Lanctot186b5732013-03-18 10:26:30 -07002639#ifdef WLAN_FEATURE_11W
2640 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
2641 sizeof(pAdapter->hdd_stats.hddPmfStats) );
2642#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302643
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05302645 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302646 {
2647 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05302648 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302649 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302650 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302651 {
2652 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
2653 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05302654#ifdef FEATURE_WLAN_TDLS
2655 wlan_hdd_tdls_connection_callback(pAdapter);
2656#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002657 }
2658 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2661
2662 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002663 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302664 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2665 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
2666 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002667 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302668 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2669 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08002670 MAC_ADDR_ARRAY(pWextState->req_bssId),
2671 roamResult, roamStatus);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302672 if (!pHddStaCtx->get_mgmt_log_sent) {
2673 pHddStaCtx->get_mgmt_log_sent = TRUE;
Abhishek Singh611295e2015-07-09 11:11:54 +05302674 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302675 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302676 }
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302677
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302678 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2679 (pRoamInfo &&
2680 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2681 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2682 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05302683 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302684 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2685 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2686 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2687 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05302688 /* Set connection state to eConnectionState_NotConnected only when CSR
2689 * has completed operation - with a ASSOCIATION_FAILURE status
2690 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302691 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05302692 {
2693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2694 "%s: Set HDD connState to eConnectionState_NotConnected",
2695 __func__);
2696 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
2697 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05302698 if((pHddCtx->concurrency_mode <= 1) &&
2699 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 {
2701 pHddCtx->isAmpAllowed = VOS_TRUE;
2702 }
2703
2704 //If the Device Mode is Station
2705 // and the P2P Client is Connected
2706 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07002707
2708 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07002709 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002710 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2711 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302712 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 {
2714 //Enable BMPS only of other Session is P2P Client
2715 hdd_context_t *pHddCtx = NULL;
2716 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2717
2718 if (NULL != pVosContext)
2719 {
2720 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2721
2722 if(NULL != pHddCtx)
2723 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302724 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302725 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2726 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302727 {
2728 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002729 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302730 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002731 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302732 hdd_enable_bmps_imps(pHddCtx);
2733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 }
2735 }
2736 }
2737
James Zmudafbf5ffc2013-03-25 12:45:35 -07002738 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002739 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302740 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002741 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302742
2743 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2744 {
2745 hddLog(LOG1,
2746 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2747 wlan_hdd_tdls_reenable(pHddCtx);
2748 }
2749
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302750 if (pRoamInfo) {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302751 hddLog(VOS_TRACE_LEVEL_ERROR,
2752 "%s: send connect failure to nl80211:"
2753 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302754 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302755 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302756 roamResult, roamStatus, pRoamInfo->reasonCode);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302757 pHddStaCtx->conn_info.assoc_status_code =
2758 pRoamInfo->statusCode;
2759 } else {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302760 hddLog(VOS_TRACE_LEVEL_ERROR,
2761 "%s: connect failed:"
2762 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302763 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302764 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2765 roamResult, roamStatus);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302766 }
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302767
James Zmudafbf5ffc2013-03-25 12:45:35 -07002768 /* inform association failure event to nl80211 */
2769 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2770 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002771 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302772 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002773 NULL, 0, NULL, 0,
2774 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302775 GFP_KERNEL);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002776 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302777 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002778 NULL, 0, NULL, 0,
2779 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302780 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002781 }
2782 else
2783 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002784 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302785 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002786 NULL, 0, NULL, 0,
2787 pRoamInfo->reasonCode ?
2788 pRoamInfo->reasonCode :
2789 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302790 GFP_KERNEL);
Gao Wu6ca73b32016-05-09 14:35:49 +08002791 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302792 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002793 NULL, 0, NULL, 0,
2794 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302795 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002796 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302797 /*Clear the roam profile*/
2798 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002800
Kumar Anand82c009f2014-05-29 00:29:42 -07002801 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002802
c_hpothu24f40982014-04-18 18:00:36 +05302803 if (pRoamInfo)
2804 {
2805 WLANTL_AssocFailed(pRoamInfo->staId);
2806 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302807
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302808 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 netif_tx_disable(dev);
2810 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002811
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 }
2813
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302814 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302815 {
2816 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2817 if (pHostapdAdapter != NULL)
2818 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302819 /* Restart SAP if its operating channel is different
2820 * from AP channel.
2821 */
2822 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2823 (int)pRoamInfo->pBssDesc->channelId)
2824 {
2825 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2826 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2827 (int)pRoamInfo->pBssDesc->channelId);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302828 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->force_scc_with_ecsa)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302829 {
Abhishek Singh78c691f2017-11-30 13:48:44 +05302830 hdd_schedule_ecsa_chan_change_work(pHddCtx,
2831 pAdapter->sessionId);
2832 }
2833 else
2834 {
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302835 hdd_hostapd_stop(pHostapdAdapter->dev);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302836 if (pHddCtx->cfg_ini &&
2837 pHddCtx->cfg_ini->enable_sap_auth_offload)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302838 hdd_force_scc_restart_sap(pHostapdAdapter,
2839 pHddCtx, (int)pRoamInfo->pBssDesc->channelId);
2840 }
Agrawal Ashish574b3e62017-02-09 18:58:34 +05302841
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302842 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302843 }
2844 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302845 else if (roamStatus == eCSR_ROAM_ASSOCIATION_FAILURE)
2846 {
2847 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
2848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 return eHAL_STATUS_SUCCESS;
2850}
2851
2852/**============================================================================
2853 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002854 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002856
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002858static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2859 tCsrRoamInfo *pRoamInfo,
2860 tANI_U32 roamId,
2861 eRoamCmdStatus roamStatus,
2862 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002863{
Katya Nigam47528772015-02-11 12:24:49 +05302864 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2865 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2866 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302867 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302868
Jeff Johnson81c17882013-05-03 09:53:35 -07002869 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2870 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2871
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 switch( roamResult )
2873 {
2874 // both IBSS Started and IBSS Join should come in here.
2875 case eCSR_ROAM_RESULT_IBSS_STARTED:
2876 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002877 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002879 if (NULL == pRoamInfo)
2880 {
2881 VOS_ASSERT(0);
2882 return;
2883 }
2884
2885 /* When IBSS Started comes from CSR, we need to move
2886 * connection state to IBSS Disconnected (meaning no peers
2887 * are in the IBSS).
2888 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2890 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2891 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002892 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2893 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302894 /*notify wmm */
2895 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002896 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002897
Jeff Johnson81c17882013-05-03 09:53:35 -07002898 if (pRoamInfo->pBssDesc)
2899 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302900#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2901 struct ieee80211_channel *chan;
2902 int chan_no;
2903 unsigned int freq;
2904#endif
Katya Nigam47528772015-02-11 12:24:49 +05302905 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2906 IBSS_BROADCAST_STAID,
2907 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002908
2909 /* we created the IBSS, notify supplicant */
2910 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2911 MAC_ADDRESS_STR,
2912 __func__, pAdapter->dev->name,
2913 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2914
2915 /* we must first give cfg80211 the BSS information */
2916 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2917 if (NULL == bss)
2918 {
2919 hddLog(VOS_TRACE_LEVEL_ERROR,
2920 "%s: %s: unable to create IBSS entry",
2921 __func__, pAdapter->dev->name);
2922 return;
2923 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302924#ifdef WLAN_FEATURE_RMC
2925 netif_carrier_on(pAdapter->dev);
2926 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2927 netif_tx_start_all_queues(pAdapter->dev);
2928#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302929#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2930 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002931
Anand N Sunkadfec40682015-07-29 09:51:17 +05302932 if (chan_no <= 14)
2933 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302934 HDD_NL80211_BAND_2GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302935 else
2936 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302937 HDD_NL80211_BAND_5GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302938
2939 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2940
2941 if (chan)
2942 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2943 chan, GFP_KERNEL);
2944 else
2945 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2946 pAdapter->dev->name,
2947 (int)pRoamInfo->pBssDesc->channelId);
2948#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002949 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302950#endif
Yue Maf49ba872013-08-19 12:04:25 -07002951 cfg80211_put_bss(
2952#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2953 pHddCtx->wiphy,
2954#endif
2955 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002956 }
Katya Nigam47528772015-02-11 12:24:49 +05302957 else
2958 {
2959 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2960 "%s: NULL Bss Desc",__func__);
2961 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302962
2963 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2964 * in IBSS_COALESCED will remove the BC key.
2965 */
2966 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2967 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2968 == pHddStaCtx->ibss_enc_key.encType
2969 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2970 == pHddStaCtx->ibss_enc_key.encType
2971 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2972 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2973 {
2974 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2975 VOS_STATUS vosStatus;
2976
2977 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2978
2979 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2980 grpmacaddr, WNI_CFG_BSSID_LEN);
2981 hddLog(VOS_TRACE_LEVEL_INFO,
2982 FL(" SET GTK in case of COALESCED"));
2983 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2984 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2985 if ( VOS_STATUS_SUCCESS != vosStatus )
2986 {
2987 hddLog(VOS_TRACE_LEVEL_ERROR,
2988 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2989 }
2990 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 break;
2992 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002993
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2995 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002996 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2997 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 break;
2999 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003000
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07003002 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
3003 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003005 }
3006
Jeff Johnson81c17882013-05-03 09:53:35 -07003007 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003008}
3009
3010/**============================================================================
3011 *
3012 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
3013 This information is passed to iwconfig later. The peer that joined
3014 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003015 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003017
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05303019static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07003020{
3021 int fSuccess = FALSE;
3022 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303023 VOS_STATUS status;
3024 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003025
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3027 {
3028 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
3029 {
3030 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003031
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003033
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 fSuccess = TRUE;
3035 break;
3036 }
3037 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003038
Nirav Shah7e3c8132015-06-22 23:51:42 +05303039 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
3040 if (status != VOS_STATUS_SUCCESS) {
3041 hddLog(VOS_TRACE_LEVEL_ERROR,
3042 FL("Not able to add staid hash %d"), staId);
3043 return FALSE;
3044 }
3045
3046 hddLog(VOS_TRACE_LEVEL_INFO,
3047 FL("New station added sta_id %d mac:"
3048 MAC_ADDRESS_STR), staId,
3049 MAC_ADDR_ARRAY(peerMacAddress->bytes));
3050
Shailender Karmuchia734f332013-04-19 14:02:48 -07003051 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07003052}
3053/**============================================================================
3054 *
3055 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003056 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003058
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07003060static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003061{
3062 int fSuccess = FALSE;
3063 int idx = 0;
3064 v_U8_t valid_idx = 0;
3065 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07003066 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003067 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05303068 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003069
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3071 {
3072 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
3073 {
3074 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303075 status = hdd_sta_id_hash_remove_entry(pAdapter,
3076 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
3077 if (status != VOS_STATUS_SUCCESS) {
3078 hddLog(VOS_TRACE_LEVEL_ERROR,
3079 FL("Not able to remove staid hash %d"), staId );
3080 fSuccess = FALSE;
3081 } else {
3082 hddLog(VOS_TRACE_LEVEL_INFO,
3083 FL("station removed sta_id %d mac:"
3084 MAC_ADDRESS_STR), staId,
3085 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07003086
Nirav Shah7e3c8132015-06-22 23:51:42 +05303087 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07003088
Nirav Shah7e3c8132015-06-22 23:51:42 +05303089 fSuccess = TRUE;
3090 // Note the deleted Index, if its 0 we need special handling
3091 del_idx = idx;
3092 empty_slots++;
3093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 }
3095 else
3096 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003097 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 {
3099 valid_idx = idx;
3100 }
Ravi Joshi8a934352013-09-25 16:46:58 -07003101 else
3102 {
3103 // Found an empty slot
3104 empty_slots++;
3105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 }
3107 }
3108
Ravi Joshi8a934352013-09-25 16:46:58 -07003109 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
3110 {
3111 // Last peer departed, set the IBSS state appropriately
3112 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07003114 "Last IBSS Peer Departed!!!" );
3115 }
3116
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 // Find next active staId, to have a valid sta trigger for TL.
3118 if (fSuccess == TRUE)
3119 {
3120 if (del_idx == 0)
3121 {
3122 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
3123 {
3124 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
3125 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
3126 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
3127
3128 pHddStaCtx->conn_info.staId[valid_idx] = 0;
3129 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
3130 }
3131 }
3132 }
3133 return( fSuccess );
3134}
3135
3136/**============================================================================
3137 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003138 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003140
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 ===========================================================================*/
3142static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
3143{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003144 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05303145 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3146 "%s: IBSS Connect Indication from SME!!! "
3147 "Set HDD connState to eConnectionState_IbssConnected",
3148 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
3150 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
3151
3152 // Save the connection info from CSR...
3153 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
3154
3155 // Send the bssid address to the wext.
3156 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003158 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3159 if (NULL == bss)
3160 {
3161 hddLog(VOS_TRACE_LEVEL_ERROR,
3162 "%s: %s: unable to create IBSS entry",
3163 __func__, pAdapter->dev->name);
3164 return eHAL_STATUS_FAILURE;
3165 }
Yue Maf49ba872013-08-19 12:04:25 -07003166 cfg80211_put_bss(
3167#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3168 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
3169#endif
3170 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07003171
3172 return( eHAL_STATUS_SUCCESS );
3173}
Mukul Sharmad2589a52014-04-23 21:06:25 +05303174
3175/**============================================================================
3176 *
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003178
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003180static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3181 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 eCsrRoamResult roamResult )
3183{
3184 eCsrEncryptionType connectedCipherAlgo;
3185 v_BOOL_t fConnected = FALSE;
3186 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3187 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303188 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303190 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07003192
3193 if (NULL == pRoamInfo)
3194 {
3195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
3196 return eHAL_STATUS_FAILURE;
3197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003199 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 // not require upper layer authentication) we can put TL directly into 'authenticated'
3201 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3203 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
3204 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003205
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3207 if( fConnected )
3208 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003209 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
3210 {
3211 v_U8_t staId;
3212
3213 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
3214
3215 if ( 0 == memcmp( pRoamInfo->peerMac,
3216 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
3217 {
3218 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3219 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05303220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3221 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003222 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3223 }
3224 else
3225 {
3226 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
3227 (v_MACADDR_t*)pRoamInfo->peerMac,
3228 &staId);
3229 if ( VOS_STATUS_SUCCESS == vosStatus )
3230 {
3231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3232 "WLAN TL STA Ptk Installed for STAID=%d", staId);
3233 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3234 staId);
3235 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3236 }
3237 }
3238 }
3239 else
3240 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05303241 WLANTL_GetSTAState(pHddCtx->pvosContext,
3242 pHddStaCtx->conn_info.staId[0],
3243 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303244 // TODO: Considering getting a state machine in HDD later.
3245 // This routine is invoked twice. 1)set PTK 2)set GTK.
3246 // The folloing if statement will be TRUE when setting GTK.
3247 // At this time we don't handle the state in detail.
3248 // Related CR: 174048 - TL not in authenticated state
3249 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
3250 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
3251 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303252
3253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
3254 "for StaId=%d. Changing TL state to AUTHENTICATED from"
3255 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303256
3257 // Connections that do not need Upper layer authentication,
3258 // transition TL to 'Authenticated' state after the keys are set.
3259 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3260 pHddStaCtx->conn_info.staId[ 0 ],
3261 WLANTL_STA_AUTHENTICATED );
3262
3263 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303264
3265 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3266 hdd_postTLPacketPendingInd(pAdapter,
3267 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05303268 //Need to call offload because when roaming happen at that time fwr
3269 //clean offload info as part of the DelBss
3270 // No need to configure offload if host was not suspended
3271 spin_lock(&pHddCtx->filter_lock);
3272 if(pHddCtx->hdd_wlan_suspended)
3273 {
3274 spin_unlock(&pHddCtx->filter_lock);
3275 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
3276 }
3277 else
3278 {
3279 spin_unlock(&pHddCtx->filter_lock);
3280 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303281 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3282 {
3283 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
3284 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303285 }
3286 else
3287 {
3288 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3289 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303290
3291 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
3292 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
3293 {
3294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
3295 " for StaId=%d. Due to OSEN, Changing TL state to"
3296 "AUTHENTICATED from state:%d",
3297 pHddStaCtx->conn_info.staId[0], prevTLState);
3298
3299 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3300 pHddStaCtx->conn_info.staId[ 0 ],
3301 WLANTL_STA_AUTHENTICATED );
3302
3303 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
3304
3305 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3306 hdd_postTLPacketPendingInd(pAdapter,
3307 pHddStaCtx->conn_info.staId[0]);
3308 }
3309
3310
3311
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303312 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3313 {
3314 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
3315 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303316 }
3317
3318 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303321 else
3322 {
3323 // possible disassoc after issuing set key and waiting set key complete
3324 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3325 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003326
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 EXIT();
3328 return( eHAL_STATUS_SUCCESS );
3329}
3330/**============================================================================
3331 *
3332 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
3333 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003334static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07003336{
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3338
3339 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3340 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
3341 {
3342 struct iw_michaelmicfailure msg;
3343 union iwreq_data wreq;
3344 memset(&msg, '\0', sizeof(msg));
3345 msg.src_addr.sa_family = ARPHRD_ETHER;
3346 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08003347 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
3348 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07003349
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3351 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003352 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 msg.flags = IW_MICFAILURE_PAIRWISE;
3354 memset(&wreq, 0, sizeof(wreq));
3355 wreq.data.length = sizeof(msg);
3356 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003358 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3360 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
3361 NL80211_KEYTYPE_GROUP :
3362 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07003363 pRoamInfo->u.pMICFailureInfo->keyId,
3364 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003366
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003368
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 return( eHAL_STATUS_SUCCESS );
3370}
3371
3372/**============================================================================
3373 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003374 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003376
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003378static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3379 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 eCsrRoamResult roamResult )
3381{
3382 VOS_STATUS vosStatus;
3383
3384 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3385 switch( roamResult )
3386 {
3387 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3388 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003389 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303390 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003391
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303392 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3393 "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 -07003394 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3395 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003397
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3399
Shailender Karmuchia734f332013-04-19 14:02:48 -07003400 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
3401 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
3402 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
3403
3404 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05303405 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 pRoamInfo,
3407 pRoamInfo->staId,
3408 (v_MACADDR_t *)pRoamInfo->peerMac,
3409 pRoamInfo->pBssDesc );
3410 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3411 {
3412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003413 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 vosStatus, vosStatus );
3415 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05303416 if (!roamSaveIbssStation(pAdapter,
3417 pRoamInfo->staId,
3418 (v_MACADDR_t *)pRoamInfo->peerMac))
3419 {
3420 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
3421 break;
3422 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003423 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303424
3425 staInfo = vos_mem_malloc(sizeof(*staInfo));
3426 if (staInfo == NULL) {
3427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3428 "memory allocation for station_info failed");
3429 return eHAL_STATUS_FAILED_ALLOC;
3430 }
3431
3432 memset(staInfo, 0, sizeof(*staInfo));
3433 staInfo->filled = 0;
3434 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003435
3436 cfg80211_new_sta(pAdapter->dev,
3437 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303438 staInfo, GFP_KERNEL);
3439 vos_mem_free(staInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003440
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003441 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3442 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3443 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3444 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
3445 {
3446 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05303447
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003448 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3449 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
3450
3451 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003452 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003453 pHddStaCtx->ibss_enc_key.encType);
3454
3455 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3456 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3457
3458 if ( VOS_STATUS_SUCCESS != vosStatus )
3459 {
3460 hddLog(VOS_TRACE_LEVEL_ERROR,
3461 "%s: sme_RoamSetKey failed, returned %d",
3462 __func__, vosStatus);
3463 return VOS_STATUS_E_FAILURE;
3464 }
3465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303467 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 netif_tx_start_all_queues(pAdapter->dev);
3469 break;
3470 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003471
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3473 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003474
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003476
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3480 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003481 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003482
Ravi Joshicc57ed42013-10-12 16:31:25 -07003483 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 {
3485 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3486 "IBSS peer departed by cannot find peer in our registration table with TL" );
3487 }
3488
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303489 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3490 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003491 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3492 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
3493 pRoamInfo->staId );
3494
Katya Nigam47528772015-02-11 12:24:49 +05303495 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003496
3497 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003498 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003499
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003500 cfg80211_del_sta(pAdapter->dev,
3501 (const u8 *)&pRoamInfo->peerMac,
3502 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 break;
3504 }
3505 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3506 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
3508 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303510 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 netif_tx_disable(pAdapter->dev);
3512 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05303513 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3514 "%s: Set HDD connState to eConnectionState_NotConnected",
3515 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003517
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 // Send the bssid address to the wext.
3519 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
3520 // clean up data path
3521 hdd_disconnect_tx_rx(pAdapter);
3522 break;
3523 }
3524 default:
3525 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003526
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003528
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 return( eHAL_STATUS_SUCCESS );
3530}
3531
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003532#ifdef FEATURE_WLAN_TDLS
3533/**============================================================================
3534 *
3535 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
3536 TL the new STA. This is called as part of ADD_STA in the TDLS setup
3537 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07003538
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003539 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303540VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
3541#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3542 const tANI_U8 *peerMac,
3543#else
3544 tANI_U8 *peerMac,
3545#endif
3546 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003547{
3548 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003549 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003550 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3551 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003552 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
3553 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003554 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3555 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003556
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003557 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3558 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003559 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003560 "%s not connected. ignored", __func__);
3561 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003562 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003563
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003564 /*
3565 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3566 * be peer MAC, here we are wokrking on direct Link
3567 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003568 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003569
3570 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003571
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003572 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003573 sizeof(tSirMacAddr) );
3574
3575 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
3576 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
3577
3578 /* set the QoS field appropriately ..*/
3579 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
3580 : (staDesc.ucQosEnabled = 0) ;
3581
3582 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08003583 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003584
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003585 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003586
3587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003588 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003589
Shailender Karmuchia734f332013-04-19 14:02:48 -07003590 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003591 * UMA is ready we inform TL to do frame translation.
3592 */
3593 staDesc.ucSwFrameTXXlation = 1;
3594 staDesc.ucSwFrameRXXlation = 1;
3595 staDesc.ucAddRmvLLC = 1;
3596
3597 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003598 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003599
3600 /* tdls Direct Link do not need bcastSig */
3601 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003602
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003603 if(staDesc.ucProtectedFrame)
3604 staDesc.ucIsReplayCheckValid = VOS_TRUE;
3605 else
3606 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003607
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303608 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003609
Shailender Karmuchia734f332013-04-19 14:02:48 -07003610 /* Register the Station with TL... */
3611 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
3612 hdd_rx_packet_cbk,
3613 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003614 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003615
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003616 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3617 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003619 "%s: WLANTL_RegisterSTAClient() failed to register. "
3620 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003621 return vosStatus;
3622 }
3623
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003624 if ( cfg_param->dynSplitscan &&
3625 ( VOS_TIMER_STATE_RUNNING !=
3626 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
3627 {
3628 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
3629 cfg_param->trafficMntrTmrForSplitScan);
3630 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003631 return( vosStatus );
3632}
3633
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303634VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003635{
3636 VOS_STATUS vosStatus;
3637 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
3638 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3639 {
3640 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3641 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003642 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003643 __func__, staId, vosStatus, vosStatus );
3644 }
3645 return( vosStatus );
3646}
3647
3648
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003649/*
3650 * HDD interface between SME and TL to ensure TDLS client registration with
3651 * TL in case of new TDLS client is added and deregistration at the time
3652 * TDLS client is deleted.
3653 */
3654
Shailender Karmuchia734f332013-04-19 14:02:48 -07003655eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
3656 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003657 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07003658 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003659 eCsrRoamResult roamResult)
3660{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003661 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003662 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003663 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003664
Kaushik, Sushant8489f472014-01-27 11:41:22 +05303665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08003666 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
3667 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
3668 "ADD_TDLS_PEER" :
3669 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
3670 "DEL_TDLS_PEER" :
3671 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
3672 "DEL_TDLS_PEER_IND" :
3673 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3674 "DEL_ALL_TDLS_PEER_IND" :
3675 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
3676 "UPDATE_TDLS_PEER" :
3677 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303678 "LINK_ESTABLISH_REQ_RSP" :
3679 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
3680 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08003681 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003682 switch( roamResult )
3683 {
3684 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3685 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003686 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3687 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303688 hddTdlsPeer_t *curr_peer;
3689
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003691 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05303692 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303693
3694 mutex_lock(&pHddCtx->tdls_lock);
3695 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3696 pRoamInfo->peerMac, FALSE);
3697 if (NULL != curr_peer)
3698 curr_peer->link_status = eTDLS_LINK_TEARING;
3699 else
3700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3701 "%s %d curr_peer is Null", __func__,__LINE__);
3702 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003703 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003704 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003705 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003706
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003707 /* check if there is available index for this new TDLS STA */
3708 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3709 {
3710 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3711 {
3712 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3713 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3714
3715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003716 ("TDLS: STA IDX at %d is %d "
3717 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003718 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003719 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003720
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003721 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003722 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3723 status = eHAL_STATUS_SUCCESS ;
3724 break ;
3725 }
3726 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003727 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003728 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003729 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003730 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3731 "wlan_hdd_tdls_set_sta_id() failed");
3732 return VOS_FALSE;
3733 }
3734
3735 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303736 /* store the ucast signature , if required for further reference. */
3737
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003738 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303739 /* start TDLS client registration with TL */
3740 status = hdd_roamRegisterTDLSSTA( pAdapter,
3741 pRoamInfo->peerMac,
3742 pRoamInfo->staId,
3743 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303744 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003745 }
3746 else
3747 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003748 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003750 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003751 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003752 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003753 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003754 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003755 break ;
3756 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003757 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3758 {
3759 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3760 {
3761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3762 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3763 }
3764 /* store the ucast signature which will be used later when
3765 * registering to TL
3766 */
3767 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3768 complete(&pAdapter->tdls_add_station_comp);
3769 break;
3770 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303771 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3772 {
3773 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3774 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303775 hddTdlsPeer_t *curr_peer;
3776
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3778 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303779
3780 mutex_lock(&pHddCtx->tdls_lock);
3781 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3782 pRoamInfo->peerMac, FALSE);
3783 if (curr_peer)
3784 curr_peer->link_status = eTDLS_LINK_TEARING;
3785 else
3786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3787 "%s %d curr_peer is Null",__func__,__LINE__);
3788 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303789 }
3790 complete(&pAdapter->tdls_link_establish_req_comp);
3791 break;
3792 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303793 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3794 {
3795 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3797 "%s: Channel switch request failed. %d", __func__,
3798 pRoamInfo->statusCode);
3799 else
3800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3801 "%s: Channel switch request Success", __func__);
3802 break;
3803 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003804 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003805 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003806 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003807 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003808 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003809 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3810 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003811 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003813 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3814
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303815 mutex_lock(&pHddCtx->tdls_lock);
3816 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3817 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303818 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003819 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3821 " Current status for peer" MAC_ADDRESS_STR "is %d",
3822 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303823 if (TDLS_IS_CONNECTED(curr_peer) ||
3824 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303825 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303826 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303827 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3828 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303829 else
3830 mutex_unlock(&pHddCtx->tdls_lock);
3831
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303832 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003833 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303834 else
3835 mutex_unlock(&pHddCtx->tdls_lock);
3836
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303837 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003838 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303839 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003840
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003841 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3842 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3843 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003844 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003845 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003846 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003847 break ;
3848 }
3849 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003850 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003851 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003852 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003853 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3854 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003855 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3857 "%s: Sending teardown to supplicant with reason code %u",
3858 __func__, pRoamInfo->reasonCode);
3859
3860#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303861 mutex_lock(&pHddCtx->tdls_lock);
3862 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3863 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003864 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303865 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3866 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303867 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003868#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003869 status = eHAL_STATUS_SUCCESS ;
3870 break ;
3871 }
3872 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3873 {
3874 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003875 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003876 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003877 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3878 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003879 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003881 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003882 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003883 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303884
3885 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003886 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303887 mutex_unlock(&pHddCtx->tdls_lock);
3888
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003889 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3890 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003891
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003892 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003893 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003894 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3895 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003896
3897 status = eHAL_STATUS_SUCCESS ;
3898 }
3899 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303900 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003901 break ;
3902 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003903 default:
3904 {
3905 break ;
3906 }
3907 }
3908
3909 return status ;
3910}
3911#endif
3912
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303913void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003914{
3915 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3916 hdd_context_t *pHddCtx = NULL;
3917 int ret;
3918
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303919 ENTER();
3920
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003921 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3922 {
3923 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003924 "%s: Bad param, pAdapter [%pK]",
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003925 __func__, pAdapter);
3926 return;
3927 }
3928
3929 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3930 ret = wlan_hdd_validate_context(pHddCtx);
3931 if (0 != ret)
3932 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003933 return;
3934 }
3935
3936 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3937 {
3938 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3939 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303940
3941 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003942}
3943
Shailender Karmuchia734f332013-04-19 14:02:48 -07003944eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3946{
3947 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3948 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303949 hdd_wext_state_t *pWextState = NULL;
3950 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003951 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303952 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003953 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003954
3955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003956 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003957 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003958
3959 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303960 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003961 {
3962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303963 "invalid adapter or adapter has invalid magic");
3964 return eHAL_STATUS_FAILURE;
3965 }
3966
3967 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3968 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3969
3970 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3971 {
3972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3973 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003974 return eHAL_STATUS_FAILURE;
3975 }
3976
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303977 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3978 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 switch( roamStatus )
3980 {
3981 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303982 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3983 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003985
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003986#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3987 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003989 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 * interface down */
3991 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303992 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3993 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303994 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3996 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3997 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3999 }
4000 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05304001 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 break;
4003
4004 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004005 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07004007 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 // eCSR_ROAM_SHOULD_ROAM will be received.
4009 // Where in we will not mark the link down
4010 // Also we want to stop tx at this point when we will be
4011 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004012 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 {
4014 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304015 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05304017 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4018 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
4019 {
4020 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
4021 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004022 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304023 * Deregister this STA with TL, but do not flush the packets
4024 * for this STA from wmm_tx_queue. Since there is no valid STA
4025 * for these packets they will not be transmitted. Eventually
4026 * after the reassociation is successful, these packets will be
4027 * transmitted after registering STA with TL again. This ensures
4028 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004029 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304030 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
4031 pHddStaCtx->conn_info.staId[0]);
4032 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004033 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4035 FL("WLANTL_ClearSTAClient failed for staID %d."
4036 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
4037 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004038 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 }
4041 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004042 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 break;
4044#endif
4045
4046 case eCSR_ROAM_SHOULD_ROAM:
4047 // Dont need to do anything
4048 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 struct net_device *dev = pAdapter->dev;
4050 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4051 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304052 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004054#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 if (pHddStaCtx->ft_carrier_on == FALSE)
4056 {
4057#endif
4058 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004059#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 }
4061#endif
4062
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004063#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 //We should clear all sta register with TL, for now, only one.
4065 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
4066 if ( !VOS_IS_STATUS_SUCCESS(status ) )
4067 {
4068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4069 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
4070 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004071 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004073#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 }
4075 break;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05304076 case eCSR_ROAM_LOSTLINK_DETECTED:
4077 {
4078 if (wlan_hdd_check_and_stop_mon(pAdapter, false))
4079 halStatus = eHAL_STATUS_FAILURE;
4080 }
4081 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 case eCSR_ROAM_LOSTLINK:
4083 case eCSR_ROAM_DISASSOCIATED:
4084 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4086 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05304087 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4089 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07004090 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4091 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304092 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07004093 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08004094
4095 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
4096 pHddCtx->configuredMcastBcastFilter =
4097 pHddCtx->sus_res_mcastbcast_filter;
4098 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
4099 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304100
Amar Singhald53568e2013-09-26 11:03:45 -07004101 hddLog(VOS_TRACE_LEVEL_INFO,
4102 "offload: disassociation happening, restoring configuredMcastBcastFilter");
4103 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
4104 pHddCtx->configuredMcastBcastFilter);
4105 hddLog(VOS_TRACE_LEVEL_INFO,
4106 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4108 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004109#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304110 /* Call to clear any MC Addr List filter applied after
4111 * successful connection.
4112 */
4113 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004114#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 }
4116 break;
4117 case eCSR_ROAM_IBSS_LEAVE:
4118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4119 "****eCSR_ROAM_IBSS_LEAVE****");
4120 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4121 break;
4122 case eCSR_ROAM_ASSOCIATION_COMPLETION:
4123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4124 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304125 // To Do - address probable memory leak with WEP encryption upon successful association
4126 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304128 //Clear saved connection information in HDD
4129 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304131 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004132
4133 break;
4134 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004135 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 pRoamInfo, roamId, roamStatus, roamResult );
4137 break;
4138 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07004139 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
4140 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 break;
4142
4143 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
4144 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004146
4147 case eCSR_ROAM_MIC_ERROR_IND:
4148 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4149 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05304150 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
4151 {
4152 /*
4153 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
4154 * adding the 100 value.
4155 */
4156 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
4157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4158 "%s : Rssi on Disconnect : %d",
4159 __func__, pAdapter->rssi_on_disconnect);
4160 break;
4161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004163 {
4164 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4165
4166 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004167 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304168 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304169 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004170 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004171 /* Send DTIM period to the FW; only if the wlan is already
4172 in suspend. This is the case with roaming (reassoc),
4173 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
4174 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
4175 before the ENTER_BMPS_REQ ensures Listen Interval is
4176 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004177 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004178
4179 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004180 if due to unexpected scenario, if we are in BMPS,
4181 then trigger Exit and Enter BMPS to take DTIM period
4182 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004183 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
4184 {
4185 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
4186
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004187 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4188 iw_full_power_cbfn, pAdapter,
4189 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004190 }
4191 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304192
4193 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304194 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
4195 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304196 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304197 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304198 {
4199 hddLog( LOG1, FL("Device in full power."
4200 "Stop and start traffic timer for roaming"));
4201 pmcStopTrafficTimer(pHddCtx->hHal);
4202 if (pmcStartTrafficTimer(pHddCtx->hHal,
4203 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
4204 {
4205 hddLog(LOGP, FL("Cannot start traffic timer"));
4206 }
4207 }
4208
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004209 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304210 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304211 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304212 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 break;
4215#ifdef WLAN_FEATURE_VOWIFI_11R
4216 case eCSR_ROAM_FT_RESPONSE:
4217 hdd_SendFTEvent(pAdapter);
4218 break;
4219#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004220#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004221 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004222 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07004223 {
4224 /* Notify the supplicant of a new candidate */
4225 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
4226 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004227 break;
4228#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004229
Yue Maef608272013-04-08 23:09:17 -07004230#ifdef FEATURE_WLAN_LFR_METRICS
4231 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4232 /* This event is to notify pre-auth initiation */
4233 if (VOS_STATUS_SUCCESS !=
4234 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
4235 {
4236 halStatus = eHAL_STATUS_FAILURE;
4237 }
4238 break;
4239 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4240 /* This event will notify pre-auth completion in case of success */
4241 if (VOS_STATUS_SUCCESS !=
4242 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4243 pRoamInfo, 1))
4244 {
4245 halStatus = eHAL_STATUS_FAILURE;
4246 }
4247 break;
4248 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4249 /* This event will notify pre-auth completion in case of failure. */
4250 if (VOS_STATUS_SUCCESS !=
4251 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4252 pRoamInfo, 0))
4253 {
4254 halStatus = eHAL_STATUS_FAILURE;
4255 }
4256 break;
4257 case eCSR_ROAM_HANDOVER_SUCCESS:
4258 /* This event is to notify handover success.
4259 It will be only invoked on success */
4260 if (VOS_STATUS_SUCCESS !=
4261 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
4262 {
4263 halStatus = eHAL_STATUS_FAILURE;
4264 }
4265 break;
4266#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 case eCSR_ROAM_REMAIN_CHAN_READY:
4268 hdd_remainChanReadyHandler( pAdapter );
4269 break;
4270 case eCSR_ROAM_SEND_ACTION_CNF:
4271 hdd_sendActionCnf( pAdapter,
4272 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
4273 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004274#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08004275 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004276 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08004277 roamId, roamStatus, roamResult );
4278 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004279 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4280 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
4281 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004282#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004283#ifdef WLAN_FEATURE_11W
4284 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4285 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
4286 pRoamInfo->pbFrames,
4287 pRoamInfo->frameType);
4288 break;
4289#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004290#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004291 case eCSR_ROAM_TSM_IE_IND:
4292 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
4293 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
4294 break;
4295
4296 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4297 {
4298 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
4299 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
4300 {
4301 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
4302 }
4303 break;
4304 }
4305
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004306 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004307 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004308 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004309 break;
4310 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004311
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004312 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004313 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004314 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004315 break;
4316 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004317#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05304318 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
4319 {
4320 pAdapter->maxRateFlags = roamResult;
4321 break;
4322 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304323 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4324 if (pRoamInfo && pRoamInfo->pBssDesc) {
4325 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4326 pRoamInfo->pBssDesc);
4327 if (bss_status)
4328 cfg80211_put_bss(
4329#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4330 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4331#endif
4332 bss_status);
4333 else
4334 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
4335 }
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304336 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4337 {
4338 hdd_adapter_t *pHostapdAdapter = NULL;
4339 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4340 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4341
4342 if (!pHddCtx || !pHddStaCtx) {
4343 hddLog(LOG1, FL("Invalid pHddCtx or pHddStaCtx"));
4344 break;
4345 }
4346
4347 hddLog(LOG1, FL("eCSR_ROAM_STA_CHANNEL_SWITCH: new channel %hu"),
4348 pRoamInfo->chan_info.chan_id);
4349
4350 pHddStaCtx->conn_info.operationChannel =
4351 pRoamInfo->chan_info.chan_id;
4352
4353 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
4354 if (pHostapdAdapter &&
4355 (test_bit(SOFTAP_BSS_STARTED,
4356 &pHostapdAdapter->event_flags)))
4357 {
4358 /* Restart SAP if its operating channel is different
4359 * from AP channel.
4360 */
4361 hddLog(VOS_TRACE_LEVEL_INFO,"SAP chan %d, STA chan %d, force_scc_with_ecsa %d",
4362 pHostapdAdapter->sessionCtx.ap.operatingChannel,
4363 pRoamInfo->chan_info.chan_id,
4364 pHddCtx->cfg_ini->force_scc_with_ecsa);
4365 if ((pHddCtx->cfg_ini->force_scc_with_ecsa ) &&
4366 (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
4367 pRoamInfo->chan_info.chan_id))
4368 {
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05304369 schedule_delayed_work(&pHddCtx->ecsa_chan_change_work, 0);
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304370 }
4371 else
4372 hddLog(LOG1, FL("SAP restart not required"));
4373 } else
4374 hddLog(LOG1, FL("SAP not active, nothing to do"));
4375 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304376 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05304377 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 break;
4379 }
4380 return( halStatus );
4381}
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304382
4383#ifdef WLAN_FEATURE_SAE
4384/**
4385 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
4386 * @auth_suite: auth suite
4387 * @auth_type: pointer to eCsrAuthType
4388 *
4389 * Return: None
4390 */
4391static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4392 eCsrAuthType *auth_type)
4393{
4394 if (!memcmp(auth_suite, ccp_rsn_oui_80, 4))
4395 *auth_type = eCSR_AUTH_TYPE_SAE;
4396}
4397#else
4398static inline
4399void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4400 eCsrAuthType *auth_type)
4401{
4402}
4403#endif
4404
Shailender Karmuchia734f332013-04-19 14:02:48 -07004405eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004406{
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304407 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004409 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 {
4411 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004412 } else
4413 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 {
4415 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004416 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004417#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004418 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 {
4420 // Check for 11r FT Authentication with PSK
4421 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004422 } else
4423 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 {
4425 // Check for 11R FT Authentication with 802.1X
4426 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004427 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004428#endif
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 , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 {
4432 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4433 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004434#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07004435#ifdef WLAN_FEATURE_11W
4436 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
4437 {
4438 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4439 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304440 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
4441 {
4442 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4443 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004444#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004445 {
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304446 /* If auth suite is of SAE, auth_type will be
4447 * overwritten in hdd_translate_sae_rsn_to_csr_auth
4448 */
4449 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
4450 }
4451
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004453}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004454
Shailender Karmuchia734f332013-04-19 14:02:48 -07004455eCsrAuthType
4456hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004457{
4458 eCsrAuthType auth_type;
4459 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004460 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 {
4462 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004463 } else
4464 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 {
4466 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004467 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004468#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004469 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 {
4471 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004472 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004473#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004474 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4476 }
4477 hddLog(LOG1, FL("auth_type: %d"), auth_type);
4478 return auth_type;
4479}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004480
Shailender Karmuchia734f332013-04-19 14:02:48 -07004481eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004482hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004483{
4484 eCsrEncryptionType cipher_type;
4485 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004486 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 {
4488 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004489 }
4490 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 {
4492 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004493 }
4494 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 {
4496 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004497 }
4498 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 {
4500 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004501 }
4502 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
4503 {
4504 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4505 }
4506 else
4507 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4509 }
4510 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4511 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004512}
Jeff Johnson295189b2012-06-20 16:38:30 -07004513/* To find if the MAC address is NULL */
4514static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
4515{
4516 int i;
4517 for (i = 0; i < length; i++)
4518 {
4519 if (0x00 != (macAddr[i]))
4520 {
4521 return FALSE;
4522 }
4523 }
4524 return TRUE;
4525} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08004526
Shailender Karmuchia734f332013-04-19 14:02:48 -07004527eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004528hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004529{
4530 eCsrEncryptionType cipher_type;
4531 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004532 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 {
4534 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004535 } else
4536 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 {
4538 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004539 } else
4540 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 {
4542 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004543 } else
4544 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 {
4546 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004547 } else
4548 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004550 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4551 } else
4552 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4554 }
4555 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4556 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004557}
Jeff Johnson295189b2012-06-20 16:38:30 -07004558
Shailender Karmuchia734f332013-04-19 14:02:48 -07004559static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
4560 struct ether_addr *pBssid,
4561 eCsrEncryptionType *pEncryptType,
4562 eCsrEncryptionType *mcEncryptType,
4563 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004564#ifdef WLAN_FEATURE_11W
4565 u_int8_t *pMfpRequired,
4566 u_int8_t *pMfpCapable,
4567#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004568 u_int16_t gen_ie_len,
4569 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07004570{
4571 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004572 eHalStatus result;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304573 tDot11fIERSN dot11RSNIE = {0};
4574 tDot11fIEWPA dot11WPAIE = {0};
Shailender Karmuchia734f332013-04-19 14:02:48 -07004575 tANI_U32 i;
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304576 tANI_U32 status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004577 tANI_U8 *pRsnIe;
4578 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07004580 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581
4582 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
4583 flag to 0 */
4584 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
4585 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
4586
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07004588 if ( gen_ie[0] == DOT11F_EID_RSN)
4589 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07004591 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
4593 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304594 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
4595 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 return -EINVAL;
4597 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004598 // Skip past the EID byte and length byte
4599 pRsnIe = gen_ie + 2;
4600 RSNIeLen = gen_ie_len - 2;
4601 // Unpack the RSN IE
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304602 status = sme_unpack_rsn_ie(halHandle,
4603 pRsnIe,
4604 RSNIeLen,
4605 &dot11RSNIE);
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304606 if (DOT11F_FAILED(status))
4607 {
4608 hddLog(LOGE,
4609 FL("Parse failure in hdd_ProcessGENIE (0x%08x)"),
4610 status);
4611 return -EINVAL;
4612 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304613 hddLog(LOG1, FL("%s: gp_cipher_suite_present: %d"),
4614 __func__, dot11RSNIE.gp_cipher_suite_present);
4615
Shailender Karmuchia734f332013-04-19 14:02:48 -07004616 // Copy out the encryption and authentication types
4617 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004618 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004619 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304620 __func__, dot11RSNIE.akm_suite_cnt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004621 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 but probably I suspect we can do something different*/
4623 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07004624 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304625 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004626 //dot11RSNIE.pwise_cipher_suite_count
4627 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
4628 //dot11RSNIE.gp_cipher_suite_count
4629 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07004630#ifdef WLAN_FEATURE_11W
4631 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
4632 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
4633#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07004635 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004637 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304639 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 break;
4641 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004642 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304644 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 break;
4646 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004647 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 // For right now, I assume setASSOCIATE() has passed in the bssid.
4649 vos_mem_copy(PMKIDCache[i].BSSID,
4650 pBssid, ETHER_ADDR_LEN);
4651 vos_mem_copy(PMKIDCache[i].PMKID,
4652 dot11RSNIE.pmkid[i],
4653 CSR_RSN_PMKID_SIZE);
4654 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004655
4656 if (updatePMKCache)
4657 {
4658 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004659 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004660 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07004661 // Finally set the PMKSA ID Cache in CSR
4662 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
4663 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304664 dot11RSNIE.pmkid_count,
4665 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07004666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 }
4668 else if (gen_ie[0] == DOT11F_EID_WPA)
4669 {
4670 // Validity checks
4671 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
4672 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
4673 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304674 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
4675 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 return -EINVAL;
4677 }
4678 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07004679 pRsnIe = gen_ie + 2 + 4;
4680 RSNIeLen = gen_ie_len - (2 + 4);
4681 // Unpack the WPA IE
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304682 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304683 pRsnIe, RSNIeLen, &dot11WPAIE);
4684 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304685 {
4686 hddLog(LOGE,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304687 FL("Invalid RSN IE: parse status %d"), status);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304688 return -EINVAL;
4689 }
4690
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 // Copy out the encryption and authentication types
4692 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004693 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004695 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 //dot11WPAIE.auth_suite_count
4697 // Just translate the FIRST one
4698 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
4699 //dot11WPAIE.unicast_cipher_count
4700 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
4701 //dot11WPAIE.unicast_cipher_count
4702 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
4703 }
4704 else
4705 {
4706 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004707 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 }
4709 return 0;
4710}
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304711
4712/**
4713 * hdd_set_def_rsne_override() - set default encryption type and auth type
4714 * in profile.
4715 * @roam_profile: pointer to adapter
4716 * @auth_type: pointer to auth type
4717 *
4718 * Set default value of encryption type and auth type in profile to
4719 * search the AP using filter, as in force_rsne_override the RSNIE can be
4720 * currupt and we might not get the proper encryption type and auth type
4721 * while parsing the RSNIE.
4722 *
4723 * Return: void
4724 */
4725static void hdd_set_def_rsne_override(
4726 tCsrRoamProfile *roam_profile, eCsrAuthType *auth_type)
4727{
4728 hddLog( LOG1, FL("Set def values in roam profile"));
4729 roam_profile->MFPCapable = roam_profile->MFPEnabled;
4730 roam_profile->EncryptionType.numEntries = 2;
4731 roam_profile->mcEncryptionType.numEntries = 2;
4732 /* Use the cipher type in the RSN IE */
4733 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
4734 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
4735 roam_profile->mcEncryptionType.encryptionType[0] =
4736 eCSR_ENCRYPT_TYPE_AES;
4737 roam_profile->mcEncryptionType.encryptionType[1] =
4738 eCSR_ENCRYPT_TYPE_TKIP;
4739 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
4740}
4741
Jeff Johnson295189b2012-06-20 16:38:30 -07004742int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
4743{
4744 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4745 v_U32_t status = 0;
4746 eCsrEncryptionType RSNEncryptType;
4747 eCsrEncryptionType mcRSNEncryptType;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304748 hdd_context_t *hdd_ctx;
Chet Lanctot186b5732013-03-18 10:26:30 -07004749#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304750 u_int8_t RSNMfpRequired = 0;
4751 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07004752#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 struct ether_addr bSsid; // MAC address of assoc peer
4754 // MAC address of assoc peer
4755 // But, this routine is only called when we are NOT associated.
4756 vos_mem_copy(bSsid.ether_addr_octet,
4757 pWextState->roamProfile.BSSIDs.bssid,
4758 sizeof(bSsid.ether_addr_octet));
4759 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
4760 {
4761 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07004762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 else
4764 {
4765 return 0;
4766 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304767
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 // The actual processing may eventually be more extensive than this.
4769 // Right now, just consume any PMKIDs that are sent in by the app.
4770 status = hdd_ProcessGENIE(pAdapter,
4771 &bSsid, // MAC address of assoc peer
4772 &RSNEncryptType,
4773 &mcRSNEncryptType,
4774 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004775#ifdef WLAN_FEATURE_11W
4776 &RSNMfpRequired,
4777 &RSNMfpCapable,
4778#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 pWextState->WPARSNIE[1]+2,
4780 pWextState->WPARSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304781
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 if (status == 0)
4783 {
4784 // Now copy over all the security attributes you have parsed out
4785 pWextState->roamProfile.EncryptionType.numEntries = 1;
4786 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004787
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
4789 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07004790
Shailender Karmuchi642e9812013-05-30 14:34:49 -07004791 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
4792 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
4793 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
4794 {
4795 /*For wpa none supplicant sends the WPA IE with unicast cipher as
4796 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
4797 either AES/TKIP based on group cipher configuration
4798 mentioned in the wpa_supplicant.conf.*/
4799
4800 /*Set the unicast cipher same as multicast cipher*/
4801 pWextState->roamProfile.EncryptionType.encryptionType[0]
4802 = mcRSNEncryptType;
4803 }
4804
Chet Lanctot186b5732013-03-18 10:26:30 -07004805#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304806 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
4807 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07004808 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
4809 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
4810#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304811 hddLog( LOG1,
4812 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
4813 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304814 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004815 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304816
4817 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4818 if (hdd_ctx->force_rsne_override &&
4819 (pWextState->WPARSNIE[0] == DOT11F_EID_RSN)) {
4820 hddLog(LOG1,
4821 FL("Test mode enabled set def Auth and enc type. RSN IE passed in connect req:"));
4822 vos_trace_hex_dump(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4823 pWextState->roamProfile.pRSNReqIE,
4824 pWextState->roamProfile.nRSNReqIELength);
4825
4826 pWextState->roamProfile.force_rsne_override = true;
4827 hddLog(LOG1,
4828 FL("MFPEnabled %d"), pWextState->roamProfile.MFPEnabled);
4829 /*
4830 * Reset MFPEnabled if testmode RSNE passed doesnt have MFPR
4831 * or MFPC bit set
4832 */
4833 if (pWextState->roamProfile.MFPEnabled &&
4834 !(pWextState->roamProfile.MFPRequired ||
4835 pWextState->roamProfile.MFPCapable)) {
4836 hddLog( LOG1,FL("Reset MFPEnabled"));
4837 pWextState->roamProfile.MFPEnabled = 0;
4838 }
4839
4840 /* If parsing failed set the def value for the roam profile */
4841 if (status)
4842 hdd_set_def_rsne_override(&pWextState->roamProfile,
4843 RSNAuthType);
4844 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304845 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004846}
4847int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
4848{
4849 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4850 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
4851 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4852 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004853
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004855 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004856
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 switch( pHddStaCtx->conn_info.authType)
4858 {
4859 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Abhinav Kumar62801ba2018-09-19 12:14:14 +05304860 case eCSR_AUTH_TYPE_AUTOSWITCH:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004861#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 case eCSR_AUTH_TYPE_CCKM_WPA:
4863 case eCSR_AUTH_TYPE_CCKM_RSN:
4864#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004865 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4866
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004868 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004870
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004871#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004872 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4873 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4874 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004875 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004876 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4877 } else
4878 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004879 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004880 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 } else
4882#endif
4883 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4884 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004885 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4886 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4888 == IW_AUTH_KEY_MGMT_PSK) {
4889 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004890 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 }
4894 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004895#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004896 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4897 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4898 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004899 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004900 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004902 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004903 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004904 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 } else
4906#endif
4907
4908#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004909 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4910 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004912 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004913 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004914 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4916 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004917 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 } else
4919#endif
4920
Chet Lanctot186b5732013-03-18 10:26:30 -07004921#ifdef WLAN_FEATURE_11W
4922 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4923 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4924 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304925 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4926 pRoamProfile->AuthType.authType[0] =
4927 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4928 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004929#endif
4930
Shailender Karmuchia734f332013-04-19 14:02:48 -07004931 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004933 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4934 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4936 == IW_AUTH_KEY_MGMT_PSK) {
4937 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004938 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004942 break;
4943
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004945
4946 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304948 case eCSR_AUTH_TYPE_SAE:
4949 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
4950 break;
4951
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004953
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004954#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004955 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004956#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4958 break;
4959 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004960
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004962 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004963
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 EXIT();
4965 return 0;
4966}
4967
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05304968/**
4969 * hdd_rx_fwd_eapol() - forward cached eapol frames
4970 * @vosContext : pointer to vos global context
4971 * @pVosPacket: pointer to vos packet
4972 *
4973 * Return: None
4974 *
4975 */
4976void hdd_assoc_registerFwdEapolCB(void *pContext)
4977{
4978 WLANTL_RegisterFwdEapol(pContext, hdd_rx_fwd_eapol);
4979}
4980
Jeff Johnson295189b2012-06-20 16:38:30 -07004981/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004982
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304983 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004985 to the CSR roam profile.
4986
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 \param - dev - Pointer to the net device.
4988 - info - Pointer to the iw_request_info.
4989 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004990 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004992
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 --------------------------------------------------------------------------*/
4994
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304995int __iw_set_essid(struct net_device *dev,
4996 struct iw_request_info *info,
4997 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004998{
4999 v_U32_t status = 0;
5000 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305001 hdd_adapter_t *pAdapter;
5002 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 v_U32_t roamId;
5004 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305006 tHalHandle hHal;
5007 hdd_station_ctx_t *pHddStaCtx;
5008 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005009
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305011 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5012 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05305014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305015 "%s: Adapter is NULL",__func__);
5016 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 }
5018
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305019 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5020 ret = wlan_hdd_validate_context(pHddCtx);
5021 if (0 != ret)
5022 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305023 return ret;
5024 }
5025
5026 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5027 if (NULL == hHal)
5028 {
5029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5030 "%s: Hal Context is NULL",__func__);
5031 return -EINVAL;
5032 }
5033 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5034 if (NULL == pHddStaCtx)
5035 {
5036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5037 "%s: STA Context is NULL",__func__);
5038 return -EINVAL;
5039 }
5040 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5041 if (NULL == pWextState)
5042 {
5043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5044 "%s: pWextState is NULL",__func__);
5045 return -EINVAL;
5046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
5048 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
5049 return -EBUSY;
5050 }
5051 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
5052 return -EINVAL;
5053 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005054
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305055 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
5056 return -EINVAL;
5057
Agrawal Ashishc407f192017-01-23 17:18:35 +05305058 /*Try disconnecting if already in connected state*/
5059 status = wlan_hdd_try_disconnect(pAdapter);
5060 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 {
Agrawal Ashishc407f192017-01-23 17:18:35 +05305062 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
5063 " connection"));
5064 return -EALREADY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 }
5066 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07005067 /** when cfg80211 defined, wpa_supplicant wext driver uses
5068 zero-length, null-string ssid for force disconnection.
5069 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 driver MUST return success */
5071 if ( 0 == wrqu->essid.length ) {
5072 return 0;
5073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005074
5075 status = hdd_wmm_get_uapsd_mask(pAdapter,
5076 &pWextState->roamProfile.uapsd_mask);
5077 if (VOS_STATUS_SUCCESS != status)
5078 {
5079 pWextState->roamProfile.uapsd_mask = 0;
5080 }
5081 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005082
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005084
5085 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
5087 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
5088 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005089
Jeff Johnson295189b2012-06-20 16:38:30 -07005090 //set gen ie
5091 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5092
5093 //set auth
5094 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5095 }
5096#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005097 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 if (pAdapter->wapi_info.nWapiMode)
5099 {
5100 switch (pAdapter->wapi_info.wapiAuthMode)
5101 {
5102 case WAPI_AUTH_MODE_PSK:
5103 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005104 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 pRoamProfile->AuthType.numEntries = 1;
5106 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5107 break;
5108 }
5109 case WAPI_AUTH_MODE_CERT:
5110 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005111 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 pRoamProfile->AuthType.numEntries = 1;
5113 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5114 break;
5115 }
5116 } // End of switch
5117 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5118 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5119 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005120 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 pRoamProfile->EncryptionType.numEntries = 1;
5122 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5123 pRoamProfile->mcEncryptionType.numEntries = 1;
5124 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5125 }
5126 }
5127#endif /* FEATURE_WLAN_WAPI */
5128 /* if previous genIE is not NULL, update AssocIE */
5129 if (0 != pWextState->genIE.length)
5130 {
5131 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
5132 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
5133 pWextState->genIE.length);
5134 pWextState->assocAddIE.length = pWextState->genIE.length;
5135 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5136 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5137
5138 /* clear previous genIE after use it */
5139 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
5140 }
5141
5142 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
5143 pWextState->roamProfile.bWPSAssociation = FALSE;
5144
5145 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5146 pWextState->roamProfile.nAddIEAssocLength))
5147 pWextState->roamProfile.bWPSAssociation = TRUE;
5148
5149
5150 // Disable auto BMPS entry by PMC until DHCP is done
5151 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
5152
Shailender Karmuchia734f332013-04-19 14:02:48 -07005153 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005155
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005156 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
5157 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005158 hdd_select_cbmode(pAdapter,
5159 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
5160 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305161 /*
5162 * Change conn_state to connecting before sme_RoamConnect(),
5163 * because sme_RoamConnect() has a direct path to call
5164 * hdd_smeRoamCallback(), which will change the conn_state
5165 * If direct path, conn_state will be accordingly changed
5166 * to NotConnected or Associated by either
5167 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
5168 * in sme_RoamCallback()
5169 * if sme_RomConnect is to be queued,
5170 * Connecting state will remain until it is completed.
5171 *
5172 * If connection state is not changed,
5173 * connection state will remain in eConnectionState_NotConnected state.
5174 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
5175 * if conn state is eConnectionState_NotConnected.
5176 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5177 * informed of connect result indication which is an issue.
5178 */
5179 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5180 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
5181 {
5182 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5183 FL("Set HDD connState to eConnectionState_Connecting"));
5184 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5185 eConnectionState_Connecting);
5186 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005187 status = sme_RoamConnect( hHal,pAdapter->sessionId,
5188 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305189
5190 if ((eHAL_STATUS_SUCCESS != status) &&
5191 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5192 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5193 {
5194 hddLog(VOS_TRACE_LEVEL_ERROR,
5195 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
5196 pAdapter->sessionId, status);
5197 /* change back to NotAssociated */
5198 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5199 eConnectionState_NotConnected);
5200 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005201 pRoamProfile->ChannelInfo.ChannelList = NULL;
5202 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005203
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005204 EXIT();
5205 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005206}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005207
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305208int iw_set_essid(struct net_device *dev,
5209 struct iw_request_info *info,
5210 union iwreq_data *wrqu, char *extra)
5211{
5212 int ret;
5213
5214 vos_ssr_protect(__func__);
5215 ret = __iw_set_essid(dev, info, wrqu, extra);
5216 vos_ssr_unprotect(__func__);
5217
5218 return ret;
5219}
5220
Jeff Johnson295189b2012-06-20 16:38:30 -07005221/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005222
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305223 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005225
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 \param - dev - Pointer to the net device.
5227 - info - Pointer to the iw_request_info.
5228 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005229 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005231
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305233int __iw_get_essid(struct net_device *dev,
5234 struct iw_request_info *info,
5235 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005236{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305237 hdd_adapter_t *pAdapter;
5238 hdd_context_t *pHddCtx;
5239 hdd_wext_state_t *wextBuf;
5240 hdd_station_ctx_t *pHddStaCtx;
5241 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305242
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 ENTER();
5244
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305245 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5246 if (NULL == pAdapter)
5247 {
5248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5249 "%s: Adapter is NULL",__func__);
5250 return -EINVAL;
5251 }
5252
5253 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5254 ret = wlan_hdd_validate_context(pHddCtx);
5255 if (0 != ret)
5256 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305257 return ret;
5258 }
5259
5260 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5261 if (NULL == pHddStaCtx)
5262 {
5263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5264 "%s: STA Context is NULL",__func__);
5265 return -EINVAL;
5266 }
5267
5268 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5269 if (NULL == wextBuf)
5270 {
5271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5272 "%s: wextBuf is NULL",__func__);
5273 return -EINVAL;
5274 }
5275
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5277 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5278 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
5279 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
5280 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
5281 {
5282 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5283 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
5284 dwrq->flags = 1;
5285 } else {
5286 memset(extra, 0, dwrq->length);
5287 dwrq->length = 0;
5288 dwrq->flags = 0;
5289 }
5290 EXIT();
5291 return 0;
5292}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305293
5294int iw_get_essid(struct net_device *dev,
5295 struct iw_request_info *info,
5296 struct iw_point *dwrq, char *extra)
5297{
5298 int ret;
5299
5300 vos_ssr_protect(__func__);
5301 ret = __iw_get_essid(dev, info, dwrq, extra);
5302 vos_ssr_unprotect(__func__);
5303
5304 return ret;
5305}
Jeff Johnson295189b2012-06-20 16:38:30 -07005306/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005307
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305308 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005309 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005310
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 \param - dev - Pointer to the net device.
5312 - info - Pointer to the iw_request_info.
5313 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005314 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005316
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305318int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
5319 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005320{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305321 hdd_adapter_t *pAdapter;
5322 hdd_context_t *pHddCtx;
5323 hdd_wext_state_t *pWextState;
5324 hdd_station_ctx_t *pHddStaCtx;
5325 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005326 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305328 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005329
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005331
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305332 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5333 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005334 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5336 "%s: Adapter is NULL",__func__);
5337 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005338 }
5339
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305340 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5341 ret = wlan_hdd_validate_context(pHddCtx);
5342 if (0 != ret)
5343 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305344 return ret;
5345 }
5346
5347 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5348 if (NULL == pHddStaCtx)
5349 {
5350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5351 "%s: STA Context is NULL",__func__);
5352 return -EINVAL;
5353 }
5354
5355 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5356 if (NULL == pWextState)
5357 {
5358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5359 "%s: pWextState is NULL",__func__);
5360 return -EINVAL;
5361 }
5362
5363 pRoamProfile = &pWextState->roamProfile;
5364
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 switch(wrqu->param.flags & IW_AUTH_INDEX)
5366 {
5367 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005368
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005370
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005372
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 case IW_AUTH_CIPHER_PAIRWISE:
5374 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005375 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5379 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5382 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005383 }
5384
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) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
5390 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005391 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 else
5393 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005394 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005397
5398 if( ( IW_AUTH_KEY_MGMT_802_1X
5399 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5401 /*Dynamic WEP key*/
5402 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5403 else
5404 /*Static WEP key*/
5405 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005406
Jeff Johnson295189b2012-06-20 16:38:30 -07005407 }
5408 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005409
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005411 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 return -EINVAL;
5413 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005414
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 pRoamProfile->EncryptionType.numEntries = 1;
5416 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 break;
5419 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005420 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5422 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5423 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005424
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5426 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5427 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005428
5429 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5431 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005432
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005434
5435 if( ( IW_AUTH_KEY_MGMT_802_1X
5436 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5437 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5438
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005440
5441 else
5442 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005444
5445 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
5446 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005448 if( ( IW_AUTH_KEY_MGMT_802_1X
5449 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5451 {
5452 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5453 }
5454 else
5455 {
5456 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5457 }
5458 }
5459 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005460
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005462 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 return -EINVAL;
5464 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005465
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 pRoamProfile->mcEncryptionType.numEntries = 1;
5467 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
5468 }
5469 break;
5470
5471 case IW_AUTH_80211_AUTH_ALG:
5472 {
5473 /*Save the auth algo here and set auth type to SME Roam profile
5474 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005475 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005477
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5479 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5480
5481 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
5482 /*Not supported*/
5483 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5484 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5485 }
5486 break;
5487
5488 case IW_AUTH_KEY_MGMT:
5489 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005490#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005491#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5492 /*Check for CCKM AKM type */
5493 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005494 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
5495 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005496 /* Set the CCKM bit in authKeyMgmt */
5497 /* Right now, this breaks all ref to authKeyMgmt because our
5498 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 */
5500 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5501 /*Set the key management to 802.1X*/
5502 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005503 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5505 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
5506 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5507 /*Save the key management*/
5508 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5509 //pWextState->authKeyMgmt = wrqu->param.value;
5510 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5511 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5512 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5513 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
5514 /*Save the key management anyway*/
5515 pWextState->authKeyMgmt = wrqu->param.value;
5516 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
5517 /*Save the key management*/
5518 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5519 //pWextState->authKeyMgmt = wrqu->param.value;
5520 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5521 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5522 }
5523#else
5524 /*Save the key management*/
5525 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005526#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 }
5528 break;
5529
5530 case IW_AUTH_TKIP_COUNTERMEASURES:
5531 {
5532 if(wrqu->param.value) {
5533 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5534 "Counter Measure started %d", wrqu->param.value);
5535 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
5536 }
5537 else {
5538 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5539 "Counter Measure stopped=%d", wrqu->param.value);
5540 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
5541 }
5542 }
5543 break;
5544 case IW_AUTH_DROP_UNENCRYPTED:
5545 case IW_AUTH_WPA_ENABLED:
5546 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5547 case IW_AUTH_ROAMING_CONTROL:
5548 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005549
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005551
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005552 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 wrqu->param.flags & IW_AUTH_INDEX);
5554 break;
5555 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005556
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 EXIT();
5558 return 0;
5559}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305560
5561int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5562 union iwreq_data *wrqu, char *extra)
5563{
5564 int ret;
5565
5566 vos_ssr_protect(__func__);
5567 ret = __iw_set_auth(dev, info, wrqu, extra);
5568 vos_ssr_unprotect(__func__);
5569
5570 return ret;
5571}
5572
Jeff Johnson295189b2012-06-20 16:38:30 -07005573/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005574
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305575 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005577
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 \param - dev - Pointer to the net device.
5579 - info - Pointer to the iw_request_info.
5580 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005581 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005583
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305585int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5586 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005587{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305588 hdd_adapter_t* pAdapter;
5589 hdd_wext_state_t *pWextState;
5590 tCsrRoamProfile *pRoamProfile;
5591 hdd_context_t *pHddCtx;
5592 int ret = 0;
5593
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005595
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305596 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5597 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005598 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5600 "%s: Adapter is NULL",__func__);
5601 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005602 }
5603
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305604 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5605 ret = wlan_hdd_validate_context(pHddCtx);
5606 if (0 != ret)
5607 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305608 return ret;
5609 }
5610
5611 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5612 if (NULL == pWextState)
5613 {
5614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5615 "%s: pWextState is NULL",__func__);
5616 return -EINVAL;
5617 }
5618 pRoamProfile = &pWextState->roamProfile;
5619
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 switch(pRoamProfile->negotiatedAuthType)
5621 {
5622 case eCSR_AUTH_TYPE_WPA_NONE:
5623 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5624 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
5625 break;
5626 case eCSR_AUTH_TYPE_WPA:
5627 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5628 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
5629 break;
5630#ifdef WLAN_FEATURE_VOWIFI_11R
5631 case eCSR_AUTH_TYPE_FT_RSN:
5632#endif
5633 case eCSR_AUTH_TYPE_RSN:
5634 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5635 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
5636 break;
5637 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5638 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5639 break;
5640 case eCSR_AUTH_TYPE_SHARED_KEY:
5641 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
5642 break;
5643 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005644 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005645 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5646 break;
5647 case eCSR_AUTH_TYPE_AUTOSWITCH:
5648 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5649 break;
5650 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305651 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5653 return -EIO;
5654#ifdef WLAN_FEATURE_VOWIFI_11R
5655 case eCSR_AUTH_TYPE_FT_RSN_PSK:
5656#endif
5657 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07005658#ifdef WLAN_FEATURE_11W
5659 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05305660 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07005661#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05305662 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5664 return -EIO;
5665 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305666 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5668 return -EIO;
5669 }
5670 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
5671 {
5672 switch(pRoamProfile->negotiatedUCEncryptionType)
5673 {
5674 case eCSR_ENCRYPT_TYPE_NONE:
5675 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5676 break;
5677 case eCSR_ENCRYPT_TYPE_WEP40:
5678 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5679 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5680 break;
5681 case eCSR_ENCRYPT_TYPE_TKIP:
5682 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5683 break;
5684 case eCSR_ENCRYPT_TYPE_WEP104:
5685 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5686 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5687 break;
5688 case eCSR_ENCRYPT_TYPE_AES:
5689 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5690 break;
5691 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305692 hddLog(LOG1, "%s called with unknown auth type %d ",
5693 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 return -EIO;
5695 }
5696 }
5697
Shailender Karmuchia734f332013-04-19 14:02:48 -07005698 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 {
5700 switch(pRoamProfile->negotiatedMCEncryptionType)
5701 {
5702 case eCSR_ENCRYPT_TYPE_NONE:
5703 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5704 break;
5705 case eCSR_ENCRYPT_TYPE_WEP40:
5706 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5707 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5708 break;
5709 case eCSR_ENCRYPT_TYPE_TKIP:
5710 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5711 break;
5712 case eCSR_ENCRYPT_TYPE_WEP104:
5713 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5714 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5715 break;
5716 case eCSR_ENCRYPT_TYPE_AES:
5717 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5718 break;
5719 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305720 hddLog(LOG1, "%s called with unknown auth type %d ",
5721 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 return -EIO;
5723 }
5724 }
5725
5726 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005727 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 EXIT();
5729 return 0;
5730}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305731
5732int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5733 union iwreq_data *wrqu,char *extra)
5734{
5735 int ret;
5736
5737 vos_ssr_protect(__func__);
5738 ret = __iw_get_auth(dev, info, wrqu, extra);
5739 vos_ssr_unprotect(__func__);
5740
5741 return ret;
5742}
5743
Jeff Johnson295189b2012-06-20 16:38:30 -07005744/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005745
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305746 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07005747 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005749
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 \param - dev - Pointer to the net device.
5751 - info - Pointer to the iw_request_info.
5752 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005753 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005755
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305757int __iw_set_ap_address(struct net_device *dev,
5758 struct iw_request_info *info,
5759 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005760{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305761 hdd_station_ctx_t *pHddStaCtx;
5762 hdd_adapter_t *pAdapter;
5763 hdd_context_t *pHddCtx;
5764 v_U8_t *pMacAddress = NULL;
5765 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305766
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305768
5769 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5770 if (NULL == pAdapter)
5771 {
5772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5773 "%s: Adapter is NULL", __func__);
5774 return -EINVAL;
5775 }
5776 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5777 ret = wlan_hdd_validate_context(pHddCtx);
5778 if (0 != ret)
5779 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305780 return ret;
5781 }
5782 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5783 if (NULL == pHddStaCtx)
5784 {
5785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5786 "%s: pHddStaCtx is NULL", __func__);
5787 return -EINVAL;
5788 }
5789
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08005791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
5792 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07005794
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305795 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 return 0;
5797}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305798
5799int iw_set_ap_address(struct net_device *dev,
5800 struct iw_request_info *info,
5801 union iwreq_data *wrqu, char *extra)
5802{
5803 int ret;
5804
5805 vos_ssr_protect(__func__);
5806 ret = __iw_set_ap_address(dev, info, wrqu, extra);
5807 vos_ssr_unprotect(__func__);
5808
5809 return ret;
5810}
5811
Jeff Johnson295189b2012-06-20 16:38:30 -07005812/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005813
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305814 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 This function returns the BSSID to the wpa_supplicant
5816 \param - dev - Pointer to the net device.
5817 - info - Pointer to the iw_request_info.
5818 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005819 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005821
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305823int __iw_get_ap_address(struct net_device *dev,
5824 struct iw_request_info *info,
5825 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005826{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305827 hdd_station_ctx_t *pHddStaCtx;
5828 hdd_adapter_t *pAdapter;
5829 hdd_context_t *pHddCtx;
5830 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305831
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 ENTER();
5833
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305834 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5835 if (NULL == pAdapter)
5836 {
5837 hddLog(VOS_TRACE_LEVEL_ERROR,
5838 "%s: Adapter is NULL", __func__);
5839 return -EINVAL;
5840 }
5841 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5842 ret = wlan_hdd_validate_context(pHddCtx);
5843 if (0 != ret)
5844 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305845 return ret;
5846 }
5847 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5848 if (NULL == pHddStaCtx)
5849 {
5850 hddLog(VOS_TRACE_LEVEL_ERROR,
5851 "%s: pHddStaCtx is NULL", __func__);
5852 return -EINVAL;
5853 }
5854
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
5856 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
5857 {
Jeff Johnson4416a782013-03-25 14:17:50 -07005858 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 }
5860 else
5861 {
5862 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
5863 }
5864 EXIT();
5865 return 0;
5866}
Jeff Johnsond13512a2012-07-17 11:42:19 -07005867
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305868int iw_get_ap_address(struct net_device *dev,
5869 struct iw_request_info *info,
5870 union iwreq_data *wrqu, char *extra)
5871{
5872 int ret;
5873
5874 vos_ssr_protect(__func__);
5875 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5876 vos_ssr_unprotect(__func__);
5877
5878 return ret;
5879}
5880
Chet Lanctot186b5732013-03-18 10:26:30 -07005881#ifdef WLAN_FEATURE_11W
5882/**---------------------------------------------------------------------------
5883
5884 \brief hdd_indicateUnprotMgmtFrame -
5885 This function forwards the unprotected management frame to the supplicant
5886 \param - pAdapter - Pointer to HDD adapter
5887 - nFrameLength - Length of the unprotected frame being passed
5888 - pbFrames - Pointer to the frame buffer
5889 - frameType - 802.11 frame type
5890 \return - nothing
5891
5892 --------------------------------------------------------------------------*/
5893void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5894 tANI_U32 nFrameLength,
5895 tANI_U8* pbFrames,
5896 tANI_U8 frameType )
5897{
5898 tANI_U8 type = 0;
5899 tANI_U8 subType = 0;
5900
5901 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5902 __func__, frameType, nFrameLength);
5903
5904 /* Sanity Checks */
5905 if (NULL == pAdapter)
5906 {
5907 hddLog( LOGE, FL("pAdapter is NULL"));
5908 return;
5909 }
5910
5911 if (NULL == pAdapter->dev)
5912 {
5913 hddLog( LOGE, FL("pAdapter->dev is NULL"));
5914 return;
5915 }
5916
5917 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5918 {
5919 hddLog( LOGE, FL("pAdapter has invalid magic"));
5920 return;
5921 }
5922
5923 if( !nFrameLength )
5924 {
5925 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
5926 return;
5927 }
5928
5929 if (NULL == pbFrames) {
5930 hddLog( LOGE, FL("pbFrames is NULL"));
5931 return;
5932 }
5933
5934 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5935 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5936
5937 /* Get pAdapter from Destination mac address of the frame */
5938 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5939 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305940#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5941 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5942#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005943 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305944#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005945 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5946 }
5947 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5948 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305949#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5950 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5951#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005952 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305953#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005954 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5955 }
5956 else
5957 {
5958 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5959 return;
5960 }
5961}
5962#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005963
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005964#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005965void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5966 tANI_U8 state,
5967 tANI_U16 measInterval )
5968{
5969 union iwreq_data wrqu;
5970 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005971 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005972
5973 if (NULL == pAdapter)
5974 return;
5975
5976 // create the event
5977 memset(&wrqu, '\0', sizeof(wrqu));
5978 memset(buf, '\0', sizeof(buf));
5979
5980 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5981 tid, state, measInterval);
5982
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005983 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005984
5985 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005986 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005987 // send the event
5988 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5989}
5990
5991void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5992{
5993 union iwreq_data wrqu;
5994 char buf[IW_CUSTOM_MAX + 1];
5995 char *pos = buf;
5996 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5997
5998 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5999 return;
6000
6001 // create the event
6002 memset(&wrqu, '\0', sizeof(wrqu));
6003 memset(buf, '\0', sizeof(buf));
6004
6005 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306006 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
6007 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
6008 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
6009 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006010
6011 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
6012 pos += nBytes;
6013 freeBytes -= nBytes;
6014
6015 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
6016 pos += WNI_CFG_BSSID_LEN;
6017 freeBytes -= WNI_CFG_BSSID_LEN;
6018
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006019 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
6020 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006021
6022 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006023 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006024
6025 // send the event
6026 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6027}
6028
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006029void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006030{
6031 union iwreq_data wrqu;
6032 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006033 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006034
6035 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6036 return;
6037
6038 // create the event
6039 memset(&wrqu, '\0', sizeof(wrqu));
6040 memset(buf, '\0', sizeof(buf));
6041
6042 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
6043
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006044 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006045
6046 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006047 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006048
6049 // send the event
6050 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6051}
6052
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006053void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
6054 const tANI_U16 measurementToken,
6055 const tANI_BOOLEAN flag,
6056 const tANI_U8 numBss)
6057{
6058 union iwreq_data wrqu;
6059 char buf[IW_CUSTOM_MAX];
6060 char *pos = buf;
6061 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6062
6063 memset(&wrqu, '\0', sizeof(wrqu));
6064 memset(buf, '\0', sizeof(buf));
6065
6066 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
6067 numBss);
6068
6069 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
6070 flag, numBss);
6071
6072 wrqu.data.pointer = buf;
6073 wrqu.data.length = nBytes;
6074 // send the event
6075 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6076}
6077
6078
6079static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006080 const tCsrRoamInfo *pRoamInfo)
6081{
6082 union iwreq_data wrqu;
6083 char buf[IW_CUSTOM_MAX + 1];
6084 char *pos = buf;
6085 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6086 tANI_U8 i = 0, len = 0;
6087 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
6088 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006089 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
6090 tANI_U8 ieLenByte = 1;
6091 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
6092#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006093
6094 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6095 return;
6096
6097 /* Custom event can pass maximum of 256 bytes of data,
6098 based on the IE len we need to identify how many BSS info can
6099 be filled in to custom event data */
6100 /*
6101 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
6102 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
6103 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
6104 */
6105
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006106 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006107 {
6108 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
6109 /* If the measurement is none and no scan results found,
6110 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006111 hdd_indicateEseBcnReportNoResults(pAdapter,
6112 pRoamInfo->pEseBcnReportRsp->measurementToken,
6113 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006114 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006115 }
6116 else
6117 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006118 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006119 {
6120 memset(&wrqu, '\0', sizeof(wrqu));
6121 memset(buf, '\0', sizeof(buf));
6122 tot_bcn_ieLen = 0;
6123 sendBss = 0;
6124 pos = buf;
6125 freeBytes = IW_CUSTOM_MAX;
6126
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006127 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006128 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006129 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
6130 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006131 {
6132 break;
6133 }
6134 tot_bcn_ieLen += len;
6135 sendBss++;
6136 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
6137 "IeLength(%d) Length of Ie(%d) totLen(%d)",
6138 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006139 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006140 tot_bcn_ieLen);
6141 }
6142
6143 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
6144 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006145 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6146 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006147
6148 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006149 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6150 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006151 pos += nBytes;
6152 freeBytes -= nBytes;
6153
6154 /* Copy total Beacon report data length */
6155 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
6156 pos += sizeof(tot_bcn_ieLen);
6157 freeBytes -= sizeof(tot_bcn_ieLen);
6158
6159 for (i = 0; i < sendBss; i++)
6160 {
6161 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306162 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
6163 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006164 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006165 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
6166 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
6167 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
6168 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
6169 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
6170 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
6171 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
6172 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
6173 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
6174 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
6175 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
6176 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
6177 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
6178 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
6179 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
6180 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006181
6182 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006183 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
6184 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006185 pos += len;
6186 freeBytes -= len;
6187
6188 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006189 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006190 vos_mem_copy(pos, (char*)&len, sizeof(len));
6191 pos += sizeof(len);
6192 freeBytes -= sizeof(len);
6193
6194 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006195 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006196 pos += len;
6197 freeBytes -= len;
6198 }
6199
6200 wrqu.data.pointer = buf;
6201 wrqu.data.length = strlen(buf);
6202
6203 // send the event
6204 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6205 lastSent += sendBss;
6206 }
6207 }
6208}
6209
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006210#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006211
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306212hdd_adapter_t *hdd_get_sta_connection_in_progress(hdd_context_t *hdd_ctx)
6213{
6214 hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
6215 hdd_adapter_t *adapter = NULL;
6216 VOS_STATUS status;
6217 hdd_station_ctx_t *hdd_sta_ctx;
6218
6219 if (!hdd_ctx) {
6220 hddLog(LOGE, FL("HDD context is NULL"));
6221 return NULL;
6222 }
6223
6224 status = hdd_get_front_adapter(hdd_ctx, &adapter_node);
6225 while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
6226 adapter = adapter_node->pAdapter;
6227 if (!adapter)
6228 goto end;
6229
6230 if ((WLAN_HDD_INFRA_STATION == adapter->device_mode) ||
6231 (WLAN_HDD_P2P_CLIENT == adapter->device_mode) ||
6232 (WLAN_HDD_P2P_DEVICE == adapter->device_mode)) {
6233 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6234 if (eConnectionState_Connecting ==
6235 hdd_sta_ctx->conn_info.connState) {
6236 hddLog(LOG1, FL("session_id %d: Connection is in progress"),
6237 adapter->sessionId);
6238 return adapter;
6239 } else if ((eConnectionState_Associated ==
6240 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +05306241 sme_is_sta_key_exchange_in_progress(
6242 hdd_ctx->hHal, adapter->sessionId)) {
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306243 hddLog(LOG1, FL("session_id %d: Key exchange is in progress"),
6244 adapter->sessionId);
6245 return adapter;
6246 }
6247 }
6248end:
6249 status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next);
6250 adapter_node = next;
6251 }
6252 return NULL;
6253}
6254