blob: 3e6418fa8acfb89d168a273ad7f95cf657724823 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
gaurank kathpaliab654f702020-01-03 15:07:17 +05302 * Copyright (c) 2012-2020 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
Abhinav Kumar487e49e2019-07-22 14:46:18 +0530159/* OWE https://tools.ietf.org/html/rfc8110 */
160uint8_t ccp_rsn_oui_18[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x12};
Abhinav Kumar4d44f632019-08-02 13:55:54 +0530161
Shailender Karmuchia734f332013-04-19 14:02:48 -0700162#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700163// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700164#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
165#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700166#endif
167
168#define BEACON_FRAME_IES_OFFSET 12
169
Abhishek Singh78c691f2017-11-30 13:48:44 +0530170/* The time after add bss, in which SAP should start ECSA to move to SCC */
171#define ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL 1500
Abhishek Singh10e17cf2018-03-12 14:34:22 +0530172/*
173 * Time in ms after disconnect, in which the SAP should move to non DFS channel.
174 * This will avoid multiple SAP channel switch if disconnet is followed by
175 * connect.
176 */
177#define ECSA_DFS_CHAN_CHANGE_DEFER_TIME 200
Abhishek Singh78c691f2017-11-30 13:48:44 +0530178
Chet Lanctot186b5732013-03-18 10:26:30 -0700179#ifdef WLAN_FEATURE_11W
180void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
181 tANI_U32 nFrameLength,
182 tANI_U8* pbFrames,
183 tANI_U8 frameType );
184#endif
185
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800186#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700187static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
188 tANI_U8 state,
189 tANI_U16 measInterval );
190static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800191static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
192static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700193
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800194#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700195
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530196static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
197 tCsrRoamInfo *pRoamInfo,
198 tANI_U32 roamId,
199 eRoamCmdStatus roamStatus,
200 eCsrRoamResult roamResult );
201
Abhinav Kumar118efd02019-08-07 16:41:07 +0530202#if defined(WLAN_FEATURE_SAE) && \
203 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
204/**
205 * wlan_hdd_sae_callback() - Sends SAE info to supplicant
206 * @adapter: pointer adapter context
207 * @roam_info: pointer to roam info
208 *
209 * This API is used to send required SAE info to trigger SAE in supplicant.
210 *
211 * Return: None
212 */
213static void wlan_hdd_sae_callback(hdd_adapter_t *adapter,
214 tCsrRoamInfo *roam_info)
215{
216 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
217 int flags;
218 struct sir_sae_info *sae_info = roam_info->sae_info;
219 struct cfg80211_external_auth_params params = {0};
220
221 if (wlan_hdd_validate_context(hdd_ctx))
222 return;
223 if (!sae_info) {
224 hddLog(LOGE, FL("SAE info in NULL"));
225 return;
226 }
227 flags = vos_get_gfp_flags();
228
229 params.key_mgmt_suite = 0x00;
230 params.key_mgmt_suite |= 0x0F << 8;
231 params.key_mgmt_suite |= 0xAC << 16;
232 params.key_mgmt_suite |= 0x8 << 24;
233
234 params.action = NL80211_EXTERNAL_AUTH_START;
235 vos_mem_copy(params.bssid, sae_info->peer_mac_addr.bytes,
236 VOS_MAC_ADDR_SIZE);
237 vos_mem_copy(params.ssid.ssid, sae_info->ssid.ssId, sae_info->ssid.length);
238 params.ssid.ssid_len = sae_info->ssid.length;
239
240 cfg80211_external_auth_request(adapter->dev, &params, flags);
241 hddLog(LOG1, FL("SAE: sent cmd"));
242}
243#else
244static void wlan_hdd_sae_callback(hdd_adapter_t *adapter,
245 tCsrRoamInfo *roam_info)
246{ }
247#endif
248
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530249v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
250 eConnectionState connState )
251{
252 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530253 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
254 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 pHddStaCtx->conn_info.connState = connState;
256}
257
258// returns FALSE if not connected.
259// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
260// returns the connection state. Can specify NULL if you dont' want to get the actual state.
261
Shailender Karmuchia734f332013-04-19 14:02:48 -0700262static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
263 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700264{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700265 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700267
Jeff Johnson295189b2012-06-20 16:38:30 -0700268 // get the connection state.
269 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700270 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700272 eConnectionState_IbssConnected == connState ||
273 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 {
275 fConnected = VOS_TRUE;
276 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700277 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 {
279 fConnected = VOS_FALSE;
280 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700281
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 if ( pConnState )
283 {
284 *pConnState = connState;
285 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 return( fConnected );
288}
289
290v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
291{
292 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700293}
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530295eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
296{
297 v_U8_t staChannel = 0;
298
299 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
300 {
301 staChannel = pHddStaCtx->conn_info.operationChannel;
302 }
303
304 if ( staChannel > 0 && staChannel < 14 )
305 return eCSR_BAND_24;
306 else if (staChannel >= 36 && staChannel <= 165 )
307 return eCSR_BAND_5G;
308 else /* If station is not connected return as eCSR_BAND_ALL */
309 return eCSR_BAND_ALL;
310}
311
312
Jeff Johnson295189b2012-06-20 16:38:30 -0700313//TODO - Not used anyhwere. Can be removed.
314#if 0
315//
316v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
317{
318 v_BOOL_t fConnectedInfra = FALSE;
319 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700320
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700322 {
323 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 {
325 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700326 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700328
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 return( fConnectedInfra );
330}
331#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700332
Jeff Johnson295189b2012-06-20 16:38:30 -0700333static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
334{
335 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700336
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700338
339 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 {
341 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
342 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700343
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 return( fConnected );
345}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700346
Jeff Johnson295189b2012-06-20 16:38:30 -0700347inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
348{
349 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700350
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700352
353 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 {
355 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
356 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700357
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 return( fConnected );
359}
360
361static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
362{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700363 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 {
365 case eCSR_BSS_TYPE_INFRASTRUCTURE:
366 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
367 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700368
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 case eCSR_BSS_TYPE_IBSS:
370 case eCSR_BSS_TYPE_START_IBSS:
371 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
372 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700373
374 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700376 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 default:
378 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700379 break;
380 }
381
Jeff Johnson295189b2012-06-20 16:38:30 -0700382}
383
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530384/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530385 * hdd_copy_ht_caps()- Populate kernel HT caps structure object
386 * @hdd_ht_cap: HT capabilities of kernel type
387 * @roam_ht_cap: HT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530388 *
389 * Return: None
390 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530391void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
392 tDot11fIEHTCaps *roam_ht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530393{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530394 uint32_t i, temp_ht_cap;
395
396 vos_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
397
398 if (roam_ht_cap->advCodingCap)
399 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
400 if (roam_ht_cap->supportedChannelWidthSet)
401 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
402 temp_ht_cap = roam_ht_cap->mimoPowerSave &
403 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
404 if (temp_ht_cap)
405 hdd_ht_cap->cap_info |=
406 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
407 if (roam_ht_cap->greenField)
408 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
409 if (roam_ht_cap->shortGI20MHz)
410 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
411 if (roam_ht_cap->shortGI40MHz)
412 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
413 if (roam_ht_cap->txSTBC)
414 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
415 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
416 IEEE80211_HT_CAP_RX_STBC_SHIFT);
417 if (temp_ht_cap)
418 hdd_ht_cap->cap_info |=
419 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
420 if (roam_ht_cap->delayedBA)
421 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
422 if (roam_ht_cap->maximalAMSDUsize)
423 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
424 if (roam_ht_cap->dsssCckMode40MHz)
425 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
426 if (roam_ht_cap->psmp)
427 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
428 if (roam_ht_cap->stbcControlFrame)
429 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
430 if (roam_ht_cap->lsigTXOPProtection)
431 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
432
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530433 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
434 if (roam_ht_cap->maxRxAMPDUFactor)
435 hdd_ht_cap->ampdu_params_info |=
436 IEEE80211_HT_AMPDU_PARM_FACTOR;
437 temp_ht_cap = roam_ht_cap->mpduDensity &
438 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
439 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
440 if (temp_ht_cap)
441 hdd_ht_cap->ampdu_params_info |=
442 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
443
444 /* 802.11n HT extended capabilities masks */
445 if (roam_ht_cap->pco)
446 hdd_ht_cap->extended_ht_cap_info |=
447 IEEE80211_HT_EXT_CAP_PCO;
448 temp_ht_cap = roam_ht_cap->transitionTime &
449 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
450 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
451 if (temp_ht_cap)
452 hdd_ht_cap->extended_ht_cap_info |=
453 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
454 temp_ht_cap = roam_ht_cap->mcsFeedback &
455 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
456 if (temp_ht_cap)
457 hdd_ht_cap->extended_ht_cap_info |=
458 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
459
460 /* tx_bf_cap_info capabilities */
461 if (roam_ht_cap->txBF)
462 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
463 if (roam_ht_cap->rxStaggeredSounding)
464 hdd_ht_cap->tx_BF_cap_info |=
465 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
466 if (roam_ht_cap->txStaggeredSounding)
467 hdd_ht_cap->tx_BF_cap_info |=
468 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
469 if (roam_ht_cap->rxZLF)
470 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
471 if (roam_ht_cap->txZLF)
472 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
473 if (roam_ht_cap->implicitTxBF)
474 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
475 temp_ht_cap = roam_ht_cap->calibration &
476 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
477 if (temp_ht_cap)
478 hdd_ht_cap->tx_BF_cap_info |=
479 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
480 if (roam_ht_cap->explicitCSITxBF)
481 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
482 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
483 hdd_ht_cap->tx_BF_cap_info |=
484 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
485 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
486 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
487 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
488 if (temp_ht_cap)
489 hdd_ht_cap->tx_BF_cap_info |=
490 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
491 temp_ht_cap =
492 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
493 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
494 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
495 if (temp_ht_cap)
496 hdd_ht_cap->tx_BF_cap_info |=
497 temp_ht_cap <<
498 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
499 temp_ht_cap =
500 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
501 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
502 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
503 if (temp_ht_cap)
504 hdd_ht_cap->tx_BF_cap_info |=
505 temp_ht_cap <<
506 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
507 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
508 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
509 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
510 if (temp_ht_cap)
511 hdd_ht_cap->tx_BF_cap_info |=
512 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
513 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
514 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
515 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
516 if (temp_ht_cap)
517 hdd_ht_cap->tx_BF_cap_info |=
518 temp_ht_cap <<
519 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
520 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
521 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
522 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
523 if (temp_ht_cap)
524 hdd_ht_cap->tx_BF_cap_info |=
525 temp_ht_cap <<
526 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
527
528 /* antenna selection */
529 if (roam_ht_cap->antennaSelection)
530 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
531 if (roam_ht_cap->explicitCSIFeedbackTx)
532 hdd_ht_cap->antenna_selection_info |=
533 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
534 if (roam_ht_cap->antennaIndicesFeedbackTx)
535 hdd_ht_cap->antenna_selection_info |=
536 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
537 if (roam_ht_cap->explicitCSIFeedback)
538 hdd_ht_cap->antenna_selection_info |=
539 ANTENNA_SEL_INFO_EXP_CSI_FB;
540 if (roam_ht_cap->antennaIndicesFeedback)
541 hdd_ht_cap->antenna_selection_info |=
542 ANTENNA_SEL_INFO_ANT_ID_FB;
543 if (roam_ht_cap->rxAS)
544 hdd_ht_cap->antenna_selection_info |=
545 ANTENNA_SEL_INFO_RX_AS;
546 if (roam_ht_cap->txSoundingPPDUs)
547 hdd_ht_cap->antenna_selection_info |=
548 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
549
550 /* mcs data rate */
551 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
552 hdd_ht_cap->mcs.rx_mask[i] =
553 roam_ht_cap->supportedMCSSet[i];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530554
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530555 hdd_ht_cap->mcs.rx_highest =
556 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
557 ((short) (roam_ht_cap->supportedMCSSet[10]));
558 hdd_ht_cap->mcs.tx_params =
559 roam_ht_cap->supportedMCSSet[12];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530560
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530561}
562
563
564#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
565#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
566#define VHT_CAP_RXSTBC_MASK_SHIFT 8
567#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
568#define VHT_CAP_BEAMFORMEE_STS_MASK \
569 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
570#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
571#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
572 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
573#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
574#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
575 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
576#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
577
578/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530579 * hdd_copy_vht_caps()- Populate kernel VHT caps structure object
580 * @hdd_ht_cap: VHT capabilities of kernel type
581 * @roam_ht_cap: VHT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530582 *
583 * Return: None
584 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530585void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
586 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530587{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530588 uint32_t temp_vht_cap;
589
590 vos_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
591
592 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
593 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
594 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
595 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
596 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
597 if (temp_vht_cap)
598 if (roam_vht_cap->supportedChannelWidthSet &
599 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
600 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
601 hdd_vht_cap->vht_cap_info |=
602 temp_vht_cap <<
603 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
604 if (roam_vht_cap->supportedChannelWidthSet &
605 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
606 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
607 hdd_vht_cap->vht_cap_info |=
608 temp_vht_cap <<
609 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
610 if (roam_vht_cap->ldpcCodingCap)
611 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
612 if (roam_vht_cap->shortGI80MHz)
613 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
614 if (roam_vht_cap->shortGI160and80plus80MHz)
615 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
616 if (roam_vht_cap->txSTBC)
617 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
618 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
619 VHT_CAP_RXSTBC_MASK_SHIFT);
620 if (temp_vht_cap)
621 hdd_vht_cap->vht_cap_info |=
622 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
623 if (roam_vht_cap->suBeamFormerCap)
624 hdd_vht_cap->vht_cap_info |=
625 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
626 if (roam_vht_cap->suBeamformeeCap)
627 hdd_vht_cap->vht_cap_info |=
628 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
629 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
630 (VHT_CAP_BEAMFORMEE_STS_MASK);
631 if (temp_vht_cap)
632 hdd_vht_cap->vht_cap_info |=
633 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
634 temp_vht_cap = roam_vht_cap->numSoundingDim &
635 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
636 if (temp_vht_cap)
637 hdd_vht_cap->vht_cap_info |=
638 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
639 if (roam_vht_cap->muBeamformerCap)
640 hdd_vht_cap->vht_cap_info |=
641 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
642 if (roam_vht_cap->muBeamformeeCap)
643 hdd_vht_cap->vht_cap_info |=
644 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
645 if (roam_vht_cap->vhtTXOPPS)
646 hdd_vht_cap->vht_cap_info |=
647 IEEE80211_VHT_CAP_VHT_TXOP_PS;
648 if (roam_vht_cap->htcVHTCap)
649 hdd_vht_cap->vht_cap_info |=
650 IEEE80211_VHT_CAP_HTC_VHT;
651 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
652 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
653 if (temp_vht_cap)
654 hdd_vht_cap->vht_cap_info |=
655 temp_vht_cap <<
656 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
657 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
658 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
659 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
660 if (temp_vht_cap)
661 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
662 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
663 if (roam_vht_cap->rxAntPattern)
664 hdd_vht_cap->vht_cap_info |=
665 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
666 if (roam_vht_cap->txAntPattern)
667 hdd_vht_cap->vht_cap_info |=
668 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
669 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
670 hdd_vht_cap->supp_mcs.rx_highest =
671 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
672 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
673 hdd_vht_cap->supp_mcs.tx_highest =
674 ((uint16_t)roam_vht_cap->txSupDataRate);
675}
676
677/* ht param */
678#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
679#define HT_PARAM_SERVICE_INT_GRAN 0xe0
680#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
681
682/* operatinon mode */
683#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
684
685/* stbc_param */
686#define HT_STBC_PARAM_MCS 0x007f
687
688/**
689 * hdd_copy_ht_operation()- copy HT operation element from roam info to
690 * hdd station context.
691 * @hdd_sta_ctx: pointer to hdd station context
692 * @roam_info: pointer to roam info
693 *
694 * Return: None
695 */
696static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
697 tCsrRoamInfo *roam_info)
698{
699 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
700 struct ieee80211_ht_operation *hdd_ht_ops =
701 &hdd_sta_ctx->conn_info.ht_operation;
702 uint32_t i, temp_ht_ops;
703
704 vos_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
705
706 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
707
708 /* HT_PARAMS */
709 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
710 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
711 if (temp_ht_ops)
712 hdd_ht_ops->ht_param |= temp_ht_ops;
713 else
714 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
715 if (roam_ht_ops->recommendedTxWidthSet)
716 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
717 if (roam_ht_ops->rifsMode)
718 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
719 if (roam_ht_ops->controlledAccessOnly)
720 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
721 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
722 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
723 if (temp_ht_ops)
724 hdd_ht_ops->ht_param |= temp_ht_ops <<
725 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
726
727 /* operation mode */
728 temp_ht_ops = roam_ht_ops->opMode &
729 IEEE80211_HT_OP_MODE_PROTECTION;
730 switch (temp_ht_ops) {
731 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
732 hdd_ht_ops->operation_mode |=
733 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
734 break;
735 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
736 hdd_ht_ops->operation_mode |=
737 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
738 break;
739 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
740 hdd_ht_ops->operation_mode |=
741 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
742 break;
743 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
744 default:
745 hdd_ht_ops->operation_mode |=
746 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
747 }
748 if (roam_ht_ops->nonGFDevicesPresent)
749 hdd_ht_ops->operation_mode |=
750 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
751 if (roam_ht_ops->transmitBurstLimit)
752 hdd_ht_ops->operation_mode |=
753 HT_OP_MODE_TX_BURST_LIMIT;
754 if (roam_ht_ops->obssNonHTStaPresent)
755 hdd_ht_ops->operation_mode |=
756 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
757
758 /* stbc_param */
759 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
760 HT_STBC_PARAM_MCS;
761 if (temp_ht_ops)
762 hdd_ht_ops->stbc_param |= temp_ht_ops;
763 if (roam_ht_ops->dualCTSProtection)
764 hdd_ht_ops->stbc_param |=
765 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
766 if (roam_ht_ops->secondaryBeacon)
767 hdd_ht_ops->stbc_param |=
768 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
769 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
770 hdd_ht_ops->stbc_param |=
771 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
772 if (roam_ht_ops->pcoActive)
773 hdd_ht_ops->stbc_param |=
774 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
775 if (roam_ht_ops->pcoPhase)
776 hdd_ht_ops->stbc_param |=
777 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
778
779 /* basic MCs set */
780 for (i = 0; i < 16; ++i)
781 hdd_ht_ops->basic_set[i] =
782 roam_ht_ops->basicMCSSet[i];
783}
784
785/**
786 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
787 * hdd station context.
788 * @hdd_sta_ctx: pointer to hdd station context
789 * @roam_info: pointer to roam info
790 *
791 * Return: None
792 */
793static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
794 tCsrRoamInfo *roam_info)
795{
796 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
797 struct ieee80211_vht_operation *hdd_vht_ops =
798 &hdd_sta_ctx->conn_info.vht_operation;
799
800 vos_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
801
802 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
803 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
804 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
805 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
806}
807
808
809/**
810 * hdd_save_bss_info() - save connection info in hdd sta ctx
811 * @adapter: Pointer to adapter
812 * @roam_info: pointer to roam info
813 *
814 * Return: None
815 */
816static void hdd_save_bss_info(hdd_adapter_t *adapter,
817 tCsrRoamInfo *roam_info)
818{
819 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
820
821 hdd_sta_ctx->conn_info.freq = vos_chan_to_freq(
822 hdd_sta_ctx->conn_info.operationChannel);
823 if (roam_info->vht_caps.present) {
824 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530825 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
826 &roam_info->vht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530827 } else {
828 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
829 }
830 if (roam_info->ht_caps.present) {
831 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530832 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps, &roam_info->ht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530833 } else {
834 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
835 }
836 if (roam_info->reassoc)
837 hdd_sta_ctx->conn_info.roam_count++;
838 if (roam_info->hs20vendor_ie.present) {
839 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
840 vos_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
841 &roam_info->hs20vendor_ie,
842 sizeof(roam_info->hs20vendor_ie));
843 } else {
844 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
845 }
846 if (roam_info->ht_operation.present) {
847 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
848 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
849 } else {
850 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
851 }
852 if (roam_info->vht_operation.present) {
853 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
854 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
855 } else {
856 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
857 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +0530858 /* Cache last connection info */
859 vos_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
860 sizeof(connection_info_t));
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530861}
862
Jeff Johnson295189b2012-06-20 16:38:30 -0700863void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
864{
865 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
866 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700867
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700869
870 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700872 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
874 {
875 VOS_ASSERT( pRoamInfo->pBssDesc );
876 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
877
878 // Save the Station ID for this station from the 'Roam Info'.
879 //For IBSS mode, staId is assigned in NEW_PEER_IND
880 //For reassoc, the staID doesn't change and it may be invalid in this structure
881 //so no change here.
882 if( !pRoamInfo->fReassocReq )
883 {
884 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
885 }
886 }
887 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700888 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700890 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 else
892 {
893 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
894 // or we can't function.
895 VOS_ASSERT( 0 );
896 }
897
898 // notify WMM
899 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
900
901 if( !pRoamInfo->u.pConnectedProfile )
902 {
903 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
904 }
905 else
906 {
907 // Get Multicast Encryption Type
908 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
909 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
910 // Get Unicast Encrytion Type
911 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
912 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
913
914 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
915
916 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
917
918 // Save the ssid for the connection
919 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530920
921 // Save dot11mode in which STA associated to AP
922 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530923
924 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 }
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530926 hdd_save_bss_info(pAdapter, pRoamInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700927 }
928
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700930 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932}
933
934#if defined(WLAN_FEATURE_VOWIFI_11R)
935/*
936 * Send the 11R key information to the supplicant.
937 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800938 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 * for the same purpose.)
940 *
941 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
942 * this contains the R1KHID, R0KHID and the MDID.
943 * For FT, this consists of the Reassoc Rsp FTIEs.
944 * This is the Assoc Response.
945 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700946static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 tCsrRoamInfo *pCsrRoamInfo)
948{
949 union iwreq_data wrqu;
950 char *buff;
951 unsigned int len = 0;
952 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700953
Ashish Kumar Dhanotiyaa1a9aaa2020-02-11 17:57:11 +0530954 if (pCsrRoamInfo->nAssocRspLength < FT_ASSOC_RSP_IES_OFFSET)
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 {
956 hddLog(LOGE,
Ashish Kumar Dhanotiyaa1a9aaa2020-02-11 17:57:11 +0530957 "%s: Invalid assoc rsp length %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 __func__, (int)pCsrRoamInfo->nAssocRspLength);
959 return;
960 }
961
Shailender Karmuchia734f332013-04-19 14:02:48 -0700962 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700964 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700966 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 return;
968 }
969
970 // pFTAssocRsp needs to point to the IEs
971 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
972 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
973 (unsigned int)pFTAssocRsp[0],
974 (unsigned int)pFTAssocRsp[1]);
975
Ashish Kumar Dhanotiyaa1a9aaa2020-02-11 17:57:11 +0530976 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
977 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
978 if (len > IW_GENERIC_IE_MAX) {
979 hddLog(LOGE,
980 "%s: Invalid assoc rsp length %d",
981 __func__, (int)pCsrRoamInfo->nAssocRspLength);
982 return;
983 }
984 wrqu.data.length = len;
985
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 // We need to send the IEs to the supplicant.
987 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700988 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700990 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 return;
992 }
993
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700995 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
997
998 kfree(buff);
999}
Shailender Karmuchia734f332013-04-19 14:02:48 -07001000#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07001001
1002#ifdef WLAN_FEATURE_VOWIFI_11R
1003
1004/*---------------------------------------------------
1005 *
1006 * Send the FTIEs, RIC IEs during FT. This is eventually
1007 * used to send the FT events to the supplicant
1008 *
1009 * At the reception of Auth2 we send the RIC followed
1010 * by the auth response IEs to the supplicant.
1011 * Once both are received in the supplicant, an FT
1012 * event is generated to the supplicant.
1013 *
1014 *---------------------------------------------------
1015 */
1016void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
1017{
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 tANI_U16 auth_resp_len = 0;
1019 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1021
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05301022#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001023 struct cfg80211_ft_event_params ftEvent;
1024 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1025 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
1026 struct net_device *dev = pAdapter->dev;
1027#else
1028 char *buff;
1029 union iwreq_data wrqu;
1030 tANI_U16 str_len;
1031#endif
1032
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05301033#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301034 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1035 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001036
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +05301037 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
1038 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301039 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001040 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301041 hddLog(LOGW,
1042 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1043 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001044 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001045
1046 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301047 ftEvent.ric_ies_len = ric_ies_length;
1048 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001049
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301050 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001051 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001052
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301053 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001054 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301055 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001056 return;
1057 }
1058
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301059 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301060
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301061 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001062
1063 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
1064 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
1065
Jeff Johnson59a121e2013-11-30 09:46:08 -08001066 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
1067 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
1068 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301069 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001070 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
1071 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1072 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001073
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301074 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001075
1076#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301077 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301079 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301081 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 return;
1083 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301084 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001085
Shailender Karmuchia734f332013-04-19 14:02:48 -07001086 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301088 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001089 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301090 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301092 hddLog(LOGW,
1093 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1094 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 }
1096 else
1097 {
1098 wrqu.data.length = str_len + ric_ies_length;
1099 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1100 }
1101
1102 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301103 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301105 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
1106 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001107
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301108 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301110 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +05301111 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 return;
1113 }
1114
1115 wrqu.data.length = str_len + auth_resp_len;
1116 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1117
1118 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001119#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001120}
1121
1122#endif /* WLAN_FEATURE_VOWIFI_11R */
1123
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001124#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001125
1126/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001127 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 * (This keeps the supplicant "up to date" on the current channel.)
1129 *
1130 * The current (new AP) channel information is passed in.
1131 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001132static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 tCsrRoamInfo *pCsrRoamInfo)
1134{
1135 union iwreq_data wrqu;
1136 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001137
Shailender Karmuchia734f332013-04-19 14:02:48 -07001138
1139 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 {
1141 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001142 "%s: pCsrRoamInfo->pBssDesc=%pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 __func__, descriptor);
1144 return;
1145 }
1146
1147 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -08001148 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 memset(&wrqu, '\0', sizeof(wrqu));
1150 wrqu.freq.m = descriptor->channelId;
1151 wrqu.freq.e = 0;
1152 wrqu.freq.i = 0;
1153 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1154}
1155
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001156#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001157
1158void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
1159{
1160 union iwreq_data wrqu;
1161 u8 *pBeaconIes;
1162 u8 currentLen = 0;
1163 char *buff;
1164 int totalIeLen = 0, currentOffset = 0, strLen;
1165
1166 memset(&wrqu, '\0', sizeof(wrqu));
1167
1168 if (0 == pCsrRoamInfo->nBeaconLength)
1169 {
1170 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
1171 return;
1172 }
1173 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001174 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001176 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 return;
1178 }
1179
1180 // pBeaconIes needs to point to the IEs
1181 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
1182 (unsigned int)pBeaconIes[0],
1183 (unsigned int)pBeaconIes[1]);
1184 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001185
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 // We need to send the IEs to the supplicant.
1187 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001188 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001190 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 return;
1192 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001193 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001194
1195 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
1196 currentLen = strLen + 1;
1197
1198 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1199 do
1200 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001201 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 * max size and send it to supplicant. Changes are done in supplicant to handle this */
1203 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
1204 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
1205 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
1206 currentOffset += currentLen;
1207 totalIeLen -= currentLen;
1208 wrqu.data.length = strLen + 1 + currentLen;
1209 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -07001210 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 else
1212 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
1213
1214 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
1215 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1216 } while (totalIeLen > 0);
1217
1218 kfree(buff);
1219}
1220
1221static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
1222{
1223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1224 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1225 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1226 union iwreq_data wrqu;
1227 int we_event;
1228 char *msg;
1229 int type = -1;
1230
Shailender Karmuchia734f332013-04-19 14:02:48 -07001231#if defined (WLAN_FEATURE_VOWIFI_11R)
1232 // Added to find the auth type on the fly at run time
1233 // rather than with cfg to see if FT is enabled
1234 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
1236#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001237
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001239 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001241
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
1243 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301244 /* In case of roaming ; We are not doing disconnect.
1245 * If disconnect is not being done for roam; We will not
1246 * decrease count for Active sessions. We should not increase active
1247 * active session in case of roaming.
1248 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +05301249 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +05301250 {
1251 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
1252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
1254 type = WLAN_STA_ASSOC_DONE_IND;
1255
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001256#ifdef WLAN_FEATURE_P2P_DEBUG
1257 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1258 {
1259 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
1260 {
1261 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
1262 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1263 "Connecting state to Connected State for 8-way "
1264 "Handshake");
1265 }
1266 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
1267 {
1268 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
1269 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1270 "Connecting state to P2P Client Connection Completed");
1271 }
1272 }
1273#endif
Yeshwanth Sriram Guntuka0004c0b2017-12-06 14:43:49 +05301274 hddLog(VOS_TRACE_LEVEL_ERROR, MAC_ADDRESS_STR " connected to "
1275 MAC_ADDRESS_STR,
1276 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1277 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
1279
Bhargav Shahd0715912015-10-01 18:17:37 +05301280 hdd_manage_delack_timer(pHddCtx);
1281
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
1283 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
1284 * and fFTEnable is TRUE */
1285#ifdef WLAN_FEATURE_VOWIFI_11R
1286 // Send FT Keys to the supplicant when FT is enabled
1287 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -07001288 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001289#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1291 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
1292#endif
1293 )
1294 {
1295 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
1296 }
1297#endif
1298 }
1299 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
1300 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301301 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -07001302 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301304
1305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1306 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
1307 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 }
1309 else /* Not Associated */
1310 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301311 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1312 "wlan: disconnected");
gaurank kathpalia51801582019-04-05 13:56:55 +05301313 if (pHddCtx->btCoexModeSet) {
1314 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1315 FL("Wlan disconnected, sending DHCP stop indication"));
1316 pHddCtx->btCoexModeSet = FALSE;
1317 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
1318 pAdapter->sessionId);
1319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 type = WLAN_STA_DISASSOC_DONE_IND;
1321 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +05301322
1323 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001325 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001326
1327 msg = NULL;
1328 /*During the WLAN uninitialization,supplicant is stopped before the
1329 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301330 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 {
1332 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001333#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001335 {
1336 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1337 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
1339 }
1340#endif
1341 }
1342 send_btc_nlink_msg(type, 0);
1343}
1344
1345void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
1346{
1347 // Remove staId, bssId and peerMacAddress
1348 pHddStaCtx->conn_info.staId [ 0 ] = 0;
1349 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
1350 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
1351
1352 // Clear all security settings
1353 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1354 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1355 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1356
1357 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -07001358 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001359
1360 // Set not-connected state
1361 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -07001362
1363 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
1364}
Katya Nigam47528772015-02-11 12:24:49 +05301365
1366VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
1367{
Katya Nigam1fd24402015-02-16 14:52:19 +05301368 v_U8_t ac;
1369 /**Track whether OS TX queue has been disabled.*/
1370 v_BOOL_t txSuspended[NUM_TX_QUEUES];
1371 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +05301372 v_U8_t i;
1373 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1374 hdd_ibss_peer_info_t *pPeerInfo;
1375
1376 if( NULL == pHddStaCtx )
1377 {
1378 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1379 "%s: HDD station context NULL ",__func__);
1380 return VOS_STATUS_E_FAILURE;
1381 }
Katya Nigam1fd24402015-02-16 14:52:19 +05301382
Katya Nigam47528772015-02-11 12:24:49 +05301383 pPeerInfo = &pHddStaCtx->ibss_peer_info;
1384 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
1385 {
1386 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1387 "%s: Deinit station not inited %d", __func__, STAId );
1388 return VOS_STATUS_E_FAILURE;
1389 }
1390
1391 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +05301392
1393 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1394 {
1395 tlAC = hdd_QdiscAcToTlAC[ac];
1396 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
1397 }
1398
Katya Nigam47528772015-02-11 12:24:49 +05301399 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1400
Katya Nigam1fd24402015-02-16 14:52:19 +05301401 /* re-init hdd list, since netdev can still open adapter until
1402 * driver gets unloaded
1403 */
1404 for (i = 0; i < NUM_TX_QUEUES; i ++)
1405 {
1406 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
1407 HDD_TX_QUEUE_MAX_LEN);
1408 }
1409
1410 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1411 {
1412 if (txSuspended[ac])
1413 {
1414 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1415 "%s: TX queue re-enabled", __func__);
1416 netif_wake_subqueue(pAdapter->dev, ac);
1417 }
1418 }
Katya Nigam47528772015-02-11 12:24:49 +05301419 return VOS_STATUS_SUCCESS;
1420}
1421
1422static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1423{
1424 VOS_STATUS vosStatus;
1425
1426 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1427 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1428 {
1429 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1430 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1431 "Status= %d [0x%08X]",
1432 __func__, staId, vosStatus, vosStatus );
1433 }
1434
1435 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
1436 if( VOS_STATUS_E_FAILURE == vosStatus )
1437 {
1438 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1439 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
1440 "Status = %d [0x%08X]",
1441 staId, vosStatus, vosStatus );
1442 }
1443
1444 return( vosStatus );
1445}
1446
1447VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
1448{
1449 v_U8_t i = 0;
1450 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1451 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1452
1453 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
1454 {
1455 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1456 "%s: Reinit station %d", __func__, STAId );
1457 return VOS_STATUS_E_FAILURE;
1458 }
1459
1460 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1461 for (i = 0; i < NUM_TX_QUEUES; i ++)
1462 {
1463 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
1464 }
1465
1466 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
1467 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
1468 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
1469
1470 return VOS_STATUS_SUCCESS;
1471}
1472
1473static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
1474 tCsrRoamInfo *pRoamInfo,
1475 v_U8_t staId,
1476 v_MACADDR_t *pPeerMacAddress,
1477 tSirBssDescription *pBssDesc )
1478{
1479 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1480 WLAN_STADescType staDesc = {0};
1481 eCsrEncryptionType connectedCipherAlgo;
1482 v_BOOL_t fConnected;
1483 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1484 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1485 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1486
1487 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
1488 {
1489 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1490 "clean up old entry for STA %d", staId);
1491 hdd_ibss_DeregisterSTA( pAdapter, staId );
1492 }
1493
1494 staDesc.ucSTAId = staId;
1495 staDesc.wSTAType = WLAN_STA_IBSS;
1496
1497 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1498 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1499 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1500 // pass when making an Infrastructure connection.
1501 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
1502 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
1503 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1504
1505 if (hdd_wmm_is_active(pAdapter))
1506 {
1507 staDesc.ucQosEnabled = 1;
1508 }
1509 else
1510 {
1511 staDesc.ucQosEnabled = 0;
1512 }
1513 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1514 "HDD SOFTAP register TL QoS_enabled=%d",
1515 staDesc.ucQosEnabled );
1516
1517 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1518 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1519 {
1520 staDesc.ucProtectedFrame = 1;
1521 }
1522 else
1523 {
1524 staDesc.ucProtectedFrame = 0;
1525
1526 }
1527
1528 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
1529
1530 // UMA is Not ready yet, Xlation will be done by TL
1531 staDesc.ucSwFrameTXXlation = 1;
1532 staDesc.ucSwFrameRXXlation = 1;
1533 staDesc.ucAddRmvLLC = 1;
1534 // Initialize signatures and state
1535 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1536 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1537 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
1538
1539 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1540
1541 // Register the Station with TL.
1542 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1543 hdd_rx_packet_cbk,
1544 hdd_tx_complete_cbk,
1545 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
1546 pBssDesc->rssi );
1547 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1548 {
1549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1550 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
1551 vosStatus, vosStatus );
1552 return vosStatus;
1553 }
1554
1555 //Timer value should be in milliseconds
1556 if ( pHddCtx->cfg_ini->dynSplitscan &&
1557 ( VOS_TIMER_STATE_RUNNING !=
1558 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1559 {
1560 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1561 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
1562 }
1563
1564 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
1565 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
1566
1567 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
1568 WLANTL_STA_AUTHENTICATED );
1569
1570 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
1571 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1572
1573 return( vosStatus );
1574}
1575
Jeff Johnson295189b2012-06-20 16:38:30 -07001576/* TODO Revist this function. and data path */
1577static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1578{
1579 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -07001580
Katya Nigam47528772015-02-11 12:24:49 +05301581 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -07001582
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1584 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1585 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05301586 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001588 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001589 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 }
1591 return( vosStatus );
1592}
1593
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301594/**
1595 * hdd_print_bss_info() - print bss info
1596 * @hdd_sta_ctx: pointer to hdd station context
1597 *
1598 * Return: None
1599 */
1600void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
1601{
1602 uint32_t *cap_info;
1603
1604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"WIFI DATA LOGGER");
1605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"channel: %d",
1606 hdd_sta_ctx->conn_info.freq);
1607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"dot11mode: %d",
1608 hdd_sta_ctx->conn_info.dot11Mode);
1609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"AKM: %d",
1610 hdd_sta_ctx->conn_info.authType);
1611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ssid: %.*s",
1612 hdd_sta_ctx->conn_info.SSID.SSID.length,
1613 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"roam count: %d",
1615 hdd_sta_ctx->conn_info.roam_count);
1616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ant_info: %d",
1617 hdd_sta_ctx->conn_info.txrate.nss);
1618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate legacy %d",
1619 hdd_sta_ctx->conn_info.txrate.legacy);
1620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate mcs: %d",
1621 hdd_sta_ctx->conn_info.txrate.mcs);
1622 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1623 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ht caps: %x",
1625 *cap_info);
1626 }
1627 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1628 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"vht caps: %x",
1630 *cap_info);
1631 }
1632 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"hs20 info: %x",
1634 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"signal: %d",
1636 hdd_sta_ctx->conn_info.signal);
1637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"noise: %d",
1638 hdd_sta_ctx->conn_info.noise);
1639}
1640
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301641/**
1642 * hdd_check_and_move_if_sap_is_on_dfs_chan() - move the sap to non dfs channel
1643 * @hdd_ctx: pointer to hdd context
1644 * @sta_adapter: pointer to sta adapater
1645 *
1646 * This function is used to check if SAP is operating on DFS channel in stand
1647 * alone mode and move it to non dfs channel
1648 *
1649 * Return: void.
1650 */
1651static void hdd_check_and_move_if_sap_is_on_dfs_chan(hdd_context_t *hdd_ctx,
1652 hdd_adapter_t *sta_adapter)
1653{
1654 hdd_adapter_t *sap_adapter;
1655 ptSapContext sap_ctx;
1656 v_CONTEXT_t vos_ctx;
1657 eNVChannelEnabledType chan_state;
1658
1659 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_ctx)) {
1660 sap_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_SOFTAP);
1661
1662 if (!sap_adapter) {
1663 hddLog(LOG1, FL("SAP not exists, nothing to do"));
1664 return;
1665 }
1666
1667 vos_ctx = hdd_ctx->pvosContext;
1668 if (!vos_ctx) {
1669 hddLog(LOGE, FL("vos_ctx is NULL"));
1670 return;
1671 }
1672 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
1673 if (!sap_ctx) {
1674 hddLog(LOG1, FL("sap_ctx not exists"));
1675 return;
1676 }
1677
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301678 if (sap_ctx->sapsMachine != eSAP_STARTED) {
1679 hddLog(LOG1, FL("SAP is not in eSAP_STARTED state"));
1680 return;
1681 }
1682
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301683 chan_state = vos_nv_getChannelEnabledState(sap_ctx->channel);
1684
1685 hddLog(LOG1, "SAP is operating on channel (%hu), chan_state %d",
1686 sap_ctx->channel, chan_state);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301687 if (vos_nv_getChannelEnabledState(sap_ctx->channel) !=
1688 NV_CHANNEL_DFS) {
1689 hddLog(LOG1, "SAP is on non DFS channel. nothing to do");
1690 return;
1691 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301692
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301693 hddLog(LOG1, "Schedule workqueue to move the SAP to non DFS channel");
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301694 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
1695 msecs_to_jiffies(ECSA_DFS_CHAN_CHANGE_DEFER_TIME));
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301696 }
1697}
Jeff Johnson295189b2012-06-20 16:38:30 -07001698
1699static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1700 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1701 eCsrRoamResult roamResult )
1702{
1703 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07001704 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 struct net_device *dev = pAdapter->dev;
1706 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1707 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -07001708 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301709 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001710
1711 // Sanity check
1712 if(dev == NULL)
1713 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301714 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001715 "%s: net_dev is released return", __func__);
1716 return eHAL_STATUS_FAILURE;
1717 }
1718
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301720 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 netif_tx_disable(dev);
1722 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301723 //TxTimeoutCount need to reset in case of disconnect handler
1724 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001725
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301726 wlan_hdd_check_and_stop_mon(pAdapter, false);
1727
Jeff Johnsone7245742012-09-05 17:12:55 -07001728 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301729 /* If only STA mode is on */
1730 if((pHddCtx->concurrency_mode <= 1) &&
1731 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1732 {
1733 pHddCtx->isAmpAllowed = VOS_TRUE;
1734 }
1735
Agarwal Ashish47d18112014-08-04 19:55:07 +05301736 /* Need to apply spin lock before decreasing active sessions
1737 * as there can be chance for double decrement if context switch
1738 * Calls wlan_hdd_disconnect.
1739 */
1740
1741 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301742
1743 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301744 * to kernel. Sending disconnected event to kernel for userspace
1745 * initiated disconnect will be handled by diconnect handler call
1746 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301747 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301748 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301749 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) ||
1750 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301751 {
1752 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1753 FL(" HDD has initiated a disconnect, no need to send"
1754 " disconnect indication to kernel"));
1755 sendDisconInd = FALSE;
1756 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301757 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301760 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301761 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301762 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1763 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301765 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh78c691f2017-11-30 13:48:44 +05301766 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001768
1769 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001770
1771 // indicate 'disconnect' status to wpa_supplicant...
1772 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 /* indicate disconnected event to nl80211 */
1774 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1775 {
1776 /*During the WLAN uninitialization,supplicant is stopped before the
1777 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301778 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301780 if (sendDisconInd)
1781 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1782 "%s: sent disconnected event to nl80211",
1783 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001784#ifdef WLAN_FEATURE_P2P_DEBUG
1785 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1786 {
1787 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1788 {
1789 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1790 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1791 "and moved to disconnected state");
1792 }
1793 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1794 {
1795 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1796 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1797 "and moved to inactive state");
1798 }
1799 }
1800#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301801 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1802 !pRoamInfo->reasonCode)
1803 wlan_hdd_get_frame_logs(pAdapter,
1804 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301805 /*Only send indication to kernel if not initiated by kernel*/
1806 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301808 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1809 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1810 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301811 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1812 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301813 }
1814 else
1815 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301816 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301817 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301820
1821 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1822 {
1823 hddLog(LOG1,
1824 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1825 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301826 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301827
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 //If the Device Mode is Station
1829 // and the P2P Client is Connected
1830 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001831
1832 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001833 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001834 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 {
1836 //Enable BMPS only of other Session is P2P Client
1837 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001838 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001839
1840 if (NULL != pVosContext)
1841 {
1842 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1843
1844 if(NULL != pHddCtx)
1845 {
1846 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301847 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1848 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301850 if (pHddCtx->hdd_wlan_suspended)
1851 {
1852 hdd_set_pwrparams(pHddCtx);
1853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 }
1857 }
1858 }
1859 }
1860 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001861
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301862 hdd_wmm_adapter_clear(pAdapter);
Kapil Guptae6867482016-06-26 13:31:37 +05301863 /* Clear PER based roam stats */
1864#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1865 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1866 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1867 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1868 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1869 sme_unset_per_roam_rxconfig(pHddCtx->hHal);
1870#endif
Mukul Sharmac159c432014-01-15 15:42:46 +05301871#if defined(WLAN_FEATURE_VOWIFI_11R)
1872 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1873#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301874
1875 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1876 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301877 v_U8_t i;
1878
Katya Nigam63ce1772014-09-26 15:53:49 +05301879 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301880 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301881 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1882 {
1883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301884 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1885 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301886 sta_id, status, status );
1887
1888 status = eHAL_STATUS_FAILURE;
1889 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301890 pHddCtx->sta_to_adapter[sta_id] = NULL;
1891
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301892 /*Clear all the peer sta register with TL.*/
1893 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1894 {
1895 if (0 != pHddStaCtx->conn_info.staId[i])
1896 {
1897 sta_id = pHddStaCtx->conn_info.staId[i];
1898
1899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1900 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301901 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301902 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1903 {
1904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1905 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1906 "Status= %d [0x%x]"),
1907 sta_id, status, status );
1908 status = eHAL_STATUS_FAILURE;
1909 }
1910
Nirav Shah7e3c8132015-06-22 23:51:42 +05301911 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1912 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1913 if (vstatus != VOS_STATUS_SUCCESS) {
1914 hddLog(VOS_TRACE_LEVEL_ERROR,
1915 FL("Not able to remove staid hash %d"),
1916 sta_id);
1917 status = eHAL_STATUS_FAILURE;
1918 } else {
1919 hddLog(VOS_TRACE_LEVEL_INFO,
1920 FL("ibss station removed sta_id %d mac:"
1921 MAC_ADDRESS_STR), sta_id,
1922 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1923 }
1924
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301925 /*set the staid and peer mac as 0, all other reset are
1926 * done in hdd_connRemoveConnectInfo.
1927 */
1928 pHddStaCtx->conn_info.staId[i]= 0;
1929 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1930
1931 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1932 pHddCtx->sta_to_adapter[sta_id] = NULL;
1933 }
1934 }
1935
Katya Nigam63ce1772014-09-26 15:53:49 +05301936 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301937 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301939 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301940 /* clear scan cache for Link Lost */
1941 if (pRoamInfo && !pRoamInfo->reasonCode &&
1942 (eCSR_ROAM_LOSTLINK == roamStatus)) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05301943 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301944 pHddStaCtx->conn_info.bssId);
1945 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1946 pHddStaCtx->conn_info.bssId);
1947 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301948
1949 //We should clear all sta register with TL, for now, only one.
1950 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1951 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1952 {
1953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1954 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1955 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001956 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001957
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301958 status = eHAL_STATUS_FAILURE;
1959 }
1960
1961 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301963
1964#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1965 if (VOS_STATUS_SUCCESS !=
1966 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1967 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1968 {
1969 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1970 "WLANTL_ClearInterfaceStats Failed", __func__);
1971 }
1972 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1973 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1974 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1975 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1976#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Sravan Kumar Kairamf9f95122017-01-18 20:54:05 +05301977 pAdapter->dad = false;
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301978
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 // Clear saved connection information in HDD
1980 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301981
1982 /*
1983 * eConnectionState_Connecting state mean that connection is in progress so
1984 * no need to set state to eConnectionState_NotConnected
1985 */
1986 if ((eConnectionState_Connecting != pHddStaCtx->conn_info.connState)) {
1987 hddLog(LOG1, FL("Set HDD connState to eConnectionState_NotConnected"));
1988 hdd_connSetConnectionState(pHddStaCtx, eConnectionState_NotConnected);
1989 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301990#ifdef WLAN_FEATURE_GTK_OFFLOAD
1991 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1992 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1993 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301994 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1995 sizeof (tSirGtkOffloadParams));
1996 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301997 }
1998#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001999
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002000#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07002001 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
2002 {
2003 wlan_hdd_tdls_disconnection_callback(pAdapter);
2004 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002005#endif
2006
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 //Unblock anyone waiting for disconnect to complete
2008 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302009 hdd_print_bss_info(pHddStaCtx);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302010
2011 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 return( status );
2013}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302014
2015static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
2016 v_U8_t staId)
2017{
2018 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2019 v_SINT_t i;
2020 v_SIZE_t size;
2021 VOS_STATUS status;
2022 v_BOOL_t granted = VOS_FALSE;
2023
2024 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2025 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
2026 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
2027 {
2028 //Indicate to TL that there is pending data if a queue is non empty
2029 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
2030 {
2031 size = 0;
2032 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
2033 if (size > 0)
2034 {
2035 if (i != WLANTL_AC_HIGH_PRIO)
2036 {
2037 if (VOS_FALSE ==
2038 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
2039 {
2040 hdd_wmm_acquire_access(pAdapter,
2041 (WLANTL_ACEnumType)i, &granted);
2042 pAdapter->psbChanged |= (1 << i);
2043 }
2044 else
2045 granted = VOS_TRUE;
2046 }
2047
2048 if (granted || (i == WLANTL_AC_HIGH_PRIO))
2049 {
2050 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
2051 staId, (WLANTL_ACEnumType)i);
2052 if (!VOS_IS_STATUS_SUCCESS(status))
2053 {
2054 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2055 "%s: Failure in indicating pkt to TL for QID=%d",
2056 __func__, i);
2057 }
2058 }
2059 }
2060 }
2061 }
2062}
2063
Jeff Johnson295189b2012-06-20 16:38:30 -07002064static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
2065 tCsrRoamInfo *pRoamInfo,
2066 v_U8_t staId,
2067 v_MACADDR_t *pPeerMacAddress,
2068 tSirBssDescription *pBssDesc )
2069{
2070 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2071 WLAN_STADescType staDesc = {0};
2072 eCsrEncryptionType connectedCipherAlgo;
2073 v_BOOL_t fConnected;
2074 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2075 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002076 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002077
2078 if ( NULL == pBssDesc)
2079 {
2080 return VOS_STATUS_E_FAILURE;
2081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 // Get the Station ID from the one saved during the assocation.
2083 staDesc.ucSTAId = staId;
2084
Katya Nigam47528772015-02-11 12:24:49 +05302085 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002086
Katya Nigam47528772015-02-11 12:24:49 +05302087 // grab the bssid from the connection info in the adapter structure and hand that
2088 // over to TL when registering.
2089 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
2090 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002091
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2093
2094 // set the QoS field appropriately
2095 if (hdd_wmm_is_active(pAdapter))
2096 {
2097 staDesc.ucQosEnabled = 1;
2098 }
2099 else
2100 {
2101 staDesc.ucQosEnabled = 0;
2102 }
2103
2104 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2105 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
2106 {
2107 staDesc.ucProtectedFrame = 1;
2108 }
2109 else
2110 {
2111 staDesc.ucProtectedFrame = 0;
2112
2113 }
2114
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002115#ifdef FEATURE_WLAN_ESE
2116 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
2117#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002118
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 /* check whether replay check is valid for the station or not */
2120 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
2121 {
2122 /* Encryption mode is either TKIP or AES
2123 and replay check is valid for only these
2124 two encryption modes */
2125 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2126 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2127 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
2128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 else
2130 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002131 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002133 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2135 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
2136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002137
2138#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002139 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 if (pAdapter->wapi_info.fIsWapiSta)
2141 {
2142 staDesc.ucIsWapiSta = 1;
2143 }
2144 else
2145 {
2146 staDesc.ucIsWapiSta = 0;
2147 }
2148#endif /* FEATURE_WLAN_WAPI */
2149
2150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2151 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
2152
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 // UMA is Not ready yet, Xlation will be done by TL
2154 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 staDesc.ucSwFrameRXXlation = 1;
2156 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002157 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 staDesc.ucQosEnabled );
2159 // Initialize signatures and state
2160 staDesc.ucUcastSig = pRoamInfo->ucastSig;
2161 staDesc.ucBcastSig = pRoamInfo->bcastSig;
2162 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
2163 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002164 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08002165 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 -07002166 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
2167 hdd_rx_packet_cbk,
2168 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 hdd_tx_fetch_packet_cbk, &staDesc,
2170 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002171
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2173 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002174 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002175 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002177 return vosStatus;
2178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002179
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002180 if ( cfg_param->dynSplitscan &&
2181 ( VOS_TIMER_STATE_RUNNING !=
2182 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
2183 {
2184 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2185 cfg_param->trafficMntrTmrForSplitScan);
2186 }
2187
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302188 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
2189 // then go to 'authenticated'. For all other authentication types
2190 // (those that donot require upper layer authentication) we can put
2191 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002192 if (staDesc.wSTAType != WLAN_STA_IBSS)
2193 VOS_ASSERT( fConnected );
2194
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302195 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002196 {
2197 // Connections that do not need Upper layer auth, transition TL directly
2198 // to 'Authenticated' state.
2199 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
2200 WLANTL_STA_AUTHENTICATED );
2201
2202 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302203
2204 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002205 }
2206 else
2207 {
2208 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302209 "ULA auth StaId= %d. Changing TL state to CONNECTED"
2210 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002211 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05302212 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002213 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 return( vosStatus );
2216}
2217
Jeff Johnson295189b2012-06-20 16:38:30 -07002218static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
2219 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
2220{
2221 unsigned int len = 0;
2222 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002223 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 tANI_U32 rspRsnLength = 0;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302225 struct cfg80211_bss* bss;
2226 tCsrRoamConnectedProfile roam_profile;
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 struct ieee80211_channel *chan;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302228 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002229
Agarwal Ashish51325b52014-06-16 16:50:49 +05302230 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002231 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07002232 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002233 }
2234
Agarwal Ashish51325b52014-06-16 16:50:49 +05302235 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002236 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
2237 goto done;
2238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
Ashish Kumar Dhanotiya7b48fd92020-02-11 18:14:46 +05302240 if (pCsrRoamInfo->nAssocRspLength < FT_ASSOC_RSP_IES_OFFSET) {
2241
2242 hddLog(LOGE, "%s: Invalid assoc response length %d",
2243 __func__, pCsrRoamInfo->nAssocRspLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002244 goto done;
2245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002246
2247 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2248 pCsrRoamInfo->nAssocReqLength);
2249 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002250 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002251
2252 //pFTAssocRsp needs to point to the IEs
2253 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002254 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 (unsigned int)pFTAssocRsp[0],
2256 (unsigned int)pFTAssocRsp[1]);
2257
2258 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08002259 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Ashish Kumar Dhanotiya7b48fd92020-02-11 18:14:46 +05302260 if (len > IW_GENERIC_IE_MAX) {
2261 hddLog(LOGE, "%s: Invalid assoc response length %d",
2262 __func__, pCsrRoamInfo->nAssocRspLength);
2263 goto done;
2264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002267 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002268
Abhishek Singh5a597e62016-12-05 15:16:30 +05302269 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
2270 (int) pCsrRoamInfo->pBssDesc->channelId);
2271 vos_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
2272 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roam_profile);
2273 bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2274 chan, pCsrRoamInfo->bssid,
2275 &roam_profile.SSID.ssId[0],
2276 roam_profile.SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302277 hdd_send_roamed_ind(dev, bss,
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 reqRsnIe, reqRsnLength,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302279 rspRsnIe, rspRsnLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002280
2281done:
2282 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07002283}
Jeff Johnson295189b2012-06-20 16:38:30 -07002284
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302285void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
2286{
2287 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2288 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2289 tCsrRoamInfo roamInfo;
2290 roamInfo.fAuthRequired = FALSE;
2291 vos_mem_copy(roamInfo.bssid,
2292 pHddStaCtx->roam_info.bssid,
2293 WNI_CFG_BSSID_LEN);
2294 vos_mem_copy(roamInfo.peerMac,
2295 pHddStaCtx->roam_info.peerMac,
2296 WNI_CFG_BSSID_LEN);
2297
2298 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
2299 &roamInfo,
2300 pHddStaCtx->roam_info.roamId,
2301 pHddStaCtx->roam_info.roamStatus,
2302 eCSR_ROAM_RESULT_AUTHENTICATED);
2303 if (halStatus != eHAL_STATUS_SUCCESS)
2304 {
2305 hddLog(LOGE, "%s: Set Key complete failure", __func__);
2306 }
2307 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
2308}
2309
Abhishek Singh78c691f2017-11-30 13:48:44 +05302310/**
2311 * hdd_schedule_ecsa_chan_change_work() - schedule ecsa chan change work
2312 * @hal: hal context
2313 * @sta_session_id: sta session id
2314 *
2315 * Return: void.
2316 */
2317static void
2318hdd_schedule_ecsa_chan_change_work(hdd_context_t *hdd_ctx,
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302319 uint8_t sta_session_id)
Abhishek Singh78c691f2017-11-30 13:48:44 +05302320{
2321 v_TIME_t conn_start_time;
2322 int32_t time_diff;
2323
2324 conn_start_time = sme_get_connect_strt_time(hdd_ctx->hHal, sta_session_id);
2325 time_diff = vos_timer_get_system_time() - conn_start_time;
2326
2327 if (time_diff < 0)
2328 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL;
2329 else if (time_diff > ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL)
2330 time_diff = 0;
2331 else
2332 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL - time_diff;
2333
2334 hddLog(LOG1, FL("schedule ecsa_chan_change_work after %d ms"), time_diff);
2335 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
2336 msecs_to_jiffies(time_diff));
2337}
2338
Shailender Karmuchia734f332013-04-19 14:02:48 -07002339static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2340 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 eCsrRoamResult roamResult )
2342{
2343 struct net_device *dev = pAdapter->dev;
2344 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2345 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302346 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05302347 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002348 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2349 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002350#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 int ft_carrier_on = FALSE;
2352#endif
2353 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302354 v_BOOL_t hddDisconInProgress = FALSE;
2355
2356 /* HDD has initiated disconnect, do not send connect result indication
2357 * to kernel as it will be handled by __cfg80211_disconnect.
2358 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05302359 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
2360 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
2361 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2362 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302363 {
2364 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2365 FL(" Disconnect from HDD in progress "));
2366 hddDisconInProgress = TRUE;
2367 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002368
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
2370 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302371 if ( !hddDisconInProgress )
2372 {
2373 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05302374 "%s: Set HDD connState to eConnectionState_Associated",
2375 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302376 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
2377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002378
c_hpothu44ff4e02014-05-08 00:13:57 +05302379 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 // Save the connection info from CSR...
2381 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05302382
2383#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2384 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
2385 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
2386 !hddDisconInProgress &&
2387 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
2388 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
2389 sme_set_per_roam_rxconfig(pHddCtx->hHal,
2390 pHddStaCtx->conn_info.staId[0],
2391 pHddCtx->cfg_ini->rateDownThreshold,
2392 pHddCtx->cfg_ini->rateUpThreshold,
2393 pHddCtx->cfg_ini->PERroamTriggerPercent,
2394 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
2395 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
2396#endif
2397
Jeff Johnson295189b2012-06-20 16:38:30 -07002398#ifdef FEATURE_WLAN_WAPI
2399 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
2400 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
2401 {
2402 pAdapter->wapi_info.fIsWapiSta = 1;
2403 }
2404 else
2405 {
2406 pAdapter->wapi_info.fIsWapiSta = 0;
2407 }
2408#endif /* FEATURE_WLAN_WAPI */
2409
2410 // indicate 'connect' status to userspace
2411 hdd_SendAssociationEvent(dev,pRoamInfo);
2412
2413
Shailender Karmuchia734f332013-04-19 14:02:48 -07002414 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 INIT_COMPLETION(pAdapter->linkup_event_var);
2416
2417 /*
2418 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
2419 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 -07002420 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 know that the device is getting activated properly.
2422 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002423#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05302424 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 {
2426#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002427 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 pAdapter->isLinkUpSvcNeeded = TRUE;
2429
Shailender Karmuchia734f332013-04-19 14:02:48 -07002430 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 pAdapter->isLinkUpSvcNeeded = TRUE;
2432
2433 // Switch on the Carrier to activate the device
2434 netif_carrier_on(dev);
2435
2436 // Wait for the Link to up to ensure all the queues are set properly by the kernel
2437 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
2438 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002439 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 {
2441 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
2442 }
2443
2444 // Disable Linkup Event Servicing - no more service required from the net device notifier call
2445 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002446#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002448 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 }
2452#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05302453 /* Check for STAID */
2454 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
2455 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2456 else
2457 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002458
2459 //For reassoc, the station is already registered, all we need is to change the state
2460 //of the STA in TL.
2461 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05302462 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 if( !pRoamInfo->fReassocReq )
2464 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002465 struct cfg80211_bss *bss;
2466#ifdef WLAN_FEATURE_VOWIFI_11R
2467 u8 *pFTAssocRsp = NULL;
2468 unsigned int assocRsplen = 0;
2469 u8 *pFTAssocReq = NULL;
2470 unsigned int assocReqlen = 0;
2471 struct ieee80211_channel *chan;
2472#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002475
2476 /* add bss_id to cfg80211 data base */
2477 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2478 if (NULL == bss)
2479 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302480 hddLog(LOGE,
2481 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05302482 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302483 if (!hddDisconInProgress) {
2484 /*
2485 * Here driver was not able to update cfg80211 database
2486 * this can happen if connected channel is not valid,
2487 * i.e reg domain was changed during connection.
2488 * Queue disconnect for the session if disconnect is
2489 * not in progress.
2490 */
2491 hddLog(LOGE, FL("Disconnecting..."));
2492 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2493 pAdapter->sessionId,
2494 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 return eHAL_STATUS_FAILURE;
2497 }
Abhinav Kumar4cde8292019-07-18 14:17:25 +05302498
2499 //Association Response
2500 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames +
2501 pRoamInfo->nBeaconLength +
2502 pRoamInfo->nAssocReqLength);
2503 if (pFTAssocRsp != NULL)
2504 {
2505 // pFTAssocRsp needs to point to the IEs
2506 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2507 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
2508 (unsigned int)pFTAssocRsp[0],
2509 (unsigned int)pFTAssocRsp[1]);
2510 assocRsplen =
2511 pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2512 }
2513 else
2514 {
2515 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
2516 assocRsplen = 0;
2517 }
2518
2519 //Association Request
2520 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
2521 pRoamInfo->nBeaconLength);
2522 if (pFTAssocReq != NULL)
2523 {
2524 if(!ft_carrier_on)
2525 {
2526 // pFTAssocReq needs to point to the IEs
2527 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
2528 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
2529 (unsigned int)pFTAssocReq[0],
2530 (unsigned int)pFTAssocReq[1]);
2531 assocReqlen =
2532 pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
2533 }
2534 else
2535 {
2536 /* This should contain only the FTIEs */
2537 assocReqlen = pRoamInfo->nAssocReqLength;
2538 }
2539 }
2540 else
2541 {
2542 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
2543 assocReqlen = 0;
2544 }
2545
2546 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
2547 assocRsplen);
2548
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002549#ifdef WLAN_FEATURE_VOWIFI_11R
2550 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002551 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002553 if(ft_carrier_on)
2554 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302555 if ( !hddDisconInProgress )
2556 {
Abhishek Singh5a597e62016-12-05 15:16:30 +05302557 struct cfg80211_bss *roam_bss;
2558
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302559 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002560 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302561 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002562 (int)pRoamInfo->pBssDesc->channelId);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302563 if (pHddCtx->cfg_ini &&
2564 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302565 {
2566 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2567 }
Abhishek Singh5a597e62016-12-05 15:16:30 +05302568 roam_bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2569 chan, pRoamInfo->bssid,
2570 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2571 pRoamInfo->u.pConnectedProfile->SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302572 hdd_send_roamed_ind(dev, roam_bss,
Abhishek Singh5a597e62016-12-05 15:16:30 +05302573 pFTAssocReq, assocReqlen,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302574 pFTAssocRsp, assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302575 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302576 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2577 {
2578 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
2579 pRoamInfo->fAuthRequired = FALSE;
2580
2581 vos_mem_copy(pHddStaCtx->roam_info.bssid,
2582 pRoamInfo->bssid,
2583 HDD_MAC_ADDR_LEN);
2584 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
2585 pRoamInfo->peerMac,
2586 HDD_MAC_ADDR_LEN);
2587 pHddStaCtx->roam_info.roamId = roamId;
2588 pHddStaCtx->roam_info.roamStatus = roamStatus;
2589 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
2590 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002591 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302592 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002593 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002594 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002595 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302596 hdd_connect_result(dev, pRoamInfo->bssid, pRoamInfo,
2597 pFTAssocReq, assocReqlen,
2598 pFTAssocRsp, assocRsplen,
2599 WLAN_STATUS_SUCCESS,
2600 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002601 }
2602 }
2603 else
2604#endif
2605 {
2606 /* wpa supplicant expecting WPA/RSN IE in connect result */
2607 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2608 pAdapter->sessionId,
2609 &reqRsnLength,
2610 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002611
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002612 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2613 pAdapter->sessionId,
2614 &rspRsnLength,
2615 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302616 if ( !hddDisconInProgress )
2617 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002618#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302619 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05302620 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302621 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302622 if (pHddCtx->cfg_ini &&
2623 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302624 {
2625 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2626 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302627 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302628 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002629#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002630
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302631 {
2632 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302633 "%s: sending connect indication to nl80211:"
2634 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302635 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302636 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
2637 roamResult, roamStatus);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302638 /* inform connect result to nl80211 */
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302639 hdd_connect_result(dev, pRoamInfo->bssid,
2640 pRoamInfo,
Abhinav Kumar4cde8292019-07-18 14:17:25 +05302641 pFTAssocReq, assocReqlen,
2642 pFTAssocRsp, assocRsplen,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302643 WLAN_STATUS_SUCCESS,
2644 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302645 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302648 if ( !hddDisconInProgress )
2649 {
2650 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07002651#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302652 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07002653#endif
2654 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302655 // Register the Station with TL after associated...
2656 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 pRoamInfo,
2658 pHddStaCtx->conn_info.staId[ 0 ],
2659 NULL,
2660 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 }
2663 else
2664 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002665 /* wpa supplicant expecting WPA/RSN IE in connect result */
2666 /* in case of reassociation also need to indicate it to supplicant */
2667 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2668 pAdapter->sessionId,
2669 &reqRsnLength,
2670 reqRsnIe);
2671
2672 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302674 if( pRoamInfo->fAuthRequired )
2675 {
2676 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2677 pHddStaCtx->conn_info.staId[ 0 ],
2678 WLANTL_STA_CONNECTED );
2679 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2680 }
2681 else
2682 {
2683 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2684 "%s: staId: %d Changing TL state to AUTHENTICATED",
2685 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
2686 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2687 pHddStaCtx->conn_info.staId[ 0 ],
2688 WLANTL_STA_AUTHENTICATED );
2689 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302690 hdd_postTLPacketPendingInd(pAdapter,
2691 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 }
2694
2695 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
2696 {
2697 // perform any WMM-related association processing
2698 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
2699 }
2700 else
2701 {
2702 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002703 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 vosStatus, vosStatus );
2705 }
Chet Lanctot186b5732013-03-18 10:26:30 -07002706#ifdef WLAN_FEATURE_11W
2707 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
2708 sizeof(pAdapter->hdd_stats.hddPmfStats) );
2709#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302710
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05302712 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302713 {
2714 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05302715 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302716 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302717 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302718 {
2719 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
2720 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05302721#ifdef FEATURE_WLAN_TDLS
2722 wlan_hdd_tdls_connection_callback(pAdapter);
2723#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002724 }
2725 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2728
2729 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002730 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2732 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
2733 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002734 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302735 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2736 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08002737 MAC_ADDR_ARRAY(pWextState->req_bssId),
2738 roamResult, roamStatus);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302739 if (!pHddStaCtx->get_mgmt_log_sent) {
2740 pHddStaCtx->get_mgmt_log_sent = TRUE;
Abhishek Singh611295e2015-07-09 11:11:54 +05302741 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302742 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302743 }
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302744
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302745 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2746 (pRoamInfo &&
2747 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2748 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2749 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05302750 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302751 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2752 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2753 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2754 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05302755 /* Set connection state to eConnectionState_NotConnected only when CSR
2756 * has completed operation - with a ASSOCIATION_FAILURE status
2757 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302758 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05302759 {
2760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2761 "%s: Set HDD connState to eConnectionState_NotConnected",
2762 __func__);
2763 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
2764 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05302765 if((pHddCtx->concurrency_mode <= 1) &&
2766 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 {
2768 pHddCtx->isAmpAllowed = VOS_TRUE;
2769 }
2770
2771 //If the Device Mode is Station
2772 // and the P2P Client is Connected
2773 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07002774
2775 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07002776 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002777 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2778 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302779 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 {
2781 //Enable BMPS only of other Session is P2P Client
2782 hdd_context_t *pHddCtx = NULL;
2783 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2784
2785 if (NULL != pVosContext)
2786 {
2787 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2788
2789 if(NULL != pHddCtx)
2790 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302791 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302792 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2793 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302794 {
2795 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002796 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302797 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002798 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302799 hdd_enable_bmps_imps(pHddCtx);
2800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 }
2802 }
2803 }
2804
James Zmudafbf5ffc2013-03-25 12:45:35 -07002805 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002806 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302807 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002808 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302809
2810 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2811 {
2812 hddLog(LOG1,
2813 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2814 wlan_hdd_tdls_reenable(pHddCtx);
2815 }
2816
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302817 if (pRoamInfo) {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302818 hddLog(VOS_TRACE_LEVEL_ERROR,
2819 "%s: send connect failure to nl80211:"
2820 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302821 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302822 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302823 roamResult, roamStatus, pRoamInfo->reasonCode);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302824 pHddStaCtx->conn_info.assoc_status_code =
2825 pRoamInfo->statusCode;
2826 } else {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302827 hddLog(VOS_TRACE_LEVEL_ERROR,
2828 "%s: connect failed:"
2829 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302830 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302831 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2832 roamResult, roamStatus);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302833 }
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302834
James Zmudafbf5ffc2013-03-25 12:45:35 -07002835 /* inform association failure event to nl80211 */
2836 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2837 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002838 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302839 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002840 NULL, 0, NULL, 0,
2841 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302842 GFP_KERNEL);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002843 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302844 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002845 NULL, 0, NULL, 0,
2846 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302847 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002848 }
2849 else
2850 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002851 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302852 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002853 NULL, 0, NULL, 0,
2854 pRoamInfo->reasonCode ?
2855 pRoamInfo->reasonCode :
2856 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302857 GFP_KERNEL);
Gao Wu6ca73b32016-05-09 14:35:49 +08002858 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302859 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002860 NULL, 0, NULL, 0,
2861 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302862 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002863 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302864 /*Clear the roam profile*/
2865 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
Kumar Anand82c009f2014-05-29 00:29:42 -07002868 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002869
c_hpothu24f40982014-04-18 18:00:36 +05302870 if (pRoamInfo)
2871 {
2872 WLANTL_AssocFailed(pRoamInfo->staId);
2873 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302874
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302875 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 netif_tx_disable(dev);
2877 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002878
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 }
2880
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302881 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302882 {
2883 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2884 if (pHostapdAdapter != NULL)
2885 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302886 /* Restart SAP if its operating channel is different
2887 * from AP channel.
2888 */
2889 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2890 (int)pRoamInfo->pBssDesc->channelId)
2891 {
2892 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2893 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2894 (int)pRoamInfo->pBssDesc->channelId);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302895 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->force_scc_with_ecsa)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302896 {
Abhishek Singh78c691f2017-11-30 13:48:44 +05302897 hdd_schedule_ecsa_chan_change_work(pHddCtx,
2898 pAdapter->sessionId);
2899 }
2900 else
2901 {
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302902 hdd_hostapd_stop(pHostapdAdapter->dev);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302903 if (pHddCtx->cfg_ini &&
2904 pHddCtx->cfg_ini->enable_sap_auth_offload)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302905 hdd_force_scc_restart_sap(pHostapdAdapter,
2906 pHddCtx, (int)pRoamInfo->pBssDesc->channelId);
2907 }
Agrawal Ashish574b3e62017-02-09 18:58:34 +05302908
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302909 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302910 }
2911 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302912 else if (roamStatus == eCSR_ROAM_ASSOCIATION_FAILURE)
2913 {
2914 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
2915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 return eHAL_STATUS_SUCCESS;
2917}
2918
2919/**============================================================================
2920 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002921 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002923
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002925static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2926 tCsrRoamInfo *pRoamInfo,
2927 tANI_U32 roamId,
2928 eRoamCmdStatus roamStatus,
2929 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002930{
Katya Nigam47528772015-02-11 12:24:49 +05302931 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2932 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2933 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302934 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302935
Jeff Johnson81c17882013-05-03 09:53:35 -07002936 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2937 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2938
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 switch( roamResult )
2940 {
2941 // both IBSS Started and IBSS Join should come in here.
2942 case eCSR_ROAM_RESULT_IBSS_STARTED:
2943 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002944 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002946 if (NULL == pRoamInfo)
2947 {
2948 VOS_ASSERT(0);
2949 return;
2950 }
2951
2952 /* When IBSS Started comes from CSR, we need to move
2953 * connection state to IBSS Disconnected (meaning no peers
2954 * are in the IBSS).
2955 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2957 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2958 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002959 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2960 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302961 /*notify wmm */
2962 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002963 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002964
Jeff Johnson81c17882013-05-03 09:53:35 -07002965 if (pRoamInfo->pBssDesc)
2966 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302967#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2968 struct ieee80211_channel *chan;
2969 int chan_no;
2970 unsigned int freq;
2971#endif
Katya Nigam47528772015-02-11 12:24:49 +05302972 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2973 IBSS_BROADCAST_STAID,
2974 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002975
2976 /* we created the IBSS, notify supplicant */
2977 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2978 MAC_ADDRESS_STR,
2979 __func__, pAdapter->dev->name,
2980 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2981
2982 /* we must first give cfg80211 the BSS information */
2983 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2984 if (NULL == bss)
2985 {
2986 hddLog(VOS_TRACE_LEVEL_ERROR,
2987 "%s: %s: unable to create IBSS entry",
2988 __func__, pAdapter->dev->name);
2989 return;
2990 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302991#ifdef WLAN_FEATURE_RMC
2992 netif_carrier_on(pAdapter->dev);
2993 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2994 netif_tx_start_all_queues(pAdapter->dev);
2995#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302996#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2997 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002998
Anand N Sunkadfec40682015-07-29 09:51:17 +05302999 if (chan_no <= 14)
3000 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05303001 HDD_NL80211_BAND_2GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05303002 else
3003 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05303004 HDD_NL80211_BAND_5GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05303005
3006 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3007
3008 if (chan)
3009 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3010 chan, GFP_KERNEL);
3011 else
3012 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
3013 pAdapter->dev->name,
3014 (int)pRoamInfo->pBssDesc->channelId);
3015#else
Jeff Johnson81c17882013-05-03 09:53:35 -07003016 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05303017#endif
Yue Maf49ba872013-08-19 12:04:25 -07003018 cfg80211_put_bss(
3019#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3020 pHddCtx->wiphy,
3021#endif
3022 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07003023 }
Katya Nigam47528772015-02-11 12:24:49 +05303024 else
3025 {
3026 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3027 "%s: NULL Bss Desc",__func__);
3028 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303029
3030 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
3031 * in IBSS_COALESCED will remove the BC key.
3032 */
3033 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
3034 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
3035 == pHddStaCtx->ibss_enc_key.encType
3036 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
3037 == pHddStaCtx->ibss_enc_key.encType
3038 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3039 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
3040 {
3041 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3042 VOS_STATUS vosStatus;
3043
3044 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
3045
3046 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3047 grpmacaddr, WNI_CFG_BSSID_LEN);
3048 hddLog(VOS_TRACE_LEVEL_INFO,
3049 FL(" SET GTK in case of COALESCED"));
3050 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3051 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3052 if ( VOS_STATUS_SUCCESS != vosStatus )
3053 {
3054 hddLog(VOS_TRACE_LEVEL_ERROR,
3055 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
3056 }
3057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 break;
3059 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003060
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3062 {
Jeff Johnson81c17882013-05-03 09:53:35 -07003063 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
3064 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 break;
3066 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003067
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07003069 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
3070 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003072 }
3073
Jeff Johnson81c17882013-05-03 09:53:35 -07003074 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003075}
3076
3077/**============================================================================
3078 *
3079 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
3080 This information is passed to iwconfig later. The peer that joined
3081 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003082 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003084
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05303086static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07003087{
3088 int fSuccess = FALSE;
3089 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303090 VOS_STATUS status;
3091 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003092
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3094 {
3095 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
3096 {
3097 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003098
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003100
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 fSuccess = TRUE;
3102 break;
3103 }
3104 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003105
Nirav Shah7e3c8132015-06-22 23:51:42 +05303106 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
3107 if (status != VOS_STATUS_SUCCESS) {
3108 hddLog(VOS_TRACE_LEVEL_ERROR,
3109 FL("Not able to add staid hash %d"), staId);
3110 return FALSE;
3111 }
3112
3113 hddLog(VOS_TRACE_LEVEL_INFO,
3114 FL("New station added sta_id %d mac:"
3115 MAC_ADDRESS_STR), staId,
3116 MAC_ADDR_ARRAY(peerMacAddress->bytes));
3117
Shailender Karmuchia734f332013-04-19 14:02:48 -07003118 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07003119}
3120/**============================================================================
3121 *
3122 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003123 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003125
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07003127static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003128{
3129 int fSuccess = FALSE;
3130 int idx = 0;
3131 v_U8_t valid_idx = 0;
3132 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07003133 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003134 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05303135 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003136
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3138 {
3139 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
3140 {
3141 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303142 status = hdd_sta_id_hash_remove_entry(pAdapter,
3143 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
3144 if (status != VOS_STATUS_SUCCESS) {
3145 hddLog(VOS_TRACE_LEVEL_ERROR,
3146 FL("Not able to remove staid hash %d"), staId );
3147 fSuccess = FALSE;
3148 } else {
3149 hddLog(VOS_TRACE_LEVEL_INFO,
3150 FL("station removed sta_id %d mac:"
3151 MAC_ADDRESS_STR), staId,
3152 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07003153
Nirav Shah7e3c8132015-06-22 23:51:42 +05303154 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07003155
Nirav Shah7e3c8132015-06-22 23:51:42 +05303156 fSuccess = TRUE;
3157 // Note the deleted Index, if its 0 we need special handling
3158 del_idx = idx;
3159 empty_slots++;
3160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 }
3162 else
3163 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003164 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 {
3166 valid_idx = idx;
3167 }
Ravi Joshi8a934352013-09-25 16:46:58 -07003168 else
3169 {
3170 // Found an empty slot
3171 empty_slots++;
3172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 }
3174 }
3175
Ravi Joshi8a934352013-09-25 16:46:58 -07003176 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
3177 {
3178 // Last peer departed, set the IBSS state appropriately
3179 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07003181 "Last IBSS Peer Departed!!!" );
3182 }
3183
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 // Find next active staId, to have a valid sta trigger for TL.
3185 if (fSuccess == TRUE)
3186 {
3187 if (del_idx == 0)
3188 {
3189 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
3190 {
3191 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
3192 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
3193 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
3194
3195 pHddStaCtx->conn_info.staId[valid_idx] = 0;
3196 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
3197 }
3198 }
3199 }
3200 return( fSuccess );
3201}
3202
3203/**============================================================================
3204 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003205 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003207
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 ===========================================================================*/
3209static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
3210{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003211 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05303212 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3213 "%s: IBSS Connect Indication from SME!!! "
3214 "Set HDD connState to eConnectionState_IbssConnected",
3215 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
3217 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
3218
3219 // Save the connection info from CSR...
3220 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
3221
3222 // Send the bssid address to the wext.
3223 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003225 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3226 if (NULL == bss)
3227 {
3228 hddLog(VOS_TRACE_LEVEL_ERROR,
3229 "%s: %s: unable to create IBSS entry",
3230 __func__, pAdapter->dev->name);
3231 return eHAL_STATUS_FAILURE;
3232 }
Yue Maf49ba872013-08-19 12:04:25 -07003233 cfg80211_put_bss(
3234#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3235 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
3236#endif
3237 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07003238
3239 return( eHAL_STATUS_SUCCESS );
3240}
Mukul Sharmad2589a52014-04-23 21:06:25 +05303241
3242/**============================================================================
3243 *
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003245
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003247static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3248 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 eCsrRoamResult roamResult )
3250{
3251 eCsrEncryptionType connectedCipherAlgo;
3252 v_BOOL_t fConnected = FALSE;
3253 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3254 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303255 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303257 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07003259
3260 if (NULL == pRoamInfo)
3261 {
3262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
3263 return eHAL_STATUS_FAILURE;
3264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003266 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 // not require upper layer authentication) we can put TL directly into 'authenticated'
3268 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3270 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
3271 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003272
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3274 if( fConnected )
3275 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003276 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
3277 {
3278 v_U8_t staId;
3279
3280 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
3281
3282 if ( 0 == memcmp( pRoamInfo->peerMac,
3283 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
3284 {
3285 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3286 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05303287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3288 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003289 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3290 }
3291 else
3292 {
3293 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
3294 (v_MACADDR_t*)pRoamInfo->peerMac,
3295 &staId);
3296 if ( VOS_STATUS_SUCCESS == vosStatus )
3297 {
3298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3299 "WLAN TL STA Ptk Installed for STAID=%d", staId);
3300 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3301 staId);
3302 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3303 }
3304 }
3305 }
3306 else
3307 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05303308 WLANTL_GetSTAState(pHddCtx->pvosContext,
3309 pHddStaCtx->conn_info.staId[0],
3310 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303311 // TODO: Considering getting a state machine in HDD later.
3312 // This routine is invoked twice. 1)set PTK 2)set GTK.
3313 // The folloing if statement will be TRUE when setting GTK.
3314 // At this time we don't handle the state in detail.
3315 // Related CR: 174048 - TL not in authenticated state
3316 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
3317 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
3318 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303319
3320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
3321 "for StaId=%d. Changing TL state to AUTHENTICATED from"
3322 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303323
3324 // Connections that do not need Upper layer authentication,
3325 // transition TL to 'Authenticated' state after the keys are set.
3326 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3327 pHddStaCtx->conn_info.staId[ 0 ],
3328 WLANTL_STA_AUTHENTICATED );
3329
3330 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303331
3332 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3333 hdd_postTLPacketPendingInd(pAdapter,
3334 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05303335 //Need to call offload because when roaming happen at that time fwr
3336 //clean offload info as part of the DelBss
3337 // No need to configure offload if host was not suspended
3338 spin_lock(&pHddCtx->filter_lock);
3339 if(pHddCtx->hdd_wlan_suspended)
3340 {
3341 spin_unlock(&pHddCtx->filter_lock);
3342 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
3343 }
3344 else
3345 {
3346 spin_unlock(&pHddCtx->filter_lock);
3347 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303348 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3349 {
3350 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
3351 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303352 }
3353 else
3354 {
3355 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3356 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303357
3358 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
3359 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
3360 {
3361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
3362 " for StaId=%d. Due to OSEN, Changing TL state to"
3363 "AUTHENTICATED from state:%d",
3364 pHddStaCtx->conn_info.staId[0], prevTLState);
3365
3366 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3367 pHddStaCtx->conn_info.staId[ 0 ],
3368 WLANTL_STA_AUTHENTICATED );
3369
3370 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
3371
3372 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3373 hdd_postTLPacketPendingInd(pAdapter,
3374 pHddStaCtx->conn_info.staId[0]);
3375 }
3376
3377
3378
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303379 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3380 {
3381 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
3382 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303383 }
3384
3385 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303388 else
3389 {
3390 // possible disassoc after issuing set key and waiting set key complete
3391 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3392 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003393
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 EXIT();
3395 return( eHAL_STATUS_SUCCESS );
3396}
3397/**============================================================================
3398 *
3399 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
3400 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003401static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07003403{
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3405
3406 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3407 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
3408 {
3409 struct iw_michaelmicfailure msg;
3410 union iwreq_data wreq;
3411 memset(&msg, '\0', sizeof(msg));
3412 msg.src_addr.sa_family = ARPHRD_ETHER;
3413 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08003414 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
3415 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07003416
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3418 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003419 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 msg.flags = IW_MICFAILURE_PAIRWISE;
3421 memset(&wreq, 0, sizeof(wreq));
3422 wreq.data.length = sizeof(msg);
3423 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003425 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3427 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
3428 NL80211_KEYTYPE_GROUP :
3429 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07003430 pRoamInfo->u.pMICFailureInfo->keyId,
3431 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003433
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003435
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 return( eHAL_STATUS_SUCCESS );
3437}
3438
3439/**============================================================================
3440 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003441 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003443
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003445static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3446 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 eCsrRoamResult roamResult )
3448{
3449 VOS_STATUS vosStatus;
3450
3451 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3452 switch( roamResult )
3453 {
3454 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3455 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003456 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303457 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003458
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303459 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3460 "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 -07003461 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3462 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003464
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3466
Shailender Karmuchia734f332013-04-19 14:02:48 -07003467 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
3468 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
3469 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
3470
3471 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05303472 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 pRoamInfo,
3474 pRoamInfo->staId,
3475 (v_MACADDR_t *)pRoamInfo->peerMac,
3476 pRoamInfo->pBssDesc );
3477 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3478 {
3479 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003480 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 vosStatus, vosStatus );
3482 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05303483 if (!roamSaveIbssStation(pAdapter,
3484 pRoamInfo->staId,
3485 (v_MACADDR_t *)pRoamInfo->peerMac))
3486 {
3487 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
3488 break;
3489 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003490 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303491
3492 staInfo = vos_mem_malloc(sizeof(*staInfo));
3493 if (staInfo == NULL) {
3494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3495 "memory allocation for station_info failed");
3496 return eHAL_STATUS_FAILED_ALLOC;
3497 }
3498
3499 memset(staInfo, 0, sizeof(*staInfo));
3500 staInfo->filled = 0;
3501 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003502
3503 cfg80211_new_sta(pAdapter->dev,
3504 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303505 staInfo, GFP_KERNEL);
3506 vos_mem_free(staInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003507
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003508 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3509 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3510 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3511 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
3512 {
3513 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05303514
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003515 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3516 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
3517
3518 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003519 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003520 pHddStaCtx->ibss_enc_key.encType);
3521
3522 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3523 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3524
3525 if ( VOS_STATUS_SUCCESS != vosStatus )
3526 {
3527 hddLog(VOS_TRACE_LEVEL_ERROR,
3528 "%s: sme_RoamSetKey failed, returned %d",
3529 __func__, vosStatus);
3530 return VOS_STATUS_E_FAILURE;
3531 }
3532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303534 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 netif_tx_start_all_queues(pAdapter->dev);
3536 break;
3537 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003538
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3540 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003541
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003543
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3547 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003548 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003549
Ravi Joshicc57ed42013-10-12 16:31:25 -07003550 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 {
3552 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3553 "IBSS peer departed by cannot find peer in our registration table with TL" );
3554 }
3555
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303556 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3557 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003558 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3559 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
3560 pRoamInfo->staId );
3561
Katya Nigam47528772015-02-11 12:24:49 +05303562 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003563
3564 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003565 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003566
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003567 cfg80211_del_sta(pAdapter->dev,
3568 (const u8 *)&pRoamInfo->peerMac,
3569 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 break;
3571 }
3572 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3573 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
3575 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303577 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 netif_tx_disable(pAdapter->dev);
3579 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05303580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3581 "%s: Set HDD connState to eConnectionState_NotConnected",
3582 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003584
Jeff Johnson295189b2012-06-20 16:38:30 -07003585 // Send the bssid address to the wext.
3586 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
3587 // clean up data path
3588 hdd_disconnect_tx_rx(pAdapter);
3589 break;
3590 }
3591 default:
3592 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003593
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003595
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 return( eHAL_STATUS_SUCCESS );
3597}
3598
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003599#ifdef FEATURE_WLAN_TDLS
3600/**============================================================================
3601 *
3602 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
3603 TL the new STA. This is called as part of ADD_STA in the TDLS setup
3604 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07003605
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003606 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303607VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
3608#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3609 const tANI_U8 *peerMac,
3610#else
3611 tANI_U8 *peerMac,
3612#endif
3613 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003614{
3615 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003616 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003617 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3618 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003619 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
3620 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003621 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3622 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003623
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003624 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3625 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003627 "%s not connected. ignored", __func__);
3628 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003629 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003630
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003631 /*
3632 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3633 * be peer MAC, here we are wokrking on direct Link
3634 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003635 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003636
3637 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003638
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003639 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003640 sizeof(tSirMacAddr) );
3641
3642 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
3643 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
3644
3645 /* set the QoS field appropriately ..*/
3646 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
3647 : (staDesc.ucQosEnabled = 0) ;
3648
3649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08003650 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003651
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003652 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003653
3654 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003655 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003656
Shailender Karmuchia734f332013-04-19 14:02:48 -07003657 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003658 * UMA is ready we inform TL to do frame translation.
3659 */
3660 staDesc.ucSwFrameTXXlation = 1;
3661 staDesc.ucSwFrameRXXlation = 1;
3662 staDesc.ucAddRmvLLC = 1;
3663
3664 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003665 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003666
3667 /* tdls Direct Link do not need bcastSig */
3668 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003669
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003670 if(staDesc.ucProtectedFrame)
3671 staDesc.ucIsReplayCheckValid = VOS_TRUE;
3672 else
3673 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003674
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303675 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003676
Shailender Karmuchia734f332013-04-19 14:02:48 -07003677 /* Register the Station with TL... */
3678 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
3679 hdd_rx_packet_cbk,
3680 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003681 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003682
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003683 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3684 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003685 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003686 "%s: WLANTL_RegisterSTAClient() failed to register. "
3687 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003688 return vosStatus;
3689 }
3690
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003691 if ( cfg_param->dynSplitscan &&
3692 ( VOS_TIMER_STATE_RUNNING !=
3693 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
3694 {
3695 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
3696 cfg_param->trafficMntrTmrForSplitScan);
3697 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003698 return( vosStatus );
3699}
3700
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303701VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003702{
3703 VOS_STATUS vosStatus;
3704 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
3705 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3706 {
3707 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3708 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003709 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003710 __func__, staId, vosStatus, vosStatus );
3711 }
3712 return( vosStatus );
3713}
3714
3715
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003716/*
3717 * HDD interface between SME and TL to ensure TDLS client registration with
3718 * TL in case of new TDLS client is added and deregistration at the time
3719 * TDLS client is deleted.
3720 */
3721
Shailender Karmuchia734f332013-04-19 14:02:48 -07003722eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
3723 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003724 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07003725 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003726 eCsrRoamResult roamResult)
3727{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003728 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003729 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003730 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003731
Kaushik, Sushant8489f472014-01-27 11:41:22 +05303732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08003733 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
3734 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
3735 "ADD_TDLS_PEER" :
3736 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
3737 "DEL_TDLS_PEER" :
3738 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
3739 "DEL_TDLS_PEER_IND" :
3740 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3741 "DEL_ALL_TDLS_PEER_IND" :
3742 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
3743 "UPDATE_TDLS_PEER" :
3744 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303745 "LINK_ESTABLISH_REQ_RSP" :
3746 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
3747 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08003748 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003749 switch( roamResult )
3750 {
3751 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3752 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003753 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3754 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303755 hddTdlsPeer_t *curr_peer;
3756
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003758 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05303759 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303760
3761 mutex_lock(&pHddCtx->tdls_lock);
3762 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3763 pRoamInfo->peerMac, FALSE);
3764 if (NULL != curr_peer)
3765 curr_peer->link_status = eTDLS_LINK_TEARING;
3766 else
3767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3768 "%s %d curr_peer is Null", __func__,__LINE__);
3769 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003770 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003771 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003772 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003773
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003774 /* check if there is available index for this new TDLS STA */
3775 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3776 {
3777 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3778 {
3779 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3780 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3781
3782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003783 ("TDLS: STA IDX at %d is %d "
3784 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003785 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003786 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003787
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003788 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003789 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3790 status = eHAL_STATUS_SUCCESS ;
3791 break ;
3792 }
3793 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003794 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003795 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003796 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003797 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3798 "wlan_hdd_tdls_set_sta_id() failed");
3799 return VOS_FALSE;
3800 }
3801
3802 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303803 /* store the ucast signature , if required for further reference. */
3804
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003805 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303806 /* start TDLS client registration with TL */
3807 status = hdd_roamRegisterTDLSSTA( pAdapter,
3808 pRoamInfo->peerMac,
3809 pRoamInfo->staId,
3810 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303811 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003812 }
3813 else
3814 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003815 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003817 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003818 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003819 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003820 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003821 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003822 break ;
3823 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003824 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3825 {
3826 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3827 {
3828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3829 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3830 }
3831 /* store the ucast signature which will be used later when
3832 * registering to TL
3833 */
3834 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3835 complete(&pAdapter->tdls_add_station_comp);
3836 break;
3837 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303838 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3839 {
3840 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3841 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303842 hddTdlsPeer_t *curr_peer;
3843
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3845 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303846
3847 mutex_lock(&pHddCtx->tdls_lock);
3848 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3849 pRoamInfo->peerMac, FALSE);
3850 if (curr_peer)
3851 curr_peer->link_status = eTDLS_LINK_TEARING;
3852 else
3853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3854 "%s %d curr_peer is Null",__func__,__LINE__);
3855 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303856 }
3857 complete(&pAdapter->tdls_link_establish_req_comp);
3858 break;
3859 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303860 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3861 {
3862 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3864 "%s: Channel switch request failed. %d", __func__,
3865 pRoamInfo->statusCode);
3866 else
3867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3868 "%s: Channel switch request Success", __func__);
3869 break;
3870 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003871 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003872 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003873 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003874 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003875 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003876 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3877 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003878 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003880 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3881
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303882 mutex_lock(&pHddCtx->tdls_lock);
3883 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3884 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303885 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003886 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3888 " Current status for peer" MAC_ADDRESS_STR "is %d",
3889 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303890 if (TDLS_IS_CONNECTED(curr_peer) ||
3891 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303892 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303893 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303894 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3895 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303896 else
3897 mutex_unlock(&pHddCtx->tdls_lock);
3898
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303899 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003900 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303901 else
3902 mutex_unlock(&pHddCtx->tdls_lock);
3903
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303904 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003905 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303906 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003907
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003908 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3909 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3910 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003911 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003912 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003913 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003914 break ;
3915 }
3916 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003917 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003918 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003919 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003920 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3921 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003922 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003923 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3924 "%s: Sending teardown to supplicant with reason code %u",
3925 __func__, pRoamInfo->reasonCode);
3926
3927#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303928 mutex_lock(&pHddCtx->tdls_lock);
3929 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3930 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003931 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303932 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3933 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303934 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003935#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003936 status = eHAL_STATUS_SUCCESS ;
3937 break ;
3938 }
3939 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3940 {
3941 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003942 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003943 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003944 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3945 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003946 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003948 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003949 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003950 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303951
3952 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003953 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303954 mutex_unlock(&pHddCtx->tdls_lock);
3955
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003956 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3957 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003958
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003959 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003960 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003961 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3962 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003963
3964 status = eHAL_STATUS_SUCCESS ;
3965 }
3966 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303967 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003968 break ;
3969 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003970 default:
3971 {
3972 break ;
3973 }
3974 }
3975
3976 return status ;
3977}
3978#endif
3979
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303980void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003981{
3982 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3983 hdd_context_t *pHddCtx = NULL;
3984 int ret;
3985
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303986 ENTER();
3987
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003988 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3989 {
3990 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003991 "%s: Bad param, pAdapter [%pK]",
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003992 __func__, pAdapter);
3993 return;
3994 }
3995
3996 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3997 ret = wlan_hdd_validate_context(pHddCtx);
3998 if (0 != ret)
3999 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004000 return;
4001 }
4002
4003 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4004 {
4005 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
4006 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304007
4008 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004009}
4010
Shailender Karmuchia734f332013-04-19 14:02:48 -07004011eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
4013{
4014 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
4015 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304016 hdd_wext_state_t *pWextState = NULL;
4017 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004018 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304019 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07004020 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004021
4022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004023 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004024 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004025
4026 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304027 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004028 {
4029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304030 "invalid adapter or adapter has invalid magic");
4031 return eHAL_STATUS_FAILURE;
4032 }
4033
4034 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4035 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4036
4037 if ((NULL == pWextState) || (NULL == pHddStaCtx))
4038 {
4039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4040 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004041 return eHAL_STATUS_FAILURE;
4042 }
4043
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05304044 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4045 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 switch( roamStatus )
4047 {
4048 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05304049 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4050 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004052
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004053#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
4054 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07004056 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 * interface down */
4058 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304059 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
4060 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05304061 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4063 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4064 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4066 }
4067 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05304068 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 break;
4070
4071 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004072 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07004074 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 // eCSR_ROAM_SHOULD_ROAM will be received.
4076 // Where in we will not mark the link down
4077 // Also we want to stop tx at this point when we will be
4078 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004079 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 {
4081 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304082 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05304084 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4085 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
4086 {
4087 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
4088 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004089 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304090 * Deregister this STA with TL, but do not flush the packets
4091 * for this STA from wmm_tx_queue. Since there is no valid STA
4092 * for these packets they will not be transmitted. Eventually
4093 * after the reassociation is successful, these packets will be
4094 * transmitted after registering STA with TL again. This ensures
4095 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004096 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304097 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
4098 pHddStaCtx->conn_info.staId[0]);
4099 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004100 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4102 FL("WLANTL_ClearSTAClient failed for staID %d."
4103 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
4104 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004105 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 }
4108 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004109 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 break;
4111#endif
4112
4113 case eCSR_ROAM_SHOULD_ROAM:
4114 // Dont need to do anything
4115 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 struct net_device *dev = pAdapter->dev;
4117 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4118 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304119 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004121#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 if (pHddStaCtx->ft_carrier_on == FALSE)
4123 {
4124#endif
4125 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004126#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 }
4128#endif
4129
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004130#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 //We should clear all sta register with TL, for now, only one.
4132 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
4133 if ( !VOS_IS_STATUS_SUCCESS(status ) )
4134 {
4135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4136 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
4137 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004138 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004140#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 }
4142 break;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05304143 case eCSR_ROAM_LOSTLINK_DETECTED:
4144 {
4145 if (wlan_hdd_check_and_stop_mon(pAdapter, false))
4146 halStatus = eHAL_STATUS_FAILURE;
4147 }
4148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 case eCSR_ROAM_LOSTLINK:
4150 case eCSR_ROAM_DISASSOCIATED:
4151 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4153 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05304154 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4156 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07004157 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4158 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304159 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07004160 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08004161
4162 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
4163 pHddCtx->configuredMcastBcastFilter =
4164 pHddCtx->sus_res_mcastbcast_filter;
4165 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
4166 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304167
Amar Singhald53568e2013-09-26 11:03:45 -07004168 hddLog(VOS_TRACE_LEVEL_INFO,
4169 "offload: disassociation happening, restoring configuredMcastBcastFilter");
4170 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
4171 pHddCtx->configuredMcastBcastFilter);
4172 hddLog(VOS_TRACE_LEVEL_INFO,
4173 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4175 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004176#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304177 /* Call to clear any MC Addr List filter applied after
4178 * successful connection.
4179 */
4180 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004181#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 }
4183 break;
4184 case eCSR_ROAM_IBSS_LEAVE:
4185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4186 "****eCSR_ROAM_IBSS_LEAVE****");
4187 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4188 break;
4189 case eCSR_ROAM_ASSOCIATION_COMPLETION:
4190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4191 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304192 // To Do - address probable memory leak with WEP encryption upon successful association
4193 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304195 //Clear saved connection information in HDD
4196 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304198 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004199
4200 break;
4201 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004202 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 pRoamInfo, roamId, roamStatus, roamResult );
4204 break;
4205 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07004206 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
4207 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 break;
4209
4210 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
4211 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004212 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004213
4214 case eCSR_ROAM_MIC_ERROR_IND:
4215 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4216 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05304217 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
4218 {
4219 /*
4220 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
4221 * adding the 100 value.
4222 */
4223 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
4224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4225 "%s : Rssi on Disconnect : %d",
4226 __func__, pAdapter->rssi_on_disconnect);
4227 break;
4228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004230 {
4231 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4232
4233 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004234 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304235 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304236 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004237 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004238 /* Send DTIM period to the FW; only if the wlan is already
4239 in suspend. This is the case with roaming (reassoc),
4240 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
4241 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
4242 before the ENTER_BMPS_REQ ensures Listen Interval is
4243 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004244 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004245
4246 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004247 if due to unexpected scenario, if we are in BMPS,
4248 then trigger Exit and Enter BMPS to take DTIM period
4249 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004250 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
4251 {
4252 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
4253
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004254 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4255 iw_full_power_cbfn, pAdapter,
4256 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004257 }
4258 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304259
4260 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304261 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
4262 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304263 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304264 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304265 {
4266 hddLog( LOG1, FL("Device in full power."
4267 "Stop and start traffic timer for roaming"));
4268 pmcStopTrafficTimer(pHddCtx->hHal);
4269 if (pmcStartTrafficTimer(pHddCtx->hHal,
4270 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
4271 {
4272 hddLog(LOGP, FL("Cannot start traffic timer"));
4273 }
4274 }
4275
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004276 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304277 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304278 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304279 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 break;
4282#ifdef WLAN_FEATURE_VOWIFI_11R
4283 case eCSR_ROAM_FT_RESPONSE:
4284 hdd_SendFTEvent(pAdapter);
4285 break;
4286#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004287#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004288 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004289 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07004290 {
4291 /* Notify the supplicant of a new candidate */
4292 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
4293 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004294 break;
4295#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004296
Yue Maef608272013-04-08 23:09:17 -07004297#ifdef FEATURE_WLAN_LFR_METRICS
4298 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4299 /* This event is to notify pre-auth initiation */
4300 if (VOS_STATUS_SUCCESS !=
4301 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
4302 {
4303 halStatus = eHAL_STATUS_FAILURE;
4304 }
4305 break;
4306 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4307 /* This event will notify pre-auth completion in case of success */
4308 if (VOS_STATUS_SUCCESS !=
4309 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4310 pRoamInfo, 1))
4311 {
4312 halStatus = eHAL_STATUS_FAILURE;
4313 }
4314 break;
4315 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4316 /* This event will notify pre-auth completion in case of failure. */
4317 if (VOS_STATUS_SUCCESS !=
4318 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4319 pRoamInfo, 0))
4320 {
4321 halStatus = eHAL_STATUS_FAILURE;
4322 }
4323 break;
4324 case eCSR_ROAM_HANDOVER_SUCCESS:
4325 /* This event is to notify handover success.
4326 It will be only invoked on success */
4327 if (VOS_STATUS_SUCCESS !=
4328 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
4329 {
4330 halStatus = eHAL_STATUS_FAILURE;
4331 }
4332 break;
4333#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 case eCSR_ROAM_REMAIN_CHAN_READY:
4335 hdd_remainChanReadyHandler( pAdapter );
4336 break;
4337 case eCSR_ROAM_SEND_ACTION_CNF:
4338 hdd_sendActionCnf( pAdapter,
4339 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
4340 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004341#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08004342 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004343 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08004344 roamId, roamStatus, roamResult );
4345 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004346 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4347 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
4348 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004349#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004350#ifdef WLAN_FEATURE_11W
4351 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4352 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
4353 pRoamInfo->pbFrames,
4354 pRoamInfo->frameType);
4355 break;
4356#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004357#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004358 case eCSR_ROAM_TSM_IE_IND:
4359 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
4360 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
4361 break;
4362
4363 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4364 {
4365 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
4366 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
4367 {
4368 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
4369 }
4370 break;
4371 }
4372
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004373 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004374 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004375 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004376 break;
4377 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004378
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004379 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004380 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004381 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004382 break;
4383 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004384#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05304385 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
4386 {
4387 pAdapter->maxRateFlags = roamResult;
4388 break;
4389 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304390 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4391 if (pRoamInfo && pRoamInfo->pBssDesc) {
4392 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4393 pRoamInfo->pBssDesc);
4394 if (bss_status)
4395 cfg80211_put_bss(
4396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4397 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4398#endif
4399 bss_status);
4400 else
4401 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
4402 }
Abhinav Kumar118efd02019-08-07 16:41:07 +05304403
4404 case eCSR_ROAM_SAE_COMPUTE:
4405 if (pRoamInfo)
4406 wlan_hdd_sae_callback(pAdapter, pRoamInfo);
4407 break;
4408
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304409 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4410 {
4411 hdd_adapter_t *pHostapdAdapter = NULL;
4412 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4413 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4414
4415 if (!pHddCtx || !pHddStaCtx) {
4416 hddLog(LOG1, FL("Invalid pHddCtx or pHddStaCtx"));
4417 break;
4418 }
4419
4420 hddLog(LOG1, FL("eCSR_ROAM_STA_CHANNEL_SWITCH: new channel %hu"),
4421 pRoamInfo->chan_info.chan_id);
4422
4423 pHddStaCtx->conn_info.operationChannel =
4424 pRoamInfo->chan_info.chan_id;
4425
4426 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
4427 if (pHostapdAdapter &&
4428 (test_bit(SOFTAP_BSS_STARTED,
4429 &pHostapdAdapter->event_flags)))
4430 {
4431 /* Restart SAP if its operating channel is different
4432 * from AP channel.
4433 */
4434 hddLog(VOS_TRACE_LEVEL_INFO,"SAP chan %d, STA chan %d, force_scc_with_ecsa %d",
4435 pHostapdAdapter->sessionCtx.ap.operatingChannel,
4436 pRoamInfo->chan_info.chan_id,
4437 pHddCtx->cfg_ini->force_scc_with_ecsa);
4438 if ((pHddCtx->cfg_ini->force_scc_with_ecsa ) &&
4439 (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
4440 pRoamInfo->chan_info.chan_id))
4441 {
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05304442 schedule_delayed_work(&pHddCtx->ecsa_chan_change_work, 0);
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304443 }
4444 else
4445 hddLog(LOG1, FL("SAP restart not required"));
4446 } else
4447 hddLog(LOG1, FL("SAP not active, nothing to do"));
4448 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304449 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05304450 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 break;
4452 }
4453 return( halStatus );
4454}
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304455
4456#ifdef WLAN_FEATURE_SAE
4457/**
4458 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
4459 * @auth_suite: auth suite
4460 * @auth_type: pointer to eCsrAuthType
4461 *
4462 * Return: None
4463 */
4464static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4465 eCsrAuthType *auth_type)
4466{
4467 if (!memcmp(auth_suite, ccp_rsn_oui_80, 4))
4468 *auth_type = eCSR_AUTH_TYPE_SAE;
4469}
4470#else
4471static inline
4472void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4473 eCsrAuthType *auth_type)
4474{
4475}
4476#endif
4477
Shailender Karmuchia734f332013-04-19 14:02:48 -07004478eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004479{
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304480 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004482 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 {
4484 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004485 } else
4486 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 {
4488 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004489 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004490#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004491 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 {
4493 // Check for 11r FT Authentication with PSK
4494 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004495 } else
4496 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 {
4498 // Check for 11R FT Authentication with 802.1X
4499 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004500 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004501#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004502#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004503 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 {
4505 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4506 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004507#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07004508#ifdef WLAN_FEATURE_11W
4509 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
4510 {
4511 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4512 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304513 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
4514 {
4515 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4516 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004517#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304518 if (!memcmp(auth_suite, ccp_rsn_oui_18, 4))
4519 {
4520 auth_type = eCSR_AUTH_TYPE_OWE;
4521 } else
4522
Shailender Karmuchia734f332013-04-19 14:02:48 -07004523 {
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304524 /* If auth suite is of SAE, auth_type will be
4525 * overwritten in hdd_translate_sae_rsn_to_csr_auth
4526 */
4527 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
4528 }
4529
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304530 hddLog(LOG1, FL("auth_type : %d"), auth_type);
4531
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004533}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004534
Shailender Karmuchia734f332013-04-19 14:02:48 -07004535eCsrAuthType
4536hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004537{
4538 eCsrAuthType auth_type;
4539 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004540 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 {
4542 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004543 } else
4544 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 {
4546 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004547 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004548#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004549 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 {
4551 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004552 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004553#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004554 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4556 }
4557 hddLog(LOG1, FL("auth_type: %d"), auth_type);
4558 return auth_type;
4559}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004560
Shailender Karmuchia734f332013-04-19 14:02:48 -07004561eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004562hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004563{
4564 eCsrEncryptionType cipher_type;
4565 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004566 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 {
4568 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004569 }
4570 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 {
4572 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004573 }
4574 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 {
4576 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004577 }
4578 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 {
4580 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004581 }
4582 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
4583 {
4584 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4585 }
4586 else
4587 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4589 }
4590 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4591 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004592}
Jeff Johnson295189b2012-06-20 16:38:30 -07004593/* To find if the MAC address is NULL */
4594static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
4595{
4596 int i;
4597 for (i = 0; i < length; i++)
4598 {
4599 if (0x00 != (macAddr[i]))
4600 {
4601 return FALSE;
4602 }
4603 }
4604 return TRUE;
4605} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08004606
Shailender Karmuchia734f332013-04-19 14:02:48 -07004607eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004608hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004609{
4610 eCsrEncryptionType cipher_type;
4611 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004612 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 {
4614 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004615 } else
4616 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 {
4618 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004619 } else
4620 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 {
4622 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004623 } else
4624 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 {
4626 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004627 } else
4628 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004630 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4631 } else
4632 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4634 }
4635 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4636 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004637}
Jeff Johnson295189b2012-06-20 16:38:30 -07004638
Shailender Karmuchia734f332013-04-19 14:02:48 -07004639static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
4640 struct ether_addr *pBssid,
4641 eCsrEncryptionType *pEncryptType,
4642 eCsrEncryptionType *mcEncryptType,
4643 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004644#ifdef WLAN_FEATURE_11W
4645 u_int8_t *pMfpRequired,
4646 u_int8_t *pMfpCapable,
4647#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004648 u_int16_t gen_ie_len,
4649 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07004650{
4651 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004652 eHalStatus result;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304653 tDot11fIERSN dot11RSNIE = {0};
4654 tDot11fIEWPA dot11WPAIE = {0};
Shailender Karmuchia734f332013-04-19 14:02:48 -07004655 tANI_U32 i;
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304656 tANI_U32 status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004657 tANI_U8 *pRsnIe;
4658 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07004660 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004661
4662 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
4663 flag to 0 */
4664 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
4665 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
gaurank kathpaliab654f702020-01-03 15:07:17 +05304666 memset( PMKIDCache, 0 , sizeof(tPmkidCacheInfo) * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004667
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07004669 if ( gen_ie[0] == DOT11F_EID_RSN)
4670 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07004672 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
4674 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304675 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
4676 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 return -EINVAL;
4678 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004679 // Skip past the EID byte and length byte
4680 pRsnIe = gen_ie + 2;
4681 RSNIeLen = gen_ie_len - 2;
4682 // Unpack the RSN IE
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304683 status = sme_unpack_rsn_ie(halHandle,
4684 pRsnIe,
4685 RSNIeLen,
4686 &dot11RSNIE);
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304687 if (DOT11F_FAILED(status))
4688 {
4689 hddLog(LOGE,
4690 FL("Parse failure in hdd_ProcessGENIE (0x%08x)"),
4691 status);
4692 return -EINVAL;
4693 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304694 hddLog(LOG1, FL("%s: gp_cipher_suite_present: %d"),
4695 __func__, dot11RSNIE.gp_cipher_suite_present);
4696
Shailender Karmuchia734f332013-04-19 14:02:48 -07004697 // Copy out the encryption and authentication types
4698 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004699 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004700 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304701 __func__, dot11RSNIE.akm_suite_cnt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004702 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 but probably I suspect we can do something different*/
4704 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07004705 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304706 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004707 //dot11RSNIE.pwise_cipher_suite_count
4708 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
4709 //dot11RSNIE.gp_cipher_suite_count
4710 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07004711#ifdef WLAN_FEATURE_11W
4712 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
4713 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
4714#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07004716 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004718 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304720 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 break;
4722 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004723 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304725 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 break;
4727 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004728 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 // For right now, I assume setASSOCIATE() has passed in the bssid.
4730 vos_mem_copy(PMKIDCache[i].BSSID,
4731 pBssid, ETHER_ADDR_LEN);
4732 vos_mem_copy(PMKIDCache[i].PMKID,
4733 dot11RSNIE.pmkid[i],
4734 CSR_RSN_PMKID_SIZE);
4735 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004736
4737 if (updatePMKCache)
4738 {
4739 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004740 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004741 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07004742 // Finally set the PMKSA ID Cache in CSR
4743 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
4744 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304745 dot11RSNIE.pmkid_count,
4746 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07004747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 }
4749 else if (gen_ie[0] == DOT11F_EID_WPA)
4750 {
4751 // Validity checks
4752 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
4753 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
4754 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304755 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
4756 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 return -EINVAL;
4758 }
4759 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07004760 pRsnIe = gen_ie + 2 + 4;
4761 RSNIeLen = gen_ie_len - (2 + 4);
4762 // Unpack the WPA IE
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304763 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304764 pRsnIe, RSNIeLen, &dot11WPAIE);
4765 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304766 {
4767 hddLog(LOGE,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304768 FL("Invalid RSN IE: parse status %d"), status);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304769 return -EINVAL;
4770 }
4771
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 // Copy out the encryption and authentication types
4773 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004774 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004776 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 //dot11WPAIE.auth_suite_count
4778 // Just translate the FIRST one
4779 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
4780 //dot11WPAIE.unicast_cipher_count
4781 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
4782 //dot11WPAIE.unicast_cipher_count
4783 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
4784 }
4785 else
4786 {
4787 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004788 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 }
4790 return 0;
4791}
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304792
4793/**
4794 * hdd_set_def_rsne_override() - set default encryption type and auth type
4795 * in profile.
4796 * @roam_profile: pointer to adapter
4797 * @auth_type: pointer to auth type
4798 *
4799 * Set default value of encryption type and auth type in profile to
4800 * search the AP using filter, as in force_rsne_override the RSNIE can be
4801 * currupt and we might not get the proper encryption type and auth type
4802 * while parsing the RSNIE.
4803 *
4804 * Return: void
4805 */
4806static void hdd_set_def_rsne_override(
4807 tCsrRoamProfile *roam_profile, eCsrAuthType *auth_type)
4808{
4809 hddLog( LOG1, FL("Set def values in roam profile"));
4810 roam_profile->MFPCapable = roam_profile->MFPEnabled;
4811 roam_profile->EncryptionType.numEntries = 2;
4812 roam_profile->mcEncryptionType.numEntries = 2;
4813 /* Use the cipher type in the RSN IE */
4814 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
4815 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
4816 roam_profile->mcEncryptionType.encryptionType[0] =
4817 eCSR_ENCRYPT_TYPE_AES;
4818 roam_profile->mcEncryptionType.encryptionType[1] =
4819 eCSR_ENCRYPT_TYPE_TKIP;
4820 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
4821}
4822
Jeff Johnson295189b2012-06-20 16:38:30 -07004823int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
4824{
4825 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4826 v_U32_t status = 0;
4827 eCsrEncryptionType RSNEncryptType;
4828 eCsrEncryptionType mcRSNEncryptType;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304829 hdd_context_t *hdd_ctx;
Chet Lanctot186b5732013-03-18 10:26:30 -07004830#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304831 u_int8_t RSNMfpRequired = 0;
4832 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07004833#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 struct ether_addr bSsid; // MAC address of assoc peer
4835 // MAC address of assoc peer
4836 // But, this routine is only called when we are NOT associated.
4837 vos_mem_copy(bSsid.ether_addr_octet,
4838 pWextState->roamProfile.BSSIDs.bssid,
4839 sizeof(bSsid.ether_addr_octet));
4840 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
4841 {
4842 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07004843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 else
4845 {
4846 return 0;
4847 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304848
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 // The actual processing may eventually be more extensive than this.
4850 // Right now, just consume any PMKIDs that are sent in by the app.
4851 status = hdd_ProcessGENIE(pAdapter,
4852 &bSsid, // MAC address of assoc peer
4853 &RSNEncryptType,
4854 &mcRSNEncryptType,
4855 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004856#ifdef WLAN_FEATURE_11W
4857 &RSNMfpRequired,
4858 &RSNMfpCapable,
4859#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 pWextState->WPARSNIE[1]+2,
4861 pWextState->WPARSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304862
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 if (status == 0)
4864 {
4865 // Now copy over all the security attributes you have parsed out
4866 pWextState->roamProfile.EncryptionType.numEntries = 1;
4867 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004868
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
4870 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07004871
Shailender Karmuchi642e9812013-05-30 14:34:49 -07004872 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
4873 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
4874 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
4875 {
4876 /*For wpa none supplicant sends the WPA IE with unicast cipher as
4877 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
4878 either AES/TKIP based on group cipher configuration
4879 mentioned in the wpa_supplicant.conf.*/
4880
4881 /*Set the unicast cipher same as multicast cipher*/
4882 pWextState->roamProfile.EncryptionType.encryptionType[0]
4883 = mcRSNEncryptType;
4884 }
4885
Chet Lanctot186b5732013-03-18 10:26:30 -07004886#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304887 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
4888 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07004889 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
4890 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
4891#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304892 hddLog( LOG1,
4893 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
4894 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304895 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304897
4898 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4899 if (hdd_ctx->force_rsne_override &&
4900 (pWextState->WPARSNIE[0] == DOT11F_EID_RSN)) {
4901 hddLog(LOG1,
4902 FL("Test mode enabled set def Auth and enc type. RSN IE passed in connect req:"));
4903 vos_trace_hex_dump(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4904 pWextState->roamProfile.pRSNReqIE,
4905 pWextState->roamProfile.nRSNReqIELength);
4906
4907 pWextState->roamProfile.force_rsne_override = true;
4908 hddLog(LOG1,
4909 FL("MFPEnabled %d"), pWextState->roamProfile.MFPEnabled);
4910 /*
4911 * Reset MFPEnabled if testmode RSNE passed doesnt have MFPR
4912 * or MFPC bit set
4913 */
4914 if (pWextState->roamProfile.MFPEnabled &&
4915 !(pWextState->roamProfile.MFPRequired ||
4916 pWextState->roamProfile.MFPCapable)) {
4917 hddLog( LOG1,FL("Reset MFPEnabled"));
4918 pWextState->roamProfile.MFPEnabled = 0;
4919 }
4920
4921 /* If parsing failed set the def value for the roam profile */
4922 if (status)
4923 hdd_set_def_rsne_override(&pWextState->roamProfile,
4924 RSNAuthType);
4925 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304926 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004927}
4928int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
4929{
4930 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4931 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
4932 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4933 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004934
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 pRoamProfile->AuthType.numEntries = 1;
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304936 hddLog( LOG1,
Abhinav Kumar2184e162019-09-16 15:02:24 +05304937 "%s: authType = %d RSNAuthType %d wpa_versions %d key_mgmt : 0x%x",
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304938 __func__, pHddStaCtx->conn_info.authType, RSNAuthType,
Abhinav Kumar2184e162019-09-16 15:02:24 +05304939 pWextState->wpaVersion, pWextState->authKeyMgmt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004940
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 switch( pHddStaCtx->conn_info.authType)
4942 {
4943 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Abhinav Kumar62801ba2018-09-19 12:14:14 +05304944 case eCSR_AUTH_TYPE_AUTOSWITCH:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004945#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 case eCSR_AUTH_TYPE_CCKM_WPA:
4947 case eCSR_AUTH_TYPE_CCKM_RSN:
4948#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004949 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4950
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004952 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004954
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004955#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004956 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4957 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4958 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004959 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004960 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4961 } else
4962 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004963 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004964 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 } else
4966#endif
4967 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4968 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004969 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4970 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4972 == IW_AUTH_KEY_MGMT_PSK) {
4973 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004974 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 }
4978 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004979#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004980 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4981 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4982 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004983 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004984 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004986 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004987 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004988 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 } else
4990#endif
4991
4992#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004993 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4994 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004996 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004997 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004998 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5000 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005001 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07005002 } else
5003#endif
5004
Chet Lanctot186b5732013-03-18 10:26:30 -07005005#ifdef WLAN_FEATURE_11W
5006 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5007 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5008 } else
Abhishek Singhae408032014-09-25 17:22:04 +05305009 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5010 pRoamProfile->AuthType.authType[0] =
5011 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5012 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07005013#endif
Abhinav Kumara4282182019-09-13 11:25:59 +05305014 if ((RSNAuthType == eCSR_AUTH_TYPE_SAE) &&
5015 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5016 == IW_AUTH_KEY_MGMT_802_1X)) {
5017 /* SAE case */
5018 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5019 } else
Abhinav Kumar487e49e2019-07-22 14:46:18 +05305020 if ((RSNAuthType == eCSR_AUTH_TYPE_OWE) &&
5021 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5022 == IW_AUTH_KEY_MGMT_802_1X)) {
5023 /* OWE case */
5024 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OWE;
5025 } else
Abhinav Kumar2184e162019-09-16 15:02:24 +05305026 if (RSNAuthType == eCSR_AUTH_TYPE_SAE) {
5027 /* SAE with open authentication case */
5028 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5029 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07005030 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005032 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
5033 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5035 == IW_AUTH_KEY_MGMT_PSK) {
5036 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Abhinav Kumar487e49e2019-07-22 14:46:18 +05305037 } else
5038 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005042 break;
5043
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005045
5046 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05305048 case eCSR_AUTH_TYPE_SAE:
5049 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5050 break;
5051
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005053
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005054#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08005055 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005056#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5058 break;
5059 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005060
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005062 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005063
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 EXIT();
5065 return 0;
5066}
5067
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05305068/**
5069 * hdd_rx_fwd_eapol() - forward cached eapol frames
5070 * @vosContext : pointer to vos global context
5071 * @pVosPacket: pointer to vos packet
5072 *
5073 * Return: None
5074 *
5075 */
5076void hdd_assoc_registerFwdEapolCB(void *pContext)
5077{
5078 WLANTL_RegisterFwdEapol(pContext, hdd_rx_fwd_eapol);
5079}
5080
Jeff Johnson295189b2012-06-20 16:38:30 -07005081/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005082
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305083 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07005085 to the CSR roam profile.
5086
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 \param - dev - Pointer to the net device.
5088 - info - Pointer to the iw_request_info.
5089 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005090 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005092
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 --------------------------------------------------------------------------*/
5094
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305095int __iw_set_essid(struct net_device *dev,
5096 struct iw_request_info *info,
5097 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005098{
5099 v_U32_t status = 0;
5100 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305101 hdd_adapter_t *pAdapter;
5102 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 v_U32_t roamId;
5104 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305106 tHalHandle hHal;
5107 hdd_station_ctx_t *pHddStaCtx;
5108 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005109
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305111 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5112 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05305114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305115 "%s: Adapter is NULL",__func__);
5116 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005117 }
5118
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305119 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5120 ret = wlan_hdd_validate_context(pHddCtx);
5121 if (0 != ret)
5122 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305123 return ret;
5124 }
5125
5126 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5127 if (NULL == hHal)
5128 {
5129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5130 "%s: Hal Context is NULL",__func__);
5131 return -EINVAL;
5132 }
5133 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5134 if (NULL == pHddStaCtx)
5135 {
5136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5137 "%s: STA Context is NULL",__func__);
5138 return -EINVAL;
5139 }
5140 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5141 if (NULL == pWextState)
5142 {
5143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5144 "%s: pWextState is NULL",__func__);
5145 return -EINVAL;
5146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
5148 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
5149 return -EBUSY;
5150 }
5151 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
5152 return -EINVAL;
5153 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005154
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305155 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
5156 return -EINVAL;
5157
Agrawal Ashishc407f192017-01-23 17:18:35 +05305158 /*Try disconnecting if already in connected state*/
5159 status = wlan_hdd_try_disconnect(pAdapter);
5160 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 {
Agrawal Ashishc407f192017-01-23 17:18:35 +05305162 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
5163 " connection"));
5164 return -EALREADY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 }
5166 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07005167 /** when cfg80211 defined, wpa_supplicant wext driver uses
5168 zero-length, null-string ssid for force disconnection.
5169 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 driver MUST return success */
5171 if ( 0 == wrqu->essid.length ) {
5172 return 0;
5173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005174
5175 status = hdd_wmm_get_uapsd_mask(pAdapter,
5176 &pWextState->roamProfile.uapsd_mask);
5177 if (VOS_STATUS_SUCCESS != status)
5178 {
5179 pWextState->roamProfile.uapsd_mask = 0;
5180 }
5181 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005182
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005184
5185 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
5187 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
5188 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005189
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 //set gen ie
5191 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5192
5193 //set auth
5194 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5195 }
5196#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005197 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 if (pAdapter->wapi_info.nWapiMode)
5199 {
5200 switch (pAdapter->wapi_info.wapiAuthMode)
5201 {
5202 case WAPI_AUTH_MODE_PSK:
5203 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005204 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 pRoamProfile->AuthType.numEntries = 1;
5206 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5207 break;
5208 }
5209 case WAPI_AUTH_MODE_CERT:
5210 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005211 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 pRoamProfile->AuthType.numEntries = 1;
5213 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5214 break;
5215 }
5216 } // End of switch
5217 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5218 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5219 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005220 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 pRoamProfile->EncryptionType.numEntries = 1;
5222 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5223 pRoamProfile->mcEncryptionType.numEntries = 1;
5224 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5225 }
5226 }
5227#endif /* FEATURE_WLAN_WAPI */
5228 /* if previous genIE is not NULL, update AssocIE */
5229 if (0 != pWextState->genIE.length)
5230 {
5231 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
5232 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
5233 pWextState->genIE.length);
5234 pWextState->assocAddIE.length = pWextState->genIE.length;
5235 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5236 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5237
5238 /* clear previous genIE after use it */
5239 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
5240 }
5241
5242 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
5243 pWextState->roamProfile.bWPSAssociation = FALSE;
5244
5245 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5246 pWextState->roamProfile.nAddIEAssocLength))
5247 pWextState->roamProfile.bWPSAssociation = TRUE;
5248
5249
5250 // Disable auto BMPS entry by PMC until DHCP is done
5251 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
5252
Shailender Karmuchia734f332013-04-19 14:02:48 -07005253 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005254 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005255
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005256 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
5257 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005258 hdd_select_cbmode(pAdapter,
5259 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
5260 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305261 /*
5262 * Change conn_state to connecting before sme_RoamConnect(),
5263 * because sme_RoamConnect() has a direct path to call
5264 * hdd_smeRoamCallback(), which will change the conn_state
5265 * If direct path, conn_state will be accordingly changed
5266 * to NotConnected or Associated by either
5267 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
5268 * in sme_RoamCallback()
5269 * if sme_RomConnect is to be queued,
5270 * Connecting state will remain until it is completed.
5271 *
5272 * If connection state is not changed,
5273 * connection state will remain in eConnectionState_NotConnected state.
5274 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
5275 * if conn state is eConnectionState_NotConnected.
5276 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5277 * informed of connect result indication which is an issue.
5278 */
5279 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5280 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
5281 {
5282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5283 FL("Set HDD connState to eConnectionState_Connecting"));
5284 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5285 eConnectionState_Connecting);
5286 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005287 status = sme_RoamConnect( hHal,pAdapter->sessionId,
5288 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305289
5290 if ((eHAL_STATUS_SUCCESS != status) &&
5291 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5292 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5293 {
5294 hddLog(VOS_TRACE_LEVEL_ERROR,
5295 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
5296 pAdapter->sessionId, status);
5297 /* change back to NotAssociated */
5298 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5299 eConnectionState_NotConnected);
5300 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005301 pRoamProfile->ChannelInfo.ChannelList = NULL;
5302 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005303
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005304 EXIT();
5305 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005306}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005307
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305308int iw_set_essid(struct net_device *dev,
5309 struct iw_request_info *info,
5310 union iwreq_data *wrqu, char *extra)
5311{
5312 int ret;
5313
5314 vos_ssr_protect(__func__);
5315 ret = __iw_set_essid(dev, info, wrqu, extra);
5316 vos_ssr_unprotect(__func__);
5317
5318 return ret;
5319}
5320
Jeff Johnson295189b2012-06-20 16:38:30 -07005321/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005322
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305323 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005325
Jeff Johnson295189b2012-06-20 16:38:30 -07005326 \param - dev - Pointer to the net device.
5327 - info - Pointer to the iw_request_info.
5328 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005329 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005331
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305333int __iw_get_essid(struct net_device *dev,
5334 struct iw_request_info *info,
5335 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005336{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305337 hdd_adapter_t *pAdapter;
5338 hdd_context_t *pHddCtx;
5339 hdd_wext_state_t *wextBuf;
5340 hdd_station_ctx_t *pHddStaCtx;
5341 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305342
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 ENTER();
5344
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305345 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5346 if (NULL == pAdapter)
5347 {
5348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5349 "%s: Adapter is NULL",__func__);
5350 return -EINVAL;
5351 }
5352
5353 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5354 ret = wlan_hdd_validate_context(pHddCtx);
5355 if (0 != ret)
5356 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305357 return ret;
5358 }
5359
5360 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5361 if (NULL == pHddStaCtx)
5362 {
5363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5364 "%s: STA Context is NULL",__func__);
5365 return -EINVAL;
5366 }
5367
5368 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5369 if (NULL == wextBuf)
5370 {
5371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5372 "%s: wextBuf is NULL",__func__);
5373 return -EINVAL;
5374 }
5375
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5377 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5378 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
5379 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
5380 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
5381 {
5382 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5383 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
5384 dwrq->flags = 1;
5385 } else {
5386 memset(extra, 0, dwrq->length);
5387 dwrq->length = 0;
5388 dwrq->flags = 0;
5389 }
5390 EXIT();
5391 return 0;
5392}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305393
5394int iw_get_essid(struct net_device *dev,
5395 struct iw_request_info *info,
5396 struct iw_point *dwrq, char *extra)
5397{
5398 int ret;
5399
5400 vos_ssr_protect(__func__);
5401 ret = __iw_get_essid(dev, info, dwrq, extra);
5402 vos_ssr_unprotect(__func__);
5403
5404 return ret;
5405}
Jeff Johnson295189b2012-06-20 16:38:30 -07005406/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005407
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305408 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005410
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 \param - dev - Pointer to the net device.
5412 - info - Pointer to the iw_request_info.
5413 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005414 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005416
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305418int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
5419 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005420{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305421 hdd_adapter_t *pAdapter;
5422 hdd_context_t *pHddCtx;
5423 hdd_wext_state_t *pWextState;
5424 hdd_station_ctx_t *pHddStaCtx;
5425 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005426 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305428 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005429
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005431
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305432 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5433 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005434 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5436 "%s: Adapter is NULL",__func__);
5437 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005438 }
5439
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305440 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5441 ret = wlan_hdd_validate_context(pHddCtx);
5442 if (0 != ret)
5443 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305444 return ret;
5445 }
5446
5447 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5448 if (NULL == pHddStaCtx)
5449 {
5450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5451 "%s: STA Context is NULL",__func__);
5452 return -EINVAL;
5453 }
5454
5455 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5456 if (NULL == pWextState)
5457 {
5458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5459 "%s: pWextState is NULL",__func__);
5460 return -EINVAL;
5461 }
5462
5463 pRoamProfile = &pWextState->roamProfile;
5464
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 switch(wrqu->param.flags & IW_AUTH_INDEX)
5466 {
5467 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005468
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005470
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005472
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 case IW_AUTH_CIPHER_PAIRWISE:
5474 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005475 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5479 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5482 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005483 }
5484
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005486
5487 if( (IW_AUTH_KEY_MGMT_802_1X
5488 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
5490 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005491 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 else
5493 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005494 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005497
5498 if( ( IW_AUTH_KEY_MGMT_802_1X
5499 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5501 /*Dynamic WEP key*/
5502 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5503 else
5504 /*Static WEP key*/
5505 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005506
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 }
5508 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005509
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005511 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 return -EINVAL;
5513 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005514
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 pRoamProfile->EncryptionType.numEntries = 1;
5516 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 break;
5519 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005520 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5522 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5523 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005524
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5526 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5527 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005528
5529 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5531 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005532
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005534
5535 if( ( IW_AUTH_KEY_MGMT_802_1X
5536 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5537 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5538
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005540
5541 else
5542 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005544
5545 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
5546 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005548 if( ( IW_AUTH_KEY_MGMT_802_1X
5549 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5551 {
5552 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5553 }
5554 else
5555 {
5556 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5557 }
5558 }
5559 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005560
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005562 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 return -EINVAL;
5564 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005565
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 pRoamProfile->mcEncryptionType.numEntries = 1;
5567 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
5568 }
5569 break;
5570
5571 case IW_AUTH_80211_AUTH_ALG:
5572 {
5573 /*Save the auth algo here and set auth type to SME Roam profile
5574 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005575 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005577
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5579 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5580
5581 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
5582 /*Not supported*/
5583 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5584 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5585 }
5586 break;
5587
5588 case IW_AUTH_KEY_MGMT:
5589 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005590#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005591#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5592 /*Check for CCKM AKM type */
5593 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005594 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
5595 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005596 /* Set the CCKM bit in authKeyMgmt */
5597 /* Right now, this breaks all ref to authKeyMgmt because our
5598 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 */
5600 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5601 /*Set the key management to 802.1X*/
5602 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005603 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5605 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
5606 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5607 /*Save the key management*/
5608 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5609 //pWextState->authKeyMgmt = wrqu->param.value;
5610 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5611 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5612 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5613 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
5614 /*Save the key management anyway*/
5615 pWextState->authKeyMgmt = wrqu->param.value;
5616 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
5617 /*Save the key management*/
5618 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5619 //pWextState->authKeyMgmt = wrqu->param.value;
5620 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5621 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5622 }
5623#else
5624 /*Save the key management*/
5625 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005626#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 }
5628 break;
5629
5630 case IW_AUTH_TKIP_COUNTERMEASURES:
5631 {
5632 if(wrqu->param.value) {
5633 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5634 "Counter Measure started %d", wrqu->param.value);
5635 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
5636 }
5637 else {
5638 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5639 "Counter Measure stopped=%d", wrqu->param.value);
5640 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
5641 }
5642 }
5643 break;
5644 case IW_AUTH_DROP_UNENCRYPTED:
5645 case IW_AUTH_WPA_ENABLED:
5646 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5647 case IW_AUTH_ROAMING_CONTROL:
5648 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005649
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005651
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005652 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 wrqu->param.flags & IW_AUTH_INDEX);
5654 break;
5655 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005656
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 EXIT();
5658 return 0;
5659}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305660
5661int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5662 union iwreq_data *wrqu, char *extra)
5663{
5664 int ret;
5665
5666 vos_ssr_protect(__func__);
5667 ret = __iw_set_auth(dev, info, wrqu, extra);
5668 vos_ssr_unprotect(__func__);
5669
5670 return ret;
5671}
5672
Jeff Johnson295189b2012-06-20 16:38:30 -07005673/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005674
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305675 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005677
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 \param - dev - Pointer to the net device.
5679 - info - Pointer to the iw_request_info.
5680 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005681 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005683
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305685int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5686 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005687{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305688 hdd_adapter_t* pAdapter;
5689 hdd_wext_state_t *pWextState;
5690 tCsrRoamProfile *pRoamProfile;
5691 hdd_context_t *pHddCtx;
5692 int ret = 0;
5693
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005695
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305696 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5697 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005698 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5700 "%s: Adapter is NULL",__func__);
5701 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005702 }
5703
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305704 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5705 ret = wlan_hdd_validate_context(pHddCtx);
5706 if (0 != ret)
5707 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305708 return ret;
5709 }
5710
5711 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5712 if (NULL == pWextState)
5713 {
5714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5715 "%s: pWextState is NULL",__func__);
5716 return -EINVAL;
5717 }
5718 pRoamProfile = &pWextState->roamProfile;
5719
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 switch(pRoamProfile->negotiatedAuthType)
5721 {
5722 case eCSR_AUTH_TYPE_WPA_NONE:
5723 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5724 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
5725 break;
5726 case eCSR_AUTH_TYPE_WPA:
5727 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5728 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
5729 break;
5730#ifdef WLAN_FEATURE_VOWIFI_11R
5731 case eCSR_AUTH_TYPE_FT_RSN:
5732#endif
5733 case eCSR_AUTH_TYPE_RSN:
5734 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5735 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
5736 break;
5737 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5738 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5739 break;
5740 case eCSR_AUTH_TYPE_SHARED_KEY:
5741 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
5742 break;
5743 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005744 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005745 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5746 break;
5747 case eCSR_AUTH_TYPE_AUTOSWITCH:
5748 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5749 break;
5750 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305751 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5753 return -EIO;
5754#ifdef WLAN_FEATURE_VOWIFI_11R
5755 case eCSR_AUTH_TYPE_FT_RSN_PSK:
5756#endif
5757 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07005758#ifdef WLAN_FEATURE_11W
5759 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05305760 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07005761#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05305762 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5764 return -EIO;
5765 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305766 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5768 return -EIO;
5769 }
5770 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
5771 {
5772 switch(pRoamProfile->negotiatedUCEncryptionType)
5773 {
5774 case eCSR_ENCRYPT_TYPE_NONE:
5775 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5776 break;
5777 case eCSR_ENCRYPT_TYPE_WEP40:
5778 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5779 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5780 break;
5781 case eCSR_ENCRYPT_TYPE_TKIP:
5782 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5783 break;
5784 case eCSR_ENCRYPT_TYPE_WEP104:
5785 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5786 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5787 break;
5788 case eCSR_ENCRYPT_TYPE_AES:
5789 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5790 break;
5791 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305792 hddLog(LOG1, "%s called with unknown auth type %d ",
5793 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 return -EIO;
5795 }
5796 }
5797
Shailender Karmuchia734f332013-04-19 14:02:48 -07005798 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 {
5800 switch(pRoamProfile->negotiatedMCEncryptionType)
5801 {
5802 case eCSR_ENCRYPT_TYPE_NONE:
5803 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5804 break;
5805 case eCSR_ENCRYPT_TYPE_WEP40:
5806 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5807 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5808 break;
5809 case eCSR_ENCRYPT_TYPE_TKIP:
5810 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5811 break;
5812 case eCSR_ENCRYPT_TYPE_WEP104:
5813 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5814 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5815 break;
5816 case eCSR_ENCRYPT_TYPE_AES:
5817 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5818 break;
5819 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305820 hddLog(LOG1, "%s called with unknown auth type %d ",
5821 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 return -EIO;
5823 }
5824 }
5825
5826 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005827 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 EXIT();
5829 return 0;
5830}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305831
5832int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5833 union iwreq_data *wrqu,char *extra)
5834{
5835 int ret;
5836
5837 vos_ssr_protect(__func__);
5838 ret = __iw_get_auth(dev, info, wrqu, extra);
5839 vos_ssr_unprotect(__func__);
5840
5841 return ret;
5842}
5843
Jeff Johnson295189b2012-06-20 16:38:30 -07005844/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005845
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305846 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07005847 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005849
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 \param - dev - Pointer to the net device.
5851 - info - Pointer to the iw_request_info.
5852 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005853 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005855
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305857int __iw_set_ap_address(struct net_device *dev,
5858 struct iw_request_info *info,
5859 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005860{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305861 hdd_station_ctx_t *pHddStaCtx;
5862 hdd_adapter_t *pAdapter;
5863 hdd_context_t *pHddCtx;
5864 v_U8_t *pMacAddress = NULL;
5865 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305866
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305868
5869 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5870 if (NULL == pAdapter)
5871 {
5872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5873 "%s: Adapter is NULL", __func__);
5874 return -EINVAL;
5875 }
5876 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5877 ret = wlan_hdd_validate_context(pHddCtx);
5878 if (0 != ret)
5879 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305880 return ret;
5881 }
5882 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5883 if (NULL == pHddStaCtx)
5884 {
5885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5886 "%s: pHddStaCtx is NULL", __func__);
5887 return -EINVAL;
5888 }
5889
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08005891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
5892 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07005894
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305895 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 return 0;
5897}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305898
5899int iw_set_ap_address(struct net_device *dev,
5900 struct iw_request_info *info,
5901 union iwreq_data *wrqu, char *extra)
5902{
5903 int ret;
5904
5905 vos_ssr_protect(__func__);
5906 ret = __iw_set_ap_address(dev, info, wrqu, extra);
5907 vos_ssr_unprotect(__func__);
5908
5909 return ret;
5910}
5911
Jeff Johnson295189b2012-06-20 16:38:30 -07005912/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005913
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305914 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 This function returns the BSSID to the wpa_supplicant
5916 \param - dev - Pointer to the net device.
5917 - info - Pointer to the iw_request_info.
5918 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005919 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005921
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305923int __iw_get_ap_address(struct net_device *dev,
5924 struct iw_request_info *info,
5925 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005926{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305927 hdd_station_ctx_t *pHddStaCtx;
5928 hdd_adapter_t *pAdapter;
5929 hdd_context_t *pHddCtx;
5930 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305931
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 ENTER();
5933
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305934 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5935 if (NULL == pAdapter)
5936 {
5937 hddLog(VOS_TRACE_LEVEL_ERROR,
5938 "%s: Adapter is NULL", __func__);
5939 return -EINVAL;
5940 }
5941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5942 ret = wlan_hdd_validate_context(pHddCtx);
5943 if (0 != ret)
5944 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305945 return ret;
5946 }
5947 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5948 if (NULL == pHddStaCtx)
5949 {
5950 hddLog(VOS_TRACE_LEVEL_ERROR,
5951 "%s: pHddStaCtx is NULL", __func__);
5952 return -EINVAL;
5953 }
5954
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
5956 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
5957 {
Jeff Johnson4416a782013-03-25 14:17:50 -07005958 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 }
5960 else
5961 {
5962 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
5963 }
5964 EXIT();
5965 return 0;
5966}
Jeff Johnsond13512a2012-07-17 11:42:19 -07005967
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305968int iw_get_ap_address(struct net_device *dev,
5969 struct iw_request_info *info,
5970 union iwreq_data *wrqu, char *extra)
5971{
5972 int ret;
5973
5974 vos_ssr_protect(__func__);
5975 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5976 vos_ssr_unprotect(__func__);
5977
5978 return ret;
5979}
5980
Chet Lanctot186b5732013-03-18 10:26:30 -07005981#ifdef WLAN_FEATURE_11W
5982/**---------------------------------------------------------------------------
5983
5984 \brief hdd_indicateUnprotMgmtFrame -
5985 This function forwards the unprotected management frame to the supplicant
5986 \param - pAdapter - Pointer to HDD adapter
5987 - nFrameLength - Length of the unprotected frame being passed
5988 - pbFrames - Pointer to the frame buffer
5989 - frameType - 802.11 frame type
5990 \return - nothing
5991
5992 --------------------------------------------------------------------------*/
5993void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5994 tANI_U32 nFrameLength,
5995 tANI_U8* pbFrames,
5996 tANI_U8 frameType )
5997{
5998 tANI_U8 type = 0;
5999 tANI_U8 subType = 0;
6000
6001 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
6002 __func__, frameType, nFrameLength);
6003
6004 /* Sanity Checks */
6005 if (NULL == pAdapter)
6006 {
6007 hddLog( LOGE, FL("pAdapter is NULL"));
6008 return;
6009 }
6010
6011 if (NULL == pAdapter->dev)
6012 {
6013 hddLog( LOGE, FL("pAdapter->dev is NULL"));
6014 return;
6015 }
6016
6017 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
6018 {
6019 hddLog( LOGE, FL("pAdapter has invalid magic"));
6020 return;
6021 }
6022
6023 if( !nFrameLength )
6024 {
6025 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
6026 return;
6027 }
6028
6029 if (NULL == pbFrames) {
6030 hddLog( LOGE, FL("pbFrames is NULL"));
6031 return;
6032 }
6033
6034 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
6035 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
6036
6037 /* Get pAdapter from Destination mac address of the frame */
6038 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
6039 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306040#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
6041 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
6042#else
Chet Lanctot186b5732013-03-18 10:26:30 -07006043 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306044#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006045 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
6046 }
6047 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
6048 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
6050 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
6051#else
Chet Lanctot186b5732013-03-18 10:26:30 -07006052 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306053#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006054 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
6055 }
6056 else
6057 {
6058 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
6059 return;
6060 }
6061}
6062#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006063
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006064#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006065void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
6066 tANI_U8 state,
6067 tANI_U16 measInterval )
6068{
6069 union iwreq_data wrqu;
6070 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006071 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006072
6073 if (NULL == pAdapter)
6074 return;
6075
6076 // create the event
6077 memset(&wrqu, '\0', sizeof(wrqu));
6078 memset(buf, '\0', sizeof(buf));
6079
6080 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
6081 tid, state, measInterval);
6082
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006083 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006084
6085 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006086 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006087 // send the event
6088 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6089}
6090
6091void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
6092{
6093 union iwreq_data wrqu;
6094 char buf[IW_CUSTOM_MAX + 1];
6095 char *pos = buf;
6096 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6097
6098 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6099 return;
6100
6101 // create the event
6102 memset(&wrqu, '\0', sizeof(wrqu));
6103 memset(buf, '\0', sizeof(buf));
6104
6105 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306106 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
6107 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
6108 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
6109 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006110
6111 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
6112 pos += nBytes;
6113 freeBytes -= nBytes;
6114
6115 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
6116 pos += WNI_CFG_BSSID_LEN;
6117 freeBytes -= WNI_CFG_BSSID_LEN;
6118
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006119 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
6120 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006121
6122 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006123 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006124
6125 // send the event
6126 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6127}
6128
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006129void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006130{
6131 union iwreq_data wrqu;
6132 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006133 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006134
6135 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6136 return;
6137
6138 // create the event
6139 memset(&wrqu, '\0', sizeof(wrqu));
6140 memset(buf, '\0', sizeof(buf));
6141
6142 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
6143
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006144 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006145
6146 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006147 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006148
6149 // send the event
6150 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6151}
6152
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006153void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
6154 const tANI_U16 measurementToken,
6155 const tANI_BOOLEAN flag,
6156 const tANI_U8 numBss)
6157{
6158 union iwreq_data wrqu;
6159 char buf[IW_CUSTOM_MAX];
6160 char *pos = buf;
6161 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6162
6163 memset(&wrqu, '\0', sizeof(wrqu));
6164 memset(buf, '\0', sizeof(buf));
6165
6166 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
6167 numBss);
6168
6169 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
6170 flag, numBss);
6171
6172 wrqu.data.pointer = buf;
6173 wrqu.data.length = nBytes;
6174 // send the event
6175 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6176}
6177
6178
6179static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006180 const tCsrRoamInfo *pRoamInfo)
6181{
6182 union iwreq_data wrqu;
6183 char buf[IW_CUSTOM_MAX + 1];
6184 char *pos = buf;
6185 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6186 tANI_U8 i = 0, len = 0;
6187 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
6188 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006189 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
6190 tANI_U8 ieLenByte = 1;
6191 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
6192#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006193
6194 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6195 return;
6196
6197 /* Custom event can pass maximum of 256 bytes of data,
6198 based on the IE len we need to identify how many BSS info can
6199 be filled in to custom event data */
6200 /*
6201 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
6202 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
6203 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
6204 */
6205
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006206 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006207 {
6208 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
6209 /* If the measurement is none and no scan results found,
6210 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006211 hdd_indicateEseBcnReportNoResults(pAdapter,
6212 pRoamInfo->pEseBcnReportRsp->measurementToken,
6213 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006214 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006215 }
6216 else
6217 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006218 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006219 {
6220 memset(&wrqu, '\0', sizeof(wrqu));
6221 memset(buf, '\0', sizeof(buf));
6222 tot_bcn_ieLen = 0;
6223 sendBss = 0;
6224 pos = buf;
6225 freeBytes = IW_CUSTOM_MAX;
6226
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006227 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006228 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006229 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
6230 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006231 {
6232 break;
6233 }
6234 tot_bcn_ieLen += len;
6235 sendBss++;
6236 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
6237 "IeLength(%d) Length of Ie(%d) totLen(%d)",
6238 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006239 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006240 tot_bcn_ieLen);
6241 }
6242
6243 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
6244 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006245 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6246 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006247
6248 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006249 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6250 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006251 pos += nBytes;
6252 freeBytes -= nBytes;
6253
6254 /* Copy total Beacon report data length */
6255 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
6256 pos += sizeof(tot_bcn_ieLen);
6257 freeBytes -= sizeof(tot_bcn_ieLen);
6258
6259 for (i = 0; i < sendBss; i++)
6260 {
6261 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306262 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
6263 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006264 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006265 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
6266 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
6267 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
6268 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
6269 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
6270 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
6271 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
6272 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
6273 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
6274 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
6275 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
6276 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
6277 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
6278 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
6279 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
6280 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006281
6282 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006283 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
6284 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006285 pos += len;
6286 freeBytes -= len;
6287
6288 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006289 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006290 vos_mem_copy(pos, (char*)&len, sizeof(len));
6291 pos += sizeof(len);
6292 freeBytes -= sizeof(len);
6293
6294 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006295 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006296 pos += len;
6297 freeBytes -= len;
6298 }
6299
6300 wrqu.data.pointer = buf;
6301 wrqu.data.length = strlen(buf);
6302
6303 // send the event
6304 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6305 lastSent += sendBss;
6306 }
6307 }
6308}
6309
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006310#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006311
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306312hdd_adapter_t *hdd_get_sta_connection_in_progress(hdd_context_t *hdd_ctx)
6313{
6314 hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
6315 hdd_adapter_t *adapter = NULL;
6316 VOS_STATUS status;
6317 hdd_station_ctx_t *hdd_sta_ctx;
6318
6319 if (!hdd_ctx) {
6320 hddLog(LOGE, FL("HDD context is NULL"));
6321 return NULL;
6322 }
6323
6324 status = hdd_get_front_adapter(hdd_ctx, &adapter_node);
6325 while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
6326 adapter = adapter_node->pAdapter;
6327 if (!adapter)
6328 goto end;
6329
6330 if ((WLAN_HDD_INFRA_STATION == adapter->device_mode) ||
6331 (WLAN_HDD_P2P_CLIENT == adapter->device_mode) ||
6332 (WLAN_HDD_P2P_DEVICE == adapter->device_mode)) {
6333 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6334 if (eConnectionState_Connecting ==
6335 hdd_sta_ctx->conn_info.connState) {
6336 hddLog(LOG1, FL("session_id %d: Connection is in progress"),
6337 adapter->sessionId);
6338 return adapter;
6339 } else if ((eConnectionState_Associated ==
6340 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +05306341 sme_is_sta_key_exchange_in_progress(
6342 hdd_ctx->hHal, adapter->sessionId)) {
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306343 hddLog(LOG1, FL("session_id %d: Key exchange is in progress"),
6344 adapter->sessionId);
6345 return adapter;
6346 }
6347 }
6348end:
6349 status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next);
6350 adapter_node = next;
6351 }
6352 return NULL;
6353}
6354