blob: 4ddb100ee5ee128859b0ed6647a160b7d0020081 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhe6137b82019-03-22 20:06:09 +05302 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +053056#include "wlan_hdd_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include <linux/ieee80211.h>
58#include <linux/wireless.h>
59#include <net/cfg80211.h>
60#include "wlan_hdd_cfg80211.h"
61#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053063#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080064#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053066#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053067#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053068#include <wlan_hdd_wext.h>
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053069#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053070
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053071#if defined CFG80211_ROAMED_API_UNIFIED || \
72 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
73/**
74 * hdd_send_roamed_ind() - send roamed indication to cfg80211
75 * @dev: network device
76 * @bss: cfg80211 roamed bss pointer
77 * @req_ie: IEs used in reassociation request
78 * @req_ie_len: Length of the @req_ie
79 * @resp_ie: IEs received in successful reassociation response
80 * @resp_ie_len: Length of @resp_ie
81 *
82 * Return: none
83 */
84static void hdd_send_roamed_ind(struct net_device *dev,
85 struct cfg80211_bss *bss, const uint8_t *req_ie,
86 size_t req_ie_len, const uint8_t *resp_ie,
87 size_t resp_ie_len)
88{
89 struct cfg80211_roam_info info = {0};
90
91 info.bss = bss;
92 info.req_ie = req_ie;
93 info.req_ie_len = req_ie_len;
94 info.resp_ie = resp_ie;
95 info.resp_ie_len = resp_ie_len;
96
97 cfg80211_roamed(dev, &info, GFP_KERNEL);
98}
99#else
100/**
101 * hdd_send_roamed_ind() - send roamed indication to cfg80211
102 * @dev: network device
103 * @bss: cfg80211 roamed bss pointer
104 * @req_ie: IEs used in reassociation request
105 * @req_ie_len: Length of the @req_ie
106 * @resp_ie: IEs received in successful reassociation response
107 * @resp_ie_len: Length of @resp_ie
108 *
109 * Return: none
110 */
111static inline void hdd_send_roamed_ind(struct net_device *dev,
112 struct cfg80211_bss *bss,
113 const uint8_t *req_ie, size_t req_ie_len,
114 const uint8_t *resp_ie,
115 size_t resp_ie_len)
116{
117 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
118 GFP_KERNEL);
119}
120#endif
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
123
Shailender Karmuchia734f332013-04-19 14:02:48 -0700124struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -0700125{
126 u_char ether_addr_octet[6];
127};
128// These are needed to recognize WPA and RSN suite types
129#define HDD_WPA_OUI_SIZE 4
130v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
131v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
132v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
133v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
134v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
135v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800136#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700137v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800138#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700139#define HDD_RSN_OUI_SIZE 4
140v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
141v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
142v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
143v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
144v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
145v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800146#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700147v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800148#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -0700149#ifdef WLAN_FEATURE_11W
150v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
Abhishek Singhae408032014-09-25 17:22:04 +0530151/* RSN-8021X-SHA256 */
152v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700153#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700154
Abhinav Kumar4d44f632019-08-02 13:55:54 +0530155#ifdef WLAN_FEATURE_SAE
156v_U8_t ccp_rsn_oui_80[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x08};
157v_U8_t ccp_rsn_oui_90[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x09};
158#endif
159
Shailender Karmuchia734f332013-04-19 14:02:48 -0700160#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700161// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700162#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
163#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700164#endif
165
166#define BEACON_FRAME_IES_OFFSET 12
167
Abhishek Singh78c691f2017-11-30 13:48:44 +0530168/* The time after add bss, in which SAP should start ECSA to move to SCC */
169#define ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL 1500
Abhishek Singh10e17cf2018-03-12 14:34:22 +0530170/*
171 * Time in ms after disconnect, in which the SAP should move to non DFS channel.
172 * This will avoid multiple SAP channel switch if disconnet is followed by
173 * connect.
174 */
175#define ECSA_DFS_CHAN_CHANGE_DEFER_TIME 200
Abhishek Singh78c691f2017-11-30 13:48:44 +0530176
Chet Lanctot186b5732013-03-18 10:26:30 -0700177#ifdef WLAN_FEATURE_11W
178void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
179 tANI_U32 nFrameLength,
180 tANI_U8* pbFrames,
181 tANI_U8 frameType );
182#endif
183
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800184#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700185static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
186 tANI_U8 state,
187 tANI_U16 measInterval );
188static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800189static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
190static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700191
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800192#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700193
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530194static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
195 tCsrRoamInfo *pRoamInfo,
196 tANI_U32 roamId,
197 eRoamCmdStatus roamStatus,
198 eCsrRoamResult roamResult );
199
Abhinav Kumar118efd02019-08-07 16:41:07 +0530200#if defined(WLAN_FEATURE_SAE) && \
201 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
202/**
203 * wlan_hdd_sae_callback() - Sends SAE info to supplicant
204 * @adapter: pointer adapter context
205 * @roam_info: pointer to roam info
206 *
207 * This API is used to send required SAE info to trigger SAE in supplicant.
208 *
209 * Return: None
210 */
211static void wlan_hdd_sae_callback(hdd_adapter_t *adapter,
212 tCsrRoamInfo *roam_info)
213{
214 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
215 int flags;
216 struct sir_sae_info *sae_info = roam_info->sae_info;
217 struct cfg80211_external_auth_params params = {0};
218
219 if (wlan_hdd_validate_context(hdd_ctx))
220 return;
221 if (!sae_info) {
222 hddLog(LOGE, FL("SAE info in NULL"));
223 return;
224 }
225 flags = vos_get_gfp_flags();
226
227 params.key_mgmt_suite = 0x00;
228 params.key_mgmt_suite |= 0x0F << 8;
229 params.key_mgmt_suite |= 0xAC << 16;
230 params.key_mgmt_suite |= 0x8 << 24;
231
232 params.action = NL80211_EXTERNAL_AUTH_START;
233 vos_mem_copy(params.bssid, sae_info->peer_mac_addr.bytes,
234 VOS_MAC_ADDR_SIZE);
235 vos_mem_copy(params.ssid.ssid, sae_info->ssid.ssId, sae_info->ssid.length);
236 params.ssid.ssid_len = sae_info->ssid.length;
237
238 cfg80211_external_auth_request(adapter->dev, &params, flags);
239 hddLog(LOG1, FL("SAE: sent cmd"));
240}
241#else
242static void wlan_hdd_sae_callback(hdd_adapter_t *adapter,
243 tCsrRoamInfo *roam_info)
244{ }
245#endif
246
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530247v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
248 eConnectionState connState )
249{
250 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530251 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
252 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700253 pHddStaCtx->conn_info.connState = connState;
254}
255
256// returns FALSE if not connected.
257// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
258// returns the connection state. Can specify NULL if you dont' want to get the actual state.
259
Shailender Karmuchia734f332013-04-19 14:02:48 -0700260static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
261 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700262{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700263 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700265
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 // get the connection state.
267 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700268 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700270 eConnectionState_IbssConnected == connState ||
271 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 {
273 fConnected = VOS_TRUE;
274 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700275 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 {
277 fConnected = VOS_FALSE;
278 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700279
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 if ( pConnState )
281 {
282 *pConnState = connState;
283 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700284
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 return( fConnected );
286}
287
288v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
289{
290 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700291}
Jeff Johnson295189b2012-06-20 16:38:30 -0700292
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530293eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
294{
295 v_U8_t staChannel = 0;
296
297 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
298 {
299 staChannel = pHddStaCtx->conn_info.operationChannel;
300 }
301
302 if ( staChannel > 0 && staChannel < 14 )
303 return eCSR_BAND_24;
304 else if (staChannel >= 36 && staChannel <= 165 )
305 return eCSR_BAND_5G;
306 else /* If station is not connected return as eCSR_BAND_ALL */
307 return eCSR_BAND_ALL;
308}
309
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311//TODO - Not used anyhwere. Can be removed.
312#if 0
313//
314v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
315{
316 v_BOOL_t fConnectedInfra = FALSE;
317 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700318
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700320 {
321 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 {
323 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700324 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700325 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700326
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 return( fConnectedInfra );
328}
329#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700330
Jeff Johnson295189b2012-06-20 16:38:30 -0700331static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
332{
333 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700334
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700336
337 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 {
339 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
340 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700341
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 return( fConnected );
343}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700344
Jeff Johnson295189b2012-06-20 16:38:30 -0700345inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
346{
347 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700348
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700350
351 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 {
353 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
354 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700355
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 return( fConnected );
357}
358
359static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
360{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700361 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700362 {
363 case eCSR_BSS_TYPE_INFRASTRUCTURE:
364 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
365 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700366
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 case eCSR_BSS_TYPE_IBSS:
368 case eCSR_BSS_TYPE_START_IBSS:
369 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
370 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700371
372 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700374 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 default:
376 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700377 break;
378 }
379
Jeff Johnson295189b2012-06-20 16:38:30 -0700380}
381
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530382/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530383 * hdd_copy_ht_caps()- Populate kernel HT caps structure object
384 * @hdd_ht_cap: HT capabilities of kernel type
385 * @roam_ht_cap: HT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530386 *
387 * Return: None
388 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530389void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
390 tDot11fIEHTCaps *roam_ht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530391{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530392 uint32_t i, temp_ht_cap;
393
394 vos_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
395
396 if (roam_ht_cap->advCodingCap)
397 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
398 if (roam_ht_cap->supportedChannelWidthSet)
399 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
400 temp_ht_cap = roam_ht_cap->mimoPowerSave &
401 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
402 if (temp_ht_cap)
403 hdd_ht_cap->cap_info |=
404 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
405 if (roam_ht_cap->greenField)
406 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
407 if (roam_ht_cap->shortGI20MHz)
408 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
409 if (roam_ht_cap->shortGI40MHz)
410 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
411 if (roam_ht_cap->txSTBC)
412 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
413 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
414 IEEE80211_HT_CAP_RX_STBC_SHIFT);
415 if (temp_ht_cap)
416 hdd_ht_cap->cap_info |=
417 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
418 if (roam_ht_cap->delayedBA)
419 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
420 if (roam_ht_cap->maximalAMSDUsize)
421 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
422 if (roam_ht_cap->dsssCckMode40MHz)
423 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
424 if (roam_ht_cap->psmp)
425 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
426 if (roam_ht_cap->stbcControlFrame)
427 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
428 if (roam_ht_cap->lsigTXOPProtection)
429 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
430
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530431 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
432 if (roam_ht_cap->maxRxAMPDUFactor)
433 hdd_ht_cap->ampdu_params_info |=
434 IEEE80211_HT_AMPDU_PARM_FACTOR;
435 temp_ht_cap = roam_ht_cap->mpduDensity &
436 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
437 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
438 if (temp_ht_cap)
439 hdd_ht_cap->ampdu_params_info |=
440 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
441
442 /* 802.11n HT extended capabilities masks */
443 if (roam_ht_cap->pco)
444 hdd_ht_cap->extended_ht_cap_info |=
445 IEEE80211_HT_EXT_CAP_PCO;
446 temp_ht_cap = roam_ht_cap->transitionTime &
447 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
448 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
449 if (temp_ht_cap)
450 hdd_ht_cap->extended_ht_cap_info |=
451 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
452 temp_ht_cap = roam_ht_cap->mcsFeedback &
453 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
454 if (temp_ht_cap)
455 hdd_ht_cap->extended_ht_cap_info |=
456 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
457
458 /* tx_bf_cap_info capabilities */
459 if (roam_ht_cap->txBF)
460 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
461 if (roam_ht_cap->rxStaggeredSounding)
462 hdd_ht_cap->tx_BF_cap_info |=
463 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
464 if (roam_ht_cap->txStaggeredSounding)
465 hdd_ht_cap->tx_BF_cap_info |=
466 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
467 if (roam_ht_cap->rxZLF)
468 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
469 if (roam_ht_cap->txZLF)
470 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
471 if (roam_ht_cap->implicitTxBF)
472 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
473 temp_ht_cap = roam_ht_cap->calibration &
474 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
475 if (temp_ht_cap)
476 hdd_ht_cap->tx_BF_cap_info |=
477 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
478 if (roam_ht_cap->explicitCSITxBF)
479 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
480 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
481 hdd_ht_cap->tx_BF_cap_info |=
482 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
483 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
484 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
485 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
486 if (temp_ht_cap)
487 hdd_ht_cap->tx_BF_cap_info |=
488 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
489 temp_ht_cap =
490 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
491 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
492 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
493 if (temp_ht_cap)
494 hdd_ht_cap->tx_BF_cap_info |=
495 temp_ht_cap <<
496 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
497 temp_ht_cap =
498 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
499 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
500 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
501 if (temp_ht_cap)
502 hdd_ht_cap->tx_BF_cap_info |=
503 temp_ht_cap <<
504 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
505 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
506 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
507 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
508 if (temp_ht_cap)
509 hdd_ht_cap->tx_BF_cap_info |=
510 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
511 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
512 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
513 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
514 if (temp_ht_cap)
515 hdd_ht_cap->tx_BF_cap_info |=
516 temp_ht_cap <<
517 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
518 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
519 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
520 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
521 if (temp_ht_cap)
522 hdd_ht_cap->tx_BF_cap_info |=
523 temp_ht_cap <<
524 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
525
526 /* antenna selection */
527 if (roam_ht_cap->antennaSelection)
528 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
529 if (roam_ht_cap->explicitCSIFeedbackTx)
530 hdd_ht_cap->antenna_selection_info |=
531 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
532 if (roam_ht_cap->antennaIndicesFeedbackTx)
533 hdd_ht_cap->antenna_selection_info |=
534 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
535 if (roam_ht_cap->explicitCSIFeedback)
536 hdd_ht_cap->antenna_selection_info |=
537 ANTENNA_SEL_INFO_EXP_CSI_FB;
538 if (roam_ht_cap->antennaIndicesFeedback)
539 hdd_ht_cap->antenna_selection_info |=
540 ANTENNA_SEL_INFO_ANT_ID_FB;
541 if (roam_ht_cap->rxAS)
542 hdd_ht_cap->antenna_selection_info |=
543 ANTENNA_SEL_INFO_RX_AS;
544 if (roam_ht_cap->txSoundingPPDUs)
545 hdd_ht_cap->antenna_selection_info |=
546 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
547
548 /* mcs data rate */
549 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
550 hdd_ht_cap->mcs.rx_mask[i] =
551 roam_ht_cap->supportedMCSSet[i];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530552
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530553 hdd_ht_cap->mcs.rx_highest =
554 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
555 ((short) (roam_ht_cap->supportedMCSSet[10]));
556 hdd_ht_cap->mcs.tx_params =
557 roam_ht_cap->supportedMCSSet[12];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530558
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530559}
560
561
562#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
563#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
564#define VHT_CAP_RXSTBC_MASK_SHIFT 8
565#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
566#define VHT_CAP_BEAMFORMEE_STS_MASK \
567 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
568#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
569#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
570 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
571#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
572#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
573 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
574#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
575
576/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530577 * hdd_copy_vht_caps()- Populate kernel VHT caps structure object
578 * @hdd_ht_cap: VHT capabilities of kernel type
579 * @roam_ht_cap: VHT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530580 *
581 * Return: None
582 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530583void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
584 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530585{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530586 uint32_t temp_vht_cap;
587
588 vos_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
589
590 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
591 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
592 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
593 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
594 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
595 if (temp_vht_cap)
596 if (roam_vht_cap->supportedChannelWidthSet &
597 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
598 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
599 hdd_vht_cap->vht_cap_info |=
600 temp_vht_cap <<
601 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
602 if (roam_vht_cap->supportedChannelWidthSet &
603 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
604 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
605 hdd_vht_cap->vht_cap_info |=
606 temp_vht_cap <<
607 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
608 if (roam_vht_cap->ldpcCodingCap)
609 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
610 if (roam_vht_cap->shortGI80MHz)
611 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
612 if (roam_vht_cap->shortGI160and80plus80MHz)
613 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
614 if (roam_vht_cap->txSTBC)
615 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
616 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
617 VHT_CAP_RXSTBC_MASK_SHIFT);
618 if (temp_vht_cap)
619 hdd_vht_cap->vht_cap_info |=
620 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
621 if (roam_vht_cap->suBeamFormerCap)
622 hdd_vht_cap->vht_cap_info |=
623 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
624 if (roam_vht_cap->suBeamformeeCap)
625 hdd_vht_cap->vht_cap_info |=
626 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
627 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
628 (VHT_CAP_BEAMFORMEE_STS_MASK);
629 if (temp_vht_cap)
630 hdd_vht_cap->vht_cap_info |=
631 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
632 temp_vht_cap = roam_vht_cap->numSoundingDim &
633 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
634 if (temp_vht_cap)
635 hdd_vht_cap->vht_cap_info |=
636 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
637 if (roam_vht_cap->muBeamformerCap)
638 hdd_vht_cap->vht_cap_info |=
639 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
640 if (roam_vht_cap->muBeamformeeCap)
641 hdd_vht_cap->vht_cap_info |=
642 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
643 if (roam_vht_cap->vhtTXOPPS)
644 hdd_vht_cap->vht_cap_info |=
645 IEEE80211_VHT_CAP_VHT_TXOP_PS;
646 if (roam_vht_cap->htcVHTCap)
647 hdd_vht_cap->vht_cap_info |=
648 IEEE80211_VHT_CAP_HTC_VHT;
649 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
650 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
651 if (temp_vht_cap)
652 hdd_vht_cap->vht_cap_info |=
653 temp_vht_cap <<
654 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
655 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
656 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
657 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
658 if (temp_vht_cap)
659 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
660 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
661 if (roam_vht_cap->rxAntPattern)
662 hdd_vht_cap->vht_cap_info |=
663 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
664 if (roam_vht_cap->txAntPattern)
665 hdd_vht_cap->vht_cap_info |=
666 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
667 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
668 hdd_vht_cap->supp_mcs.rx_highest =
669 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
670 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
671 hdd_vht_cap->supp_mcs.tx_highest =
672 ((uint16_t)roam_vht_cap->txSupDataRate);
673}
674
675/* ht param */
676#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
677#define HT_PARAM_SERVICE_INT_GRAN 0xe0
678#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
679
680/* operatinon mode */
681#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
682
683/* stbc_param */
684#define HT_STBC_PARAM_MCS 0x007f
685
686/**
687 * hdd_copy_ht_operation()- copy HT operation element from roam info to
688 * hdd station context.
689 * @hdd_sta_ctx: pointer to hdd station context
690 * @roam_info: pointer to roam info
691 *
692 * Return: None
693 */
694static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
695 tCsrRoamInfo *roam_info)
696{
697 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
698 struct ieee80211_ht_operation *hdd_ht_ops =
699 &hdd_sta_ctx->conn_info.ht_operation;
700 uint32_t i, temp_ht_ops;
701
702 vos_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
703
704 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
705
706 /* HT_PARAMS */
707 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
708 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
709 if (temp_ht_ops)
710 hdd_ht_ops->ht_param |= temp_ht_ops;
711 else
712 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
713 if (roam_ht_ops->recommendedTxWidthSet)
714 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
715 if (roam_ht_ops->rifsMode)
716 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
717 if (roam_ht_ops->controlledAccessOnly)
718 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
719 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
720 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
721 if (temp_ht_ops)
722 hdd_ht_ops->ht_param |= temp_ht_ops <<
723 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
724
725 /* operation mode */
726 temp_ht_ops = roam_ht_ops->opMode &
727 IEEE80211_HT_OP_MODE_PROTECTION;
728 switch (temp_ht_ops) {
729 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
730 hdd_ht_ops->operation_mode |=
731 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
732 break;
733 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
734 hdd_ht_ops->operation_mode |=
735 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
736 break;
737 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
738 hdd_ht_ops->operation_mode |=
739 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
740 break;
741 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
742 default:
743 hdd_ht_ops->operation_mode |=
744 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
745 }
746 if (roam_ht_ops->nonGFDevicesPresent)
747 hdd_ht_ops->operation_mode |=
748 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
749 if (roam_ht_ops->transmitBurstLimit)
750 hdd_ht_ops->operation_mode |=
751 HT_OP_MODE_TX_BURST_LIMIT;
752 if (roam_ht_ops->obssNonHTStaPresent)
753 hdd_ht_ops->operation_mode |=
754 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
755
756 /* stbc_param */
757 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
758 HT_STBC_PARAM_MCS;
759 if (temp_ht_ops)
760 hdd_ht_ops->stbc_param |= temp_ht_ops;
761 if (roam_ht_ops->dualCTSProtection)
762 hdd_ht_ops->stbc_param |=
763 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
764 if (roam_ht_ops->secondaryBeacon)
765 hdd_ht_ops->stbc_param |=
766 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
767 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
768 hdd_ht_ops->stbc_param |=
769 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
770 if (roam_ht_ops->pcoActive)
771 hdd_ht_ops->stbc_param |=
772 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
773 if (roam_ht_ops->pcoPhase)
774 hdd_ht_ops->stbc_param |=
775 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
776
777 /* basic MCs set */
778 for (i = 0; i < 16; ++i)
779 hdd_ht_ops->basic_set[i] =
780 roam_ht_ops->basicMCSSet[i];
781}
782
783/**
784 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
785 * hdd station context.
786 * @hdd_sta_ctx: pointer to hdd station context
787 * @roam_info: pointer to roam info
788 *
789 * Return: None
790 */
791static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
792 tCsrRoamInfo *roam_info)
793{
794 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
795 struct ieee80211_vht_operation *hdd_vht_ops =
796 &hdd_sta_ctx->conn_info.vht_operation;
797
798 vos_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
799
800 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
801 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
802 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
803 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
804}
805
806
807/**
808 * hdd_save_bss_info() - save connection info in hdd sta ctx
809 * @adapter: Pointer to adapter
810 * @roam_info: pointer to roam info
811 *
812 * Return: None
813 */
814static void hdd_save_bss_info(hdd_adapter_t *adapter,
815 tCsrRoamInfo *roam_info)
816{
817 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
818
819 hdd_sta_ctx->conn_info.freq = vos_chan_to_freq(
820 hdd_sta_ctx->conn_info.operationChannel);
821 if (roam_info->vht_caps.present) {
822 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530823 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
824 &roam_info->vht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530825 } else {
826 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
827 }
828 if (roam_info->ht_caps.present) {
829 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530830 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps, &roam_info->ht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530831 } else {
832 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
833 }
834 if (roam_info->reassoc)
835 hdd_sta_ctx->conn_info.roam_count++;
836 if (roam_info->hs20vendor_ie.present) {
837 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
838 vos_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
839 &roam_info->hs20vendor_ie,
840 sizeof(roam_info->hs20vendor_ie));
841 } else {
842 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
843 }
844 if (roam_info->ht_operation.present) {
845 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
846 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
847 } else {
848 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
849 }
850 if (roam_info->vht_operation.present) {
851 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
852 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
853 } else {
854 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
855 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +0530856 /* Cache last connection info */
857 vos_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
858 sizeof(connection_info_t));
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530859}
860
Jeff Johnson295189b2012-06-20 16:38:30 -0700861void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
862{
863 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
864 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700867
868 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700870 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
872 {
873 VOS_ASSERT( pRoamInfo->pBssDesc );
874 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
875
876 // Save the Station ID for this station from the 'Roam Info'.
877 //For IBSS mode, staId is assigned in NEW_PEER_IND
878 //For reassoc, the staID doesn't change and it may be invalid in this structure
879 //so no change here.
880 if( !pRoamInfo->fReassocReq )
881 {
882 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
883 }
884 }
885 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700886 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700888 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 else
890 {
891 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
892 // or we can't function.
893 VOS_ASSERT( 0 );
894 }
895
896 // notify WMM
897 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
898
899 if( !pRoamInfo->u.pConnectedProfile )
900 {
901 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
902 }
903 else
904 {
905 // Get Multicast Encryption Type
906 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
907 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
908 // Get Unicast Encrytion Type
909 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
910 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
911
912 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
913
914 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
915
916 // Save the ssid for the connection
917 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530918
919 // Save dot11mode in which STA associated to AP
920 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530921
922 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 }
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530924 hdd_save_bss_info(pAdapter, pRoamInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700925 }
926
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700928 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
929
Jeff Johnson295189b2012-06-20 16:38:30 -0700930}
931
932#if defined(WLAN_FEATURE_VOWIFI_11R)
933/*
934 * Send the 11R key information to the supplicant.
935 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800936 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 * for the same purpose.)
938 *
939 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
940 * this contains the R1KHID, R0KHID and the MDID.
941 * For FT, this consists of the Reassoc Rsp FTIEs.
942 * This is the Assoc Response.
943 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700944static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 tCsrRoamInfo *pCsrRoamInfo)
946{
947 union iwreq_data wrqu;
948 char *buff;
949 unsigned int len = 0;
950 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700951
952 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 {
954 hddLog(LOGE,
955 "%s: pCsrRoamInfo->nAssocRspLength=%d",
956 __func__, (int)pCsrRoamInfo->nAssocRspLength);
957 return;
958 }
959
Shailender Karmuchia734f332013-04-19 14:02:48 -0700960 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700962 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700964 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 return;
966 }
967
968 // pFTAssocRsp needs to point to the IEs
969 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
970 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
971 (unsigned int)pFTAssocRsp[0],
972 (unsigned int)pFTAssocRsp[1]);
973
974 // We need to send the IEs to the supplicant.
975 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700976 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700978 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 return;
980 }
981
982 // Send the Assoc Resp, the supplicant needs this for initial Auth.
983 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700984 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700986 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
988
989 kfree(buff);
990}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700991#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700992
993#ifdef WLAN_FEATURE_VOWIFI_11R
994
995/*---------------------------------------------------
996 *
997 * Send the FTIEs, RIC IEs during FT. This is eventually
998 * used to send the FT events to the supplicant
999 *
1000 * At the reception of Auth2 we send the RIC followed
1001 * by the auth response IEs to the supplicant.
1002 * Once both are received in the supplicant, an FT
1003 * event is generated to the supplicant.
1004 *
1005 *---------------------------------------------------
1006 */
1007void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
1008{
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 tANI_U16 auth_resp_len = 0;
1010 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1012
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05301013#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001014 struct cfg80211_ft_event_params ftEvent;
1015 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1016 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
1017 struct net_device *dev = pAdapter->dev;
1018#else
1019 char *buff;
1020 union iwreq_data wrqu;
1021 tANI_U16 str_len;
1022#endif
1023
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05301024#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301025 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1026 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001027
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +05301028 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
1029 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301030 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001031 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301032 hddLog(LOGW,
1033 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1034 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001035 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001036
1037 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301038 ftEvent.ric_ies_len = ric_ies_length;
1039 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001040
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301041 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001042 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001043
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301044 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001045 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301046 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001047 return;
1048 }
1049
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301050 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301051
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301052 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001053
1054 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
1055 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
1056
Jeff Johnson59a121e2013-11-30 09:46:08 -08001057 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
1058 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
1059 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301060 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001061 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
1062 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1063 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001064
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301065 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001066
1067#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301068 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301070 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301072 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 return;
1074 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301075 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
Shailender Karmuchia734f332013-04-19 14:02:48 -07001077 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301079 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001080 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301081 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301083 hddLog(LOGW,
1084 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1085 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 }
1087 else
1088 {
1089 wrqu.data.length = str_len + ric_ies_length;
1090 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1091 }
1092
1093 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301094 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301096 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
1097 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001098
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301099 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301101 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +05301102 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 return;
1104 }
1105
1106 wrqu.data.length = str_len + auth_resp_len;
1107 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1108
1109 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001111}
1112
1113#endif /* WLAN_FEATURE_VOWIFI_11R */
1114
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001115#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001116
1117/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001118 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 * (This keeps the supplicant "up to date" on the current channel.)
1120 *
1121 * The current (new AP) channel information is passed in.
1122 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001123static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 tCsrRoamInfo *pCsrRoamInfo)
1125{
1126 union iwreq_data wrqu;
1127 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001128
Shailender Karmuchia734f332013-04-19 14:02:48 -07001129
1130 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 {
1132 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001133 "%s: pCsrRoamInfo->pBssDesc=%pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 __func__, descriptor);
1135 return;
1136 }
1137
1138 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -08001139 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 memset(&wrqu, '\0', sizeof(wrqu));
1141 wrqu.freq.m = descriptor->channelId;
1142 wrqu.freq.e = 0;
1143 wrqu.freq.i = 0;
1144 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1145}
1146
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001147#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001148
1149void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
1150{
1151 union iwreq_data wrqu;
1152 u8 *pBeaconIes;
1153 u8 currentLen = 0;
1154 char *buff;
1155 int totalIeLen = 0, currentOffset = 0, strLen;
1156
1157 memset(&wrqu, '\0', sizeof(wrqu));
1158
1159 if (0 == pCsrRoamInfo->nBeaconLength)
1160 {
1161 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
1162 return;
1163 }
1164 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001165 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001167 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 return;
1169 }
1170
1171 // pBeaconIes needs to point to the IEs
1172 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
1173 (unsigned int)pBeaconIes[0],
1174 (unsigned int)pBeaconIes[1]);
1175 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001176
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 // We need to send the IEs to the supplicant.
1178 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001179 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001181 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 return;
1183 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001184 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001185
1186 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
1187 currentLen = strLen + 1;
1188
1189 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1190 do
1191 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001192 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 * max size and send it to supplicant. Changes are done in supplicant to handle this */
1194 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
1195 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
1196 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
1197 currentOffset += currentLen;
1198 totalIeLen -= currentLen;
1199 wrqu.data.length = strLen + 1 + currentLen;
1200 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -07001201 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 else
1203 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
1204
1205 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
1206 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1207 } while (totalIeLen > 0);
1208
1209 kfree(buff);
1210}
1211
1212static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
1213{
1214 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1215 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1216 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1217 union iwreq_data wrqu;
1218 int we_event;
1219 char *msg;
1220 int type = -1;
1221
Shailender Karmuchia734f332013-04-19 14:02:48 -07001222#if defined (WLAN_FEATURE_VOWIFI_11R)
1223 // Added to find the auth type on the fly at run time
1224 // rather than with cfg to see if FT is enabled
1225 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
1227#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001228
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001230 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001232
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
1234 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301235 /* In case of roaming ; We are not doing disconnect.
1236 * If disconnect is not being done for roam; We will not
1237 * decrease count for Active sessions. We should not increase active
1238 * active session in case of roaming.
1239 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +05301240 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +05301241 {
1242 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
1243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
1245 type = WLAN_STA_ASSOC_DONE_IND;
1246
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001247#ifdef WLAN_FEATURE_P2P_DEBUG
1248 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1249 {
1250 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
1251 {
1252 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
1253 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1254 "Connecting state to Connected State for 8-way "
1255 "Handshake");
1256 }
1257 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
1258 {
1259 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
1260 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1261 "Connecting state to P2P Client Connection Completed");
1262 }
1263 }
1264#endif
Yeshwanth Sriram Guntuka0004c0b2017-12-06 14:43:49 +05301265 hddLog(VOS_TRACE_LEVEL_ERROR, MAC_ADDRESS_STR " connected to "
1266 MAC_ADDRESS_STR,
1267 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1268 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
1270
Bhargav Shahd0715912015-10-01 18:17:37 +05301271 hdd_manage_delack_timer(pHddCtx);
1272
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
1274 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
1275 * and fFTEnable is TRUE */
1276#ifdef WLAN_FEATURE_VOWIFI_11R
1277 // Send FT Keys to the supplicant when FT is enabled
1278 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -07001279 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001280#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1282 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
1283#endif
1284 )
1285 {
1286 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
1287 }
1288#endif
1289 }
1290 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
1291 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301292 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -07001293 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301295
1296 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1297 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
1298 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 }
1300 else /* Not Associated */
1301 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301302 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1303 "wlan: disconnected");
gaurank kathpalia51801582019-04-05 13:56:55 +05301304 if (pHddCtx->btCoexModeSet) {
1305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1306 FL("Wlan disconnected, sending DHCP stop indication"));
1307 pHddCtx->btCoexModeSet = FALSE;
1308 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
1309 pAdapter->sessionId);
1310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 type = WLAN_STA_DISASSOC_DONE_IND;
1312 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +05301313
1314 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001316 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001317
1318 msg = NULL;
1319 /*During the WLAN uninitialization,supplicant is stopped before the
1320 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301321 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 {
1323 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001324#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001326 {
1327 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1328 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
1330 }
1331#endif
1332 }
1333 send_btc_nlink_msg(type, 0);
1334}
1335
1336void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
1337{
1338 // Remove staId, bssId and peerMacAddress
1339 pHddStaCtx->conn_info.staId [ 0 ] = 0;
1340 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
1341 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
1342
1343 // Clear all security settings
1344 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1345 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1346 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1347
1348 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -07001349 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001350
1351 // Set not-connected state
1352 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -07001353
1354 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
1355}
Katya Nigam47528772015-02-11 12:24:49 +05301356
1357VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
1358{
Katya Nigam1fd24402015-02-16 14:52:19 +05301359 v_U8_t ac;
1360 /**Track whether OS TX queue has been disabled.*/
1361 v_BOOL_t txSuspended[NUM_TX_QUEUES];
1362 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +05301363 v_U8_t i;
1364 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1365 hdd_ibss_peer_info_t *pPeerInfo;
1366
1367 if( NULL == pHddStaCtx )
1368 {
1369 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1370 "%s: HDD station context NULL ",__func__);
1371 return VOS_STATUS_E_FAILURE;
1372 }
Katya Nigam1fd24402015-02-16 14:52:19 +05301373
Katya Nigam47528772015-02-11 12:24:49 +05301374 pPeerInfo = &pHddStaCtx->ibss_peer_info;
1375 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
1376 {
1377 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1378 "%s: Deinit station not inited %d", __func__, STAId );
1379 return VOS_STATUS_E_FAILURE;
1380 }
1381
1382 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +05301383
1384 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1385 {
1386 tlAC = hdd_QdiscAcToTlAC[ac];
1387 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
1388 }
1389
Katya Nigam47528772015-02-11 12:24:49 +05301390 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1391
Katya Nigam1fd24402015-02-16 14:52:19 +05301392 /* re-init hdd list, since netdev can still open adapter until
1393 * driver gets unloaded
1394 */
1395 for (i = 0; i < NUM_TX_QUEUES; i ++)
1396 {
1397 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
1398 HDD_TX_QUEUE_MAX_LEN);
1399 }
1400
1401 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1402 {
1403 if (txSuspended[ac])
1404 {
1405 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1406 "%s: TX queue re-enabled", __func__);
1407 netif_wake_subqueue(pAdapter->dev, ac);
1408 }
1409 }
Katya Nigam47528772015-02-11 12:24:49 +05301410 return VOS_STATUS_SUCCESS;
1411}
1412
1413static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1414{
1415 VOS_STATUS vosStatus;
1416
1417 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1418 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1419 {
1420 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1421 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1422 "Status= %d [0x%08X]",
1423 __func__, staId, vosStatus, vosStatus );
1424 }
1425
1426 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
1427 if( VOS_STATUS_E_FAILURE == vosStatus )
1428 {
1429 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1430 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
1431 "Status = %d [0x%08X]",
1432 staId, vosStatus, vosStatus );
1433 }
1434
1435 return( vosStatus );
1436}
1437
1438VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
1439{
1440 v_U8_t i = 0;
1441 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1442 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1443
1444 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
1445 {
1446 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1447 "%s: Reinit station %d", __func__, STAId );
1448 return VOS_STATUS_E_FAILURE;
1449 }
1450
1451 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1452 for (i = 0; i < NUM_TX_QUEUES; i ++)
1453 {
1454 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
1455 }
1456
1457 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
1458 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
1459 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
1460
1461 return VOS_STATUS_SUCCESS;
1462}
1463
1464static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
1465 tCsrRoamInfo *pRoamInfo,
1466 v_U8_t staId,
1467 v_MACADDR_t *pPeerMacAddress,
1468 tSirBssDescription *pBssDesc )
1469{
1470 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1471 WLAN_STADescType staDesc = {0};
1472 eCsrEncryptionType connectedCipherAlgo;
1473 v_BOOL_t fConnected;
1474 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1475 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1476 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1477
1478 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
1479 {
1480 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1481 "clean up old entry for STA %d", staId);
1482 hdd_ibss_DeregisterSTA( pAdapter, staId );
1483 }
1484
1485 staDesc.ucSTAId = staId;
1486 staDesc.wSTAType = WLAN_STA_IBSS;
1487
1488 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1489 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1490 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1491 // pass when making an Infrastructure connection.
1492 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
1493 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
1494 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1495
1496 if (hdd_wmm_is_active(pAdapter))
1497 {
1498 staDesc.ucQosEnabled = 1;
1499 }
1500 else
1501 {
1502 staDesc.ucQosEnabled = 0;
1503 }
1504 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1505 "HDD SOFTAP register TL QoS_enabled=%d",
1506 staDesc.ucQosEnabled );
1507
1508 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1509 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1510 {
1511 staDesc.ucProtectedFrame = 1;
1512 }
1513 else
1514 {
1515 staDesc.ucProtectedFrame = 0;
1516
1517 }
1518
1519 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
1520
1521 // UMA is Not ready yet, Xlation will be done by TL
1522 staDesc.ucSwFrameTXXlation = 1;
1523 staDesc.ucSwFrameRXXlation = 1;
1524 staDesc.ucAddRmvLLC = 1;
1525 // Initialize signatures and state
1526 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1527 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1528 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
1529
1530 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1531
1532 // Register the Station with TL.
1533 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1534 hdd_rx_packet_cbk,
1535 hdd_tx_complete_cbk,
1536 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
1537 pBssDesc->rssi );
1538 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1539 {
1540 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1541 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
1542 vosStatus, vosStatus );
1543 return vosStatus;
1544 }
1545
1546 //Timer value should be in milliseconds
1547 if ( pHddCtx->cfg_ini->dynSplitscan &&
1548 ( VOS_TIMER_STATE_RUNNING !=
1549 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1550 {
1551 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1552 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
1553 }
1554
1555 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
1556 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
1557
1558 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
1559 WLANTL_STA_AUTHENTICATED );
1560
1561 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
1562 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1563
1564 return( vosStatus );
1565}
1566
Jeff Johnson295189b2012-06-20 16:38:30 -07001567/* TODO Revist this function. and data path */
1568static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1569{
1570 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -07001571
Katya Nigam47528772015-02-11 12:24:49 +05301572 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -07001573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1575 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1576 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05301577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001579 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001580 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 }
1582 return( vosStatus );
1583}
1584
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301585/**
1586 * hdd_print_bss_info() - print bss info
1587 * @hdd_sta_ctx: pointer to hdd station context
1588 *
1589 * Return: None
1590 */
1591void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
1592{
1593 uint32_t *cap_info;
1594
1595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"WIFI DATA LOGGER");
1596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"channel: %d",
1597 hdd_sta_ctx->conn_info.freq);
1598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"dot11mode: %d",
1599 hdd_sta_ctx->conn_info.dot11Mode);
1600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"AKM: %d",
1601 hdd_sta_ctx->conn_info.authType);
1602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ssid: %.*s",
1603 hdd_sta_ctx->conn_info.SSID.SSID.length,
1604 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"roam count: %d",
1606 hdd_sta_ctx->conn_info.roam_count);
1607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ant_info: %d",
1608 hdd_sta_ctx->conn_info.txrate.nss);
1609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate legacy %d",
1610 hdd_sta_ctx->conn_info.txrate.legacy);
1611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate mcs: %d",
1612 hdd_sta_ctx->conn_info.txrate.mcs);
1613 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1614 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ht caps: %x",
1616 *cap_info);
1617 }
1618 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1619 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"vht caps: %x",
1621 *cap_info);
1622 }
1623 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"hs20 info: %x",
1625 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"signal: %d",
1627 hdd_sta_ctx->conn_info.signal);
1628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"noise: %d",
1629 hdd_sta_ctx->conn_info.noise);
1630}
1631
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301632/**
1633 * hdd_check_and_move_if_sap_is_on_dfs_chan() - move the sap to non dfs channel
1634 * @hdd_ctx: pointer to hdd context
1635 * @sta_adapter: pointer to sta adapater
1636 *
1637 * This function is used to check if SAP is operating on DFS channel in stand
1638 * alone mode and move it to non dfs channel
1639 *
1640 * Return: void.
1641 */
1642static void hdd_check_and_move_if_sap_is_on_dfs_chan(hdd_context_t *hdd_ctx,
1643 hdd_adapter_t *sta_adapter)
1644{
1645 hdd_adapter_t *sap_adapter;
1646 ptSapContext sap_ctx;
1647 v_CONTEXT_t vos_ctx;
1648 eNVChannelEnabledType chan_state;
1649
1650 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_ctx)) {
1651 sap_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_SOFTAP);
1652
1653 if (!sap_adapter) {
1654 hddLog(LOG1, FL("SAP not exists, nothing to do"));
1655 return;
1656 }
1657
1658 vos_ctx = hdd_ctx->pvosContext;
1659 if (!vos_ctx) {
1660 hddLog(LOGE, FL("vos_ctx is NULL"));
1661 return;
1662 }
1663 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
1664 if (!sap_ctx) {
1665 hddLog(LOG1, FL("sap_ctx not exists"));
1666 return;
1667 }
1668
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301669 if (sap_ctx->sapsMachine != eSAP_STARTED) {
1670 hddLog(LOG1, FL("SAP is not in eSAP_STARTED state"));
1671 return;
1672 }
1673
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301674 chan_state = vos_nv_getChannelEnabledState(sap_ctx->channel);
1675
1676 hddLog(LOG1, "SAP is operating on channel (%hu), chan_state %d",
1677 sap_ctx->channel, chan_state);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301678 if (vos_nv_getChannelEnabledState(sap_ctx->channel) !=
1679 NV_CHANNEL_DFS) {
1680 hddLog(LOG1, "SAP is on non DFS channel. nothing to do");
1681 return;
1682 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301683
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301684 hddLog(LOG1, "Schedule workqueue to move the SAP to non DFS channel");
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301685 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
1686 msecs_to_jiffies(ECSA_DFS_CHAN_CHANGE_DEFER_TIME));
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301687 }
1688}
Jeff Johnson295189b2012-06-20 16:38:30 -07001689
1690static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1691 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1692 eCsrRoamResult roamResult )
1693{
1694 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07001695 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 struct net_device *dev = pAdapter->dev;
1697 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1698 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -07001699 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301700 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001701
1702 // Sanity check
1703 if(dev == NULL)
1704 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301705 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001706 "%s: net_dev is released return", __func__);
1707 return eHAL_STATUS_FAILURE;
1708 }
1709
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301711 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 netif_tx_disable(dev);
1713 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301714 //TxTimeoutCount need to reset in case of disconnect handler
1715 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001716
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301717 wlan_hdd_check_and_stop_mon(pAdapter, false);
1718
Jeff Johnsone7245742012-09-05 17:12:55 -07001719 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301720 /* If only STA mode is on */
1721 if((pHddCtx->concurrency_mode <= 1) &&
1722 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1723 {
1724 pHddCtx->isAmpAllowed = VOS_TRUE;
1725 }
1726
Agarwal Ashish47d18112014-08-04 19:55:07 +05301727 /* Need to apply spin lock before decreasing active sessions
1728 * as there can be chance for double decrement if context switch
1729 * Calls wlan_hdd_disconnect.
1730 */
1731
1732 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301733
1734 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301735 * to kernel. Sending disconnected event to kernel for userspace
1736 * initiated disconnect will be handled by diconnect handler call
1737 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301738 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301739 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301740 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) ||
1741 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301742 {
1743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1744 FL(" HDD has initiated a disconnect, no need to send"
1745 " disconnect indication to kernel"));
1746 sendDisconInd = FALSE;
1747 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301748 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301751 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301752 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301753 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1754 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301756 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh78c691f2017-11-30 13:48:44 +05301757 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001759
1760 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001761
1762 // indicate 'disconnect' status to wpa_supplicant...
1763 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 /* indicate disconnected event to nl80211 */
1765 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1766 {
1767 /*During the WLAN uninitialization,supplicant is stopped before the
1768 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301769 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301771 if (sendDisconInd)
1772 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1773 "%s: sent disconnected event to nl80211",
1774 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001775#ifdef WLAN_FEATURE_P2P_DEBUG
1776 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1777 {
1778 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1779 {
1780 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1781 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1782 "and moved to disconnected state");
1783 }
1784 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1785 {
1786 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1787 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1788 "and moved to inactive state");
1789 }
1790 }
1791#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301792 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1793 !pRoamInfo->reasonCode)
1794 wlan_hdd_get_frame_logs(pAdapter,
1795 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301796 /*Only send indication to kernel if not initiated by kernel*/
1797 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301799 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1800 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1801 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301802 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1803 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301804 }
1805 else
1806 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301807 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301808 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301811
1812 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1813 {
1814 hddLog(LOG1,
1815 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1816 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301817 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301818
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 //If the Device Mode is Station
1820 // and the P2P Client is Connected
1821 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001822
1823 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001824 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001825 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 {
1827 //Enable BMPS only of other Session is P2P Client
1828 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001829 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001830
1831 if (NULL != pVosContext)
1832 {
1833 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1834
1835 if(NULL != pHddCtx)
1836 {
1837 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301838 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1839 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301841 if (pHddCtx->hdd_wlan_suspended)
1842 {
1843 hdd_set_pwrparams(pHddCtx);
1844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 }
1848 }
1849 }
1850 }
1851 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001852
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301853 hdd_wmm_adapter_clear(pAdapter);
Kapil Guptae6867482016-06-26 13:31:37 +05301854 /* Clear PER based roam stats */
1855#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1856 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1857 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1858 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1859 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1860 sme_unset_per_roam_rxconfig(pHddCtx->hHal);
1861#endif
Mukul Sharmac159c432014-01-15 15:42:46 +05301862#if defined(WLAN_FEATURE_VOWIFI_11R)
1863 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1864#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301865
1866 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1867 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301868 v_U8_t i;
1869
Katya Nigam63ce1772014-09-26 15:53:49 +05301870 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301871 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301872 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1873 {
1874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301875 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1876 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301877 sta_id, status, status );
1878
1879 status = eHAL_STATUS_FAILURE;
1880 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301881 pHddCtx->sta_to_adapter[sta_id] = NULL;
1882
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301883 /*Clear all the peer sta register with TL.*/
1884 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1885 {
1886 if (0 != pHddStaCtx->conn_info.staId[i])
1887 {
1888 sta_id = pHddStaCtx->conn_info.staId[i];
1889
1890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1891 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301892 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301893 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1894 {
1895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1896 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1897 "Status= %d [0x%x]"),
1898 sta_id, status, status );
1899 status = eHAL_STATUS_FAILURE;
1900 }
1901
Nirav Shah7e3c8132015-06-22 23:51:42 +05301902 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1903 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1904 if (vstatus != VOS_STATUS_SUCCESS) {
1905 hddLog(VOS_TRACE_LEVEL_ERROR,
1906 FL("Not able to remove staid hash %d"),
1907 sta_id);
1908 status = eHAL_STATUS_FAILURE;
1909 } else {
1910 hddLog(VOS_TRACE_LEVEL_INFO,
1911 FL("ibss station removed sta_id %d mac:"
1912 MAC_ADDRESS_STR), sta_id,
1913 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1914 }
1915
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301916 /*set the staid and peer mac as 0, all other reset are
1917 * done in hdd_connRemoveConnectInfo.
1918 */
1919 pHddStaCtx->conn_info.staId[i]= 0;
1920 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1921
1922 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1923 pHddCtx->sta_to_adapter[sta_id] = NULL;
1924 }
1925 }
1926
Katya Nigam63ce1772014-09-26 15:53:49 +05301927 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301928 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301930 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301931 /* clear scan cache for Link Lost */
1932 if (pRoamInfo && !pRoamInfo->reasonCode &&
1933 (eCSR_ROAM_LOSTLINK == roamStatus)) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05301934 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301935 pHddStaCtx->conn_info.bssId);
1936 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1937 pHddStaCtx->conn_info.bssId);
1938 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301939
1940 //We should clear all sta register with TL, for now, only one.
1941 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1942 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1943 {
1944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1945 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1946 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001947 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001948
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301949 status = eHAL_STATUS_FAILURE;
1950 }
1951
1952 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301954
1955#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1956 if (VOS_STATUS_SUCCESS !=
1957 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1958 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1959 {
1960 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1961 "WLANTL_ClearInterfaceStats Failed", __func__);
1962 }
1963 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1964 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1965 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1966 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1967#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Sravan Kumar Kairamf9f95122017-01-18 20:54:05 +05301968 pAdapter->dad = false;
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301969
Jeff Johnson295189b2012-06-20 16:38:30 -07001970 // Clear saved connection information in HDD
1971 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301972
1973 /*
1974 * eConnectionState_Connecting state mean that connection is in progress so
1975 * no need to set state to eConnectionState_NotConnected
1976 */
1977 if ((eConnectionState_Connecting != pHddStaCtx->conn_info.connState)) {
1978 hddLog(LOG1, FL("Set HDD connState to eConnectionState_NotConnected"));
1979 hdd_connSetConnectionState(pHddStaCtx, eConnectionState_NotConnected);
1980 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301981#ifdef WLAN_FEATURE_GTK_OFFLOAD
1982 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1983 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1984 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301985 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1986 sizeof (tSirGtkOffloadParams));
1987 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301988 }
1989#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001990
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001991#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001992 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1993 {
1994 wlan_hdd_tdls_disconnection_callback(pAdapter);
1995 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001996#endif
1997
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 //Unblock anyone waiting for disconnect to complete
1999 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302000 hdd_print_bss_info(pHddStaCtx);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302001
2002 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 return( status );
2004}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302005
2006static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
2007 v_U8_t staId)
2008{
2009 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2010 v_SINT_t i;
2011 v_SIZE_t size;
2012 VOS_STATUS status;
2013 v_BOOL_t granted = VOS_FALSE;
2014
2015 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2016 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
2017 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
2018 {
2019 //Indicate to TL that there is pending data if a queue is non empty
2020 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
2021 {
2022 size = 0;
2023 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
2024 if (size > 0)
2025 {
2026 if (i != WLANTL_AC_HIGH_PRIO)
2027 {
2028 if (VOS_FALSE ==
2029 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
2030 {
2031 hdd_wmm_acquire_access(pAdapter,
2032 (WLANTL_ACEnumType)i, &granted);
2033 pAdapter->psbChanged |= (1 << i);
2034 }
2035 else
2036 granted = VOS_TRUE;
2037 }
2038
2039 if (granted || (i == WLANTL_AC_HIGH_PRIO))
2040 {
2041 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
2042 staId, (WLANTL_ACEnumType)i);
2043 if (!VOS_IS_STATUS_SUCCESS(status))
2044 {
2045 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2046 "%s: Failure in indicating pkt to TL for QID=%d",
2047 __func__, i);
2048 }
2049 }
2050 }
2051 }
2052 }
2053}
2054
Jeff Johnson295189b2012-06-20 16:38:30 -07002055static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
2056 tCsrRoamInfo *pRoamInfo,
2057 v_U8_t staId,
2058 v_MACADDR_t *pPeerMacAddress,
2059 tSirBssDescription *pBssDesc )
2060{
2061 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2062 WLAN_STADescType staDesc = {0};
2063 eCsrEncryptionType connectedCipherAlgo;
2064 v_BOOL_t fConnected;
2065 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2066 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002067 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002068
2069 if ( NULL == pBssDesc)
2070 {
2071 return VOS_STATUS_E_FAILURE;
2072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 // Get the Station ID from the one saved during the assocation.
2074 staDesc.ucSTAId = staId;
2075
Katya Nigam47528772015-02-11 12:24:49 +05302076 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002077
Katya Nigam47528772015-02-11 12:24:49 +05302078 // grab the bssid from the connection info in the adapter structure and hand that
2079 // over to TL when registering.
2080 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
2081 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002082
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2084
2085 // set the QoS field appropriately
2086 if (hdd_wmm_is_active(pAdapter))
2087 {
2088 staDesc.ucQosEnabled = 1;
2089 }
2090 else
2091 {
2092 staDesc.ucQosEnabled = 0;
2093 }
2094
2095 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2096 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
2097 {
2098 staDesc.ucProtectedFrame = 1;
2099 }
2100 else
2101 {
2102 staDesc.ucProtectedFrame = 0;
2103
2104 }
2105
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002106#ifdef FEATURE_WLAN_ESE
2107 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
2108#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002109
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 /* check whether replay check is valid for the station or not */
2111 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
2112 {
2113 /* Encryption mode is either TKIP or AES
2114 and replay check is valid for only these
2115 two encryption modes */
2116 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2118 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
2119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 else
2121 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002122 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002124 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2126 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
2127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002128
2129#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002130 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 if (pAdapter->wapi_info.fIsWapiSta)
2132 {
2133 staDesc.ucIsWapiSta = 1;
2134 }
2135 else
2136 {
2137 staDesc.ucIsWapiSta = 0;
2138 }
2139#endif /* FEATURE_WLAN_WAPI */
2140
2141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2142 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
2143
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 // UMA is Not ready yet, Xlation will be done by TL
2145 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 staDesc.ucSwFrameRXXlation = 1;
2147 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002148 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 staDesc.ucQosEnabled );
2150 // Initialize signatures and state
2151 staDesc.ucUcastSig = pRoamInfo->ucastSig;
2152 staDesc.ucBcastSig = pRoamInfo->bcastSig;
2153 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
2154 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002155 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08002156 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 -07002157 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
2158 hdd_rx_packet_cbk,
2159 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 hdd_tx_fetch_packet_cbk, &staDesc,
2161 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002162
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2164 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002166 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002168 return vosStatus;
2169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002170
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002171 if ( cfg_param->dynSplitscan &&
2172 ( VOS_TIMER_STATE_RUNNING !=
2173 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
2174 {
2175 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2176 cfg_param->trafficMntrTmrForSplitScan);
2177 }
2178
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302179 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
2180 // then go to 'authenticated'. For all other authentication types
2181 // (those that donot require upper layer authentication) we can put
2182 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002183 if (staDesc.wSTAType != WLAN_STA_IBSS)
2184 VOS_ASSERT( fConnected );
2185
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302186 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002187 {
2188 // Connections that do not need Upper layer auth, transition TL directly
2189 // to 'Authenticated' state.
2190 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
2191 WLANTL_STA_AUTHENTICATED );
2192
2193 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302194
2195 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002196 }
2197 else
2198 {
2199 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302200 "ULA auth StaId= %d. Changing TL state to CONNECTED"
2201 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002202 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05302203 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002204 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 return( vosStatus );
2207}
2208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
2210 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
2211{
2212 unsigned int len = 0;
2213 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002214 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 tANI_U32 rspRsnLength = 0;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302216 struct cfg80211_bss* bss;
2217 tCsrRoamConnectedProfile roam_profile;
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 struct ieee80211_channel *chan;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302219 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002220
Agarwal Ashish51325b52014-06-16 16:50:49 +05302221 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002222 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07002223 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002224 }
2225
Agarwal Ashish51325b52014-06-16 16:50:49 +05302226 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002227 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
2228 goto done;
2229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002230
Agarwal Ashish51325b52014-06-16 16:50:49 +05302231 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002232 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
2233 goto done;
2234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002235
2236 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2237 pCsrRoamInfo->nAssocReqLength);
2238 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002239 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002240
2241 //pFTAssocRsp needs to point to the IEs
2242 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002243 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 (unsigned int)pFTAssocRsp[0],
2245 (unsigned int)pFTAssocRsp[1]);
2246
2247 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08002248 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002251 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002252
Abhishek Singh5a597e62016-12-05 15:16:30 +05302253 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
2254 (int) pCsrRoamInfo->pBssDesc->channelId);
2255 vos_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
2256 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roam_profile);
2257 bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2258 chan, pCsrRoamInfo->bssid,
2259 &roam_profile.SSID.ssId[0],
2260 roam_profile.SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302261 hdd_send_roamed_ind(dev, bss,
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 reqRsnIe, reqRsnLength,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302263 rspRsnIe, rspRsnLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002264
2265done:
2266 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07002267}
Jeff Johnson295189b2012-06-20 16:38:30 -07002268
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302269void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
2270{
2271 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2273 tCsrRoamInfo roamInfo;
2274 roamInfo.fAuthRequired = FALSE;
2275 vos_mem_copy(roamInfo.bssid,
2276 pHddStaCtx->roam_info.bssid,
2277 WNI_CFG_BSSID_LEN);
2278 vos_mem_copy(roamInfo.peerMac,
2279 pHddStaCtx->roam_info.peerMac,
2280 WNI_CFG_BSSID_LEN);
2281
2282 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
2283 &roamInfo,
2284 pHddStaCtx->roam_info.roamId,
2285 pHddStaCtx->roam_info.roamStatus,
2286 eCSR_ROAM_RESULT_AUTHENTICATED);
2287 if (halStatus != eHAL_STATUS_SUCCESS)
2288 {
2289 hddLog(LOGE, "%s: Set Key complete failure", __func__);
2290 }
2291 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
2292}
2293
Abhishek Singh78c691f2017-11-30 13:48:44 +05302294/**
2295 * hdd_schedule_ecsa_chan_change_work() - schedule ecsa chan change work
2296 * @hal: hal context
2297 * @sta_session_id: sta session id
2298 *
2299 * Return: void.
2300 */
2301static void
2302hdd_schedule_ecsa_chan_change_work(hdd_context_t *hdd_ctx,
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302303 uint8_t sta_session_id)
Abhishek Singh78c691f2017-11-30 13:48:44 +05302304{
2305 v_TIME_t conn_start_time;
2306 int32_t time_diff;
2307
2308 conn_start_time = sme_get_connect_strt_time(hdd_ctx->hHal, sta_session_id);
2309 time_diff = vos_timer_get_system_time() - conn_start_time;
2310
2311 if (time_diff < 0)
2312 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL;
2313 else if (time_diff > ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL)
2314 time_diff = 0;
2315 else
2316 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL - time_diff;
2317
2318 hddLog(LOG1, FL("schedule ecsa_chan_change_work after %d ms"), time_diff);
2319 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
2320 msecs_to_jiffies(time_diff));
2321}
2322
Shailender Karmuchia734f332013-04-19 14:02:48 -07002323static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2324 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 eCsrRoamResult roamResult )
2326{
2327 struct net_device *dev = pAdapter->dev;
2328 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2329 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302330 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05302331 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002332 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2333 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002334#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 int ft_carrier_on = FALSE;
2336#endif
2337 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302338 v_BOOL_t hddDisconInProgress = FALSE;
2339
2340 /* HDD has initiated disconnect, do not send connect result indication
2341 * to kernel as it will be handled by __cfg80211_disconnect.
2342 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05302343 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
2344 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
2345 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2346 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302347 {
2348 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2349 FL(" Disconnect from HDD in progress "));
2350 hddDisconInProgress = TRUE;
2351 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002352
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
2354 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302355 if ( !hddDisconInProgress )
2356 {
2357 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05302358 "%s: Set HDD connState to eConnectionState_Associated",
2359 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302360 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
2361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002362
c_hpothu44ff4e02014-05-08 00:13:57 +05302363 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 // Save the connection info from CSR...
2365 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05302366
2367#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2368 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
2369 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
2370 !hddDisconInProgress &&
2371 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
2372 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
2373 sme_set_per_roam_rxconfig(pHddCtx->hHal,
2374 pHddStaCtx->conn_info.staId[0],
2375 pHddCtx->cfg_ini->rateDownThreshold,
2376 pHddCtx->cfg_ini->rateUpThreshold,
2377 pHddCtx->cfg_ini->PERroamTriggerPercent,
2378 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
2379 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
2380#endif
2381
Jeff Johnson295189b2012-06-20 16:38:30 -07002382#ifdef FEATURE_WLAN_WAPI
2383 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
2384 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
2385 {
2386 pAdapter->wapi_info.fIsWapiSta = 1;
2387 }
2388 else
2389 {
2390 pAdapter->wapi_info.fIsWapiSta = 0;
2391 }
2392#endif /* FEATURE_WLAN_WAPI */
2393
2394 // indicate 'connect' status to userspace
2395 hdd_SendAssociationEvent(dev,pRoamInfo);
2396
2397
Shailender Karmuchia734f332013-04-19 14:02:48 -07002398 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 INIT_COMPLETION(pAdapter->linkup_event_var);
2400
2401 /*
2402 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
2403 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 -07002404 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 know that the device is getting activated properly.
2406 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002407#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05302408 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 {
2410#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002411 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 pAdapter->isLinkUpSvcNeeded = TRUE;
2413
Shailender Karmuchia734f332013-04-19 14:02:48 -07002414 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 pAdapter->isLinkUpSvcNeeded = TRUE;
2416
2417 // Switch on the Carrier to activate the device
2418 netif_carrier_on(dev);
2419
2420 // Wait for the Link to up to ensure all the queues are set properly by the kernel
2421 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
2422 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002423 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 {
2425 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
2426 }
2427
2428 // Disable Linkup Event Servicing - no more service required from the net device notifier call
2429 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002430#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002432 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 }
2436#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05302437 /* Check for STAID */
2438 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
2439 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2440 else
2441 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002442
2443 //For reassoc, the station is already registered, all we need is to change the state
2444 //of the STA in TL.
2445 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05302446 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 if( !pRoamInfo->fReassocReq )
2448 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002449 struct cfg80211_bss *bss;
2450#ifdef WLAN_FEATURE_VOWIFI_11R
2451 u8 *pFTAssocRsp = NULL;
2452 unsigned int assocRsplen = 0;
2453 u8 *pFTAssocReq = NULL;
2454 unsigned int assocReqlen = 0;
2455 struct ieee80211_channel *chan;
2456#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002459
2460 /* add bss_id to cfg80211 data base */
2461 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2462 if (NULL == bss)
2463 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302464 hddLog(LOGE,
2465 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05302466 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302467 if (!hddDisconInProgress) {
2468 /*
2469 * Here driver was not able to update cfg80211 database
2470 * this can happen if connected channel is not valid,
2471 * i.e reg domain was changed during connection.
2472 * Queue disconnect for the session if disconnect is
2473 * not in progress.
2474 */
2475 hddLog(LOGE, FL("Disconnecting..."));
2476 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2477 pAdapter->sessionId,
2478 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 return eHAL_STATUS_FAILURE;
2481 }
Abhinav Kumar4cde8292019-07-18 14:17:25 +05302482
2483 //Association Response
2484 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames +
2485 pRoamInfo->nBeaconLength +
2486 pRoamInfo->nAssocReqLength);
2487 if (pFTAssocRsp != NULL)
2488 {
2489 // pFTAssocRsp needs to point to the IEs
2490 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2491 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
2492 (unsigned int)pFTAssocRsp[0],
2493 (unsigned int)pFTAssocRsp[1]);
2494 assocRsplen =
2495 pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2496 }
2497 else
2498 {
2499 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
2500 assocRsplen = 0;
2501 }
2502
2503 //Association Request
2504 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
2505 pRoamInfo->nBeaconLength);
2506 if (pFTAssocReq != NULL)
2507 {
2508 if(!ft_carrier_on)
2509 {
2510 // pFTAssocReq needs to point to the IEs
2511 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
2512 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
2513 (unsigned int)pFTAssocReq[0],
2514 (unsigned int)pFTAssocReq[1]);
2515 assocReqlen =
2516 pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
2517 }
2518 else
2519 {
2520 /* This should contain only the FTIEs */
2521 assocReqlen = pRoamInfo->nAssocReqLength;
2522 }
2523 }
2524 else
2525 {
2526 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
2527 assocReqlen = 0;
2528 }
2529
2530 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
2531 assocRsplen);
2532
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002533#ifdef WLAN_FEATURE_VOWIFI_11R
2534 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002535 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002537 if(ft_carrier_on)
2538 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302539 if ( !hddDisconInProgress )
2540 {
Abhishek Singh5a597e62016-12-05 15:16:30 +05302541 struct cfg80211_bss *roam_bss;
2542
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302543 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002544 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302545 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002546 (int)pRoamInfo->pBssDesc->channelId);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302547 if (pHddCtx->cfg_ini &&
2548 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302549 {
2550 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2551 }
Abhishek Singh5a597e62016-12-05 15:16:30 +05302552 roam_bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2553 chan, pRoamInfo->bssid,
2554 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2555 pRoamInfo->u.pConnectedProfile->SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302556 hdd_send_roamed_ind(dev, roam_bss,
Abhishek Singh5a597e62016-12-05 15:16:30 +05302557 pFTAssocReq, assocReqlen,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302558 pFTAssocRsp, assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302559 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302560 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2561 {
2562 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
2563 pRoamInfo->fAuthRequired = FALSE;
2564
2565 vos_mem_copy(pHddStaCtx->roam_info.bssid,
2566 pRoamInfo->bssid,
2567 HDD_MAC_ADDR_LEN);
2568 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
2569 pRoamInfo->peerMac,
2570 HDD_MAC_ADDR_LEN);
2571 pHddStaCtx->roam_info.roamId = roamId;
2572 pHddStaCtx->roam_info.roamStatus = roamStatus;
2573 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
2574 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002575 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302576 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002577 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002578 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002579 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302580 hdd_connect_result(dev, pRoamInfo->bssid, pRoamInfo,
2581 pFTAssocReq, assocReqlen,
2582 pFTAssocRsp, assocRsplen,
2583 WLAN_STATUS_SUCCESS,
2584 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002585 }
2586 }
2587 else
2588#endif
2589 {
2590 /* wpa supplicant expecting WPA/RSN IE in connect result */
2591 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2592 pAdapter->sessionId,
2593 &reqRsnLength,
2594 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002595
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002596 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2597 pAdapter->sessionId,
2598 &rspRsnLength,
2599 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302600 if ( !hddDisconInProgress )
2601 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002602#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302603 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05302604 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302605 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302606 if (pHddCtx->cfg_ini &&
2607 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302608 {
2609 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2610 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302611 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302612 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002613#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002614
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302615 {
2616 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302617 "%s: sending connect indication to nl80211:"
2618 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302619 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302620 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
2621 roamResult, roamStatus);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302622 /* inform connect result to nl80211 */
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302623 hdd_connect_result(dev, pRoamInfo->bssid,
2624 pRoamInfo,
Abhinav Kumar4cde8292019-07-18 14:17:25 +05302625 pFTAssocReq, assocReqlen,
2626 pFTAssocRsp, assocRsplen,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302627 WLAN_STATUS_SUCCESS,
2628 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302629 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302632 if ( !hddDisconInProgress )
2633 {
2634 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07002635#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302636 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07002637#endif
2638 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302639 // Register the Station with TL after associated...
2640 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 pRoamInfo,
2642 pHddStaCtx->conn_info.staId[ 0 ],
2643 NULL,
2644 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 }
2647 else
2648 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002649 /* wpa supplicant expecting WPA/RSN IE in connect result */
2650 /* in case of reassociation also need to indicate it to supplicant */
2651 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2652 pAdapter->sessionId,
2653 &reqRsnLength,
2654 reqRsnIe);
2655
2656 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302658 if( pRoamInfo->fAuthRequired )
2659 {
2660 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2661 pHddStaCtx->conn_info.staId[ 0 ],
2662 WLANTL_STA_CONNECTED );
2663 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2664 }
2665 else
2666 {
2667 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2668 "%s: staId: %d Changing TL state to AUTHENTICATED",
2669 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
2670 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2671 pHddStaCtx->conn_info.staId[ 0 ],
2672 WLANTL_STA_AUTHENTICATED );
2673 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302674 hdd_postTLPacketPendingInd(pAdapter,
2675 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 }
2678
2679 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
2680 {
2681 // perform any WMM-related association processing
2682 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
2683 }
2684 else
2685 {
2686 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002687 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 vosStatus, vosStatus );
2689 }
Chet Lanctot186b5732013-03-18 10:26:30 -07002690#ifdef WLAN_FEATURE_11W
2691 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
2692 sizeof(pAdapter->hdd_stats.hddPmfStats) );
2693#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302694
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05302696 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302697 {
2698 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05302699 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302700 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302701 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302702 {
2703 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
2704 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05302705#ifdef FEATURE_WLAN_TDLS
2706 wlan_hdd_tdls_connection_callback(pAdapter);
2707#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002708 }
2709 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2712
2713 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002714 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302715 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2716 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
2717 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002718 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302719 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2720 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08002721 MAC_ADDR_ARRAY(pWextState->req_bssId),
2722 roamResult, roamStatus);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302723 if (!pHddStaCtx->get_mgmt_log_sent) {
2724 pHddStaCtx->get_mgmt_log_sent = TRUE;
Abhishek Singh611295e2015-07-09 11:11:54 +05302725 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302726 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302727 }
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302728
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302729 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2730 (pRoamInfo &&
2731 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2732 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2733 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05302734 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302735 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2736 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2737 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2738 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05302739 /* Set connection state to eConnectionState_NotConnected only when CSR
2740 * has completed operation - with a ASSOCIATION_FAILURE status
2741 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302742 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05302743 {
2744 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2745 "%s: Set HDD connState to eConnectionState_NotConnected",
2746 __func__);
2747 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
2748 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05302749 if((pHddCtx->concurrency_mode <= 1) &&
2750 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 {
2752 pHddCtx->isAmpAllowed = VOS_TRUE;
2753 }
2754
2755 //If the Device Mode is Station
2756 // and the P2P Client is Connected
2757 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07002758
2759 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07002760 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002761 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2762 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302763 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 {
2765 //Enable BMPS only of other Session is P2P Client
2766 hdd_context_t *pHddCtx = NULL;
2767 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2768
2769 if (NULL != pVosContext)
2770 {
2771 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2772
2773 if(NULL != pHddCtx)
2774 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302775 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302776 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2777 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302778 {
2779 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002780 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302781 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002782 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302783 hdd_enable_bmps_imps(pHddCtx);
2784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 }
2786 }
2787 }
2788
James Zmudafbf5ffc2013-03-25 12:45:35 -07002789 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002790 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302791 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002792 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302793
2794 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2795 {
2796 hddLog(LOG1,
2797 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2798 wlan_hdd_tdls_reenable(pHddCtx);
2799 }
2800
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302801 if (pRoamInfo) {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302802 hddLog(VOS_TRACE_LEVEL_ERROR,
2803 "%s: send connect failure to nl80211:"
2804 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302805 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302806 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302807 roamResult, roamStatus, pRoamInfo->reasonCode);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302808 pHddStaCtx->conn_info.assoc_status_code =
2809 pRoamInfo->statusCode;
2810 } else {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302811 hddLog(VOS_TRACE_LEVEL_ERROR,
2812 "%s: connect failed:"
2813 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302814 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302815 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2816 roamResult, roamStatus);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302817 }
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302818
James Zmudafbf5ffc2013-03-25 12:45:35 -07002819 /* inform association failure event to nl80211 */
2820 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2821 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002822 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302823 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002824 NULL, 0, NULL, 0,
2825 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302826 GFP_KERNEL);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002827 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302828 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002829 NULL, 0, NULL, 0,
2830 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302831 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002832 }
2833 else
2834 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002835 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302836 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002837 NULL, 0, NULL, 0,
2838 pRoamInfo->reasonCode ?
2839 pRoamInfo->reasonCode :
2840 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302841 GFP_KERNEL);
Gao Wu6ca73b32016-05-09 14:35:49 +08002842 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302843 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002844 NULL, 0, NULL, 0,
2845 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302846 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002847 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302848 /*Clear the roam profile*/
2849 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002851
Kumar Anand82c009f2014-05-29 00:29:42 -07002852 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002853
c_hpothu24f40982014-04-18 18:00:36 +05302854 if (pRoamInfo)
2855 {
2856 WLANTL_AssocFailed(pRoamInfo->staId);
2857 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302858
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302859 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 netif_tx_disable(dev);
2861 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002862
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 }
2864
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302865 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302866 {
2867 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2868 if (pHostapdAdapter != NULL)
2869 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302870 /* Restart SAP if its operating channel is different
2871 * from AP channel.
2872 */
2873 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2874 (int)pRoamInfo->pBssDesc->channelId)
2875 {
2876 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2877 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2878 (int)pRoamInfo->pBssDesc->channelId);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302879 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->force_scc_with_ecsa)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302880 {
Abhishek Singh78c691f2017-11-30 13:48:44 +05302881 hdd_schedule_ecsa_chan_change_work(pHddCtx,
2882 pAdapter->sessionId);
2883 }
2884 else
2885 {
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302886 hdd_hostapd_stop(pHostapdAdapter->dev);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302887 if (pHddCtx->cfg_ini &&
2888 pHddCtx->cfg_ini->enable_sap_auth_offload)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302889 hdd_force_scc_restart_sap(pHostapdAdapter,
2890 pHddCtx, (int)pRoamInfo->pBssDesc->channelId);
2891 }
Agrawal Ashish574b3e62017-02-09 18:58:34 +05302892
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302893 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302894 }
2895 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302896 else if (roamStatus == eCSR_ROAM_ASSOCIATION_FAILURE)
2897 {
2898 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
2899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 return eHAL_STATUS_SUCCESS;
2901}
2902
2903/**============================================================================
2904 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002905 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002907
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002909static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2910 tCsrRoamInfo *pRoamInfo,
2911 tANI_U32 roamId,
2912 eRoamCmdStatus roamStatus,
2913 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002914{
Katya Nigam47528772015-02-11 12:24:49 +05302915 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2916 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2917 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302918 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302919
Jeff Johnson81c17882013-05-03 09:53:35 -07002920 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2921 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2922
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 switch( roamResult )
2924 {
2925 // both IBSS Started and IBSS Join should come in here.
2926 case eCSR_ROAM_RESULT_IBSS_STARTED:
2927 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002928 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002930 if (NULL == pRoamInfo)
2931 {
2932 VOS_ASSERT(0);
2933 return;
2934 }
2935
2936 /* When IBSS Started comes from CSR, we need to move
2937 * connection state to IBSS Disconnected (meaning no peers
2938 * are in the IBSS).
2939 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2941 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2942 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002943 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2944 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302945 /*notify wmm */
2946 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002947 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002948
Jeff Johnson81c17882013-05-03 09:53:35 -07002949 if (pRoamInfo->pBssDesc)
2950 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302951#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2952 struct ieee80211_channel *chan;
2953 int chan_no;
2954 unsigned int freq;
2955#endif
Katya Nigam47528772015-02-11 12:24:49 +05302956 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2957 IBSS_BROADCAST_STAID,
2958 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002959
2960 /* we created the IBSS, notify supplicant */
2961 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2962 MAC_ADDRESS_STR,
2963 __func__, pAdapter->dev->name,
2964 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2965
2966 /* we must first give cfg80211 the BSS information */
2967 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2968 if (NULL == bss)
2969 {
2970 hddLog(VOS_TRACE_LEVEL_ERROR,
2971 "%s: %s: unable to create IBSS entry",
2972 __func__, pAdapter->dev->name);
2973 return;
2974 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302975#ifdef WLAN_FEATURE_RMC
2976 netif_carrier_on(pAdapter->dev);
2977 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2978 netif_tx_start_all_queues(pAdapter->dev);
2979#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302980#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2981 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002982
Anand N Sunkadfec40682015-07-29 09:51:17 +05302983 if (chan_no <= 14)
2984 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302985 HDD_NL80211_BAND_2GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302986 else
2987 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302988 HDD_NL80211_BAND_5GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302989
2990 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2991
2992 if (chan)
2993 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2994 chan, GFP_KERNEL);
2995 else
2996 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2997 pAdapter->dev->name,
2998 (int)pRoamInfo->pBssDesc->channelId);
2999#else
Jeff Johnson81c17882013-05-03 09:53:35 -07003000 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05303001#endif
Yue Maf49ba872013-08-19 12:04:25 -07003002 cfg80211_put_bss(
3003#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3004 pHddCtx->wiphy,
3005#endif
3006 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07003007 }
Katya Nigam47528772015-02-11 12:24:49 +05303008 else
3009 {
3010 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3011 "%s: NULL Bss Desc",__func__);
3012 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303013
3014 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
3015 * in IBSS_COALESCED will remove the BC key.
3016 */
3017 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
3018 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
3019 == pHddStaCtx->ibss_enc_key.encType
3020 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
3021 == pHddStaCtx->ibss_enc_key.encType
3022 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3023 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
3024 {
3025 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3026 VOS_STATUS vosStatus;
3027
3028 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
3029
3030 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3031 grpmacaddr, WNI_CFG_BSSID_LEN);
3032 hddLog(VOS_TRACE_LEVEL_INFO,
3033 FL(" SET GTK in case of COALESCED"));
3034 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3035 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3036 if ( VOS_STATUS_SUCCESS != vosStatus )
3037 {
3038 hddLog(VOS_TRACE_LEVEL_ERROR,
3039 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
3040 }
3041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 break;
3043 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003044
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3046 {
Jeff Johnson81c17882013-05-03 09:53:35 -07003047 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
3048 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 break;
3050 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003051
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07003053 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
3054 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07003055 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003056 }
3057
Jeff Johnson81c17882013-05-03 09:53:35 -07003058 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003059}
3060
3061/**============================================================================
3062 *
3063 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
3064 This information is passed to iwconfig later. The peer that joined
3065 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003066 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003068
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05303070static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07003071{
3072 int fSuccess = FALSE;
3073 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303074 VOS_STATUS status;
3075 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003076
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3078 {
3079 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
3080 {
3081 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003082
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003084
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 fSuccess = TRUE;
3086 break;
3087 }
3088 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003089
Nirav Shah7e3c8132015-06-22 23:51:42 +05303090 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
3091 if (status != VOS_STATUS_SUCCESS) {
3092 hddLog(VOS_TRACE_LEVEL_ERROR,
3093 FL("Not able to add staid hash %d"), staId);
3094 return FALSE;
3095 }
3096
3097 hddLog(VOS_TRACE_LEVEL_INFO,
3098 FL("New station added sta_id %d mac:"
3099 MAC_ADDRESS_STR), staId,
3100 MAC_ADDR_ARRAY(peerMacAddress->bytes));
3101
Shailender Karmuchia734f332013-04-19 14:02:48 -07003102 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07003103}
3104/**============================================================================
3105 *
3106 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003107 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003109
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07003111static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003112{
3113 int fSuccess = FALSE;
3114 int idx = 0;
3115 v_U8_t valid_idx = 0;
3116 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07003117 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003118 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05303119 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003120
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3122 {
3123 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
3124 {
3125 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303126 status = hdd_sta_id_hash_remove_entry(pAdapter,
3127 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
3128 if (status != VOS_STATUS_SUCCESS) {
3129 hddLog(VOS_TRACE_LEVEL_ERROR,
3130 FL("Not able to remove staid hash %d"), staId );
3131 fSuccess = FALSE;
3132 } else {
3133 hddLog(VOS_TRACE_LEVEL_INFO,
3134 FL("station removed sta_id %d mac:"
3135 MAC_ADDRESS_STR), staId,
3136 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07003137
Nirav Shah7e3c8132015-06-22 23:51:42 +05303138 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07003139
Nirav Shah7e3c8132015-06-22 23:51:42 +05303140 fSuccess = TRUE;
3141 // Note the deleted Index, if its 0 we need special handling
3142 del_idx = idx;
3143 empty_slots++;
3144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 }
3146 else
3147 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003148 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 {
3150 valid_idx = idx;
3151 }
Ravi Joshi8a934352013-09-25 16:46:58 -07003152 else
3153 {
3154 // Found an empty slot
3155 empty_slots++;
3156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 }
3158 }
3159
Ravi Joshi8a934352013-09-25 16:46:58 -07003160 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
3161 {
3162 // Last peer departed, set the IBSS state appropriately
3163 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003164 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07003165 "Last IBSS Peer Departed!!!" );
3166 }
3167
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 // Find next active staId, to have a valid sta trigger for TL.
3169 if (fSuccess == TRUE)
3170 {
3171 if (del_idx == 0)
3172 {
3173 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
3174 {
3175 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
3176 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
3177 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
3178
3179 pHddStaCtx->conn_info.staId[valid_idx] = 0;
3180 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
3181 }
3182 }
3183 }
3184 return( fSuccess );
3185}
3186
3187/**============================================================================
3188 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003189 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003191
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 ===========================================================================*/
3193static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
3194{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003195 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05303196 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3197 "%s: IBSS Connect Indication from SME!!! "
3198 "Set HDD connState to eConnectionState_IbssConnected",
3199 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
3201 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
3202
3203 // Save the connection info from CSR...
3204 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
3205
3206 // Send the bssid address to the wext.
3207 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003209 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3210 if (NULL == bss)
3211 {
3212 hddLog(VOS_TRACE_LEVEL_ERROR,
3213 "%s: %s: unable to create IBSS entry",
3214 __func__, pAdapter->dev->name);
3215 return eHAL_STATUS_FAILURE;
3216 }
Yue Maf49ba872013-08-19 12:04:25 -07003217 cfg80211_put_bss(
3218#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3219 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
3220#endif
3221 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222
3223 return( eHAL_STATUS_SUCCESS );
3224}
Mukul Sharmad2589a52014-04-23 21:06:25 +05303225
3226/**============================================================================
3227 *
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003229
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003231static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3232 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 eCsrRoamResult roamResult )
3234{
3235 eCsrEncryptionType connectedCipherAlgo;
3236 v_BOOL_t fConnected = FALSE;
3237 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3238 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303239 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303241 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07003243
3244 if (NULL == pRoamInfo)
3245 {
3246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
3247 return eHAL_STATUS_FAILURE;
3248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003250 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 // not require upper layer authentication) we can put TL directly into 'authenticated'
3252 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3254 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
3255 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003256
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3258 if( fConnected )
3259 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003260 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
3261 {
3262 v_U8_t staId;
3263
3264 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
3265
3266 if ( 0 == memcmp( pRoamInfo->peerMac,
3267 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
3268 {
3269 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3270 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05303271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3272 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003273 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3274 }
3275 else
3276 {
3277 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
3278 (v_MACADDR_t*)pRoamInfo->peerMac,
3279 &staId);
3280 if ( VOS_STATUS_SUCCESS == vosStatus )
3281 {
3282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3283 "WLAN TL STA Ptk Installed for STAID=%d", staId);
3284 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3285 staId);
3286 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3287 }
3288 }
3289 }
3290 else
3291 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05303292 WLANTL_GetSTAState(pHddCtx->pvosContext,
3293 pHddStaCtx->conn_info.staId[0],
3294 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303295 // TODO: Considering getting a state machine in HDD later.
3296 // This routine is invoked twice. 1)set PTK 2)set GTK.
3297 // The folloing if statement will be TRUE when setting GTK.
3298 // At this time we don't handle the state in detail.
3299 // Related CR: 174048 - TL not in authenticated state
3300 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
3301 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
3302 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303303
3304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
3305 "for StaId=%d. Changing TL state to AUTHENTICATED from"
3306 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303307
3308 // Connections that do not need Upper layer authentication,
3309 // transition TL to 'Authenticated' state after the keys are set.
3310 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3311 pHddStaCtx->conn_info.staId[ 0 ],
3312 WLANTL_STA_AUTHENTICATED );
3313
3314 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303315
3316 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3317 hdd_postTLPacketPendingInd(pAdapter,
3318 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05303319 //Need to call offload because when roaming happen at that time fwr
3320 //clean offload info as part of the DelBss
3321 // No need to configure offload if host was not suspended
3322 spin_lock(&pHddCtx->filter_lock);
3323 if(pHddCtx->hdd_wlan_suspended)
3324 {
3325 spin_unlock(&pHddCtx->filter_lock);
3326 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
3327 }
3328 else
3329 {
3330 spin_unlock(&pHddCtx->filter_lock);
3331 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303332 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3333 {
3334 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
3335 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303336 }
3337 else
3338 {
3339 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3340 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303341
3342 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
3343 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
3344 {
3345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
3346 " for StaId=%d. Due to OSEN, Changing TL state to"
3347 "AUTHENTICATED from state:%d",
3348 pHddStaCtx->conn_info.staId[0], prevTLState);
3349
3350 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3351 pHddStaCtx->conn_info.staId[ 0 ],
3352 WLANTL_STA_AUTHENTICATED );
3353
3354 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
3355
3356 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3357 hdd_postTLPacketPendingInd(pAdapter,
3358 pHddStaCtx->conn_info.staId[0]);
3359 }
3360
3361
3362
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303363 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3364 {
3365 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
3366 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303367 }
3368
3369 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303372 else
3373 {
3374 // possible disassoc after issuing set key and waiting set key complete
3375 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3376 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003377
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 EXIT();
3379 return( eHAL_STATUS_SUCCESS );
3380}
3381/**============================================================================
3382 *
3383 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
3384 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003385static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07003387{
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3389
3390 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3391 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
3392 {
3393 struct iw_michaelmicfailure msg;
3394 union iwreq_data wreq;
3395 memset(&msg, '\0', sizeof(msg));
3396 msg.src_addr.sa_family = ARPHRD_ETHER;
3397 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08003398 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
3399 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07003400
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3402 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003403 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 msg.flags = IW_MICFAILURE_PAIRWISE;
3405 memset(&wreq, 0, sizeof(wreq));
3406 wreq.data.length = sizeof(msg);
3407 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003409 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3411 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
3412 NL80211_KEYTYPE_GROUP :
3413 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07003414 pRoamInfo->u.pMICFailureInfo->keyId,
3415 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003417
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003419
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 return( eHAL_STATUS_SUCCESS );
3421}
3422
3423/**============================================================================
3424 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003425 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003427
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003429static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3430 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 eCsrRoamResult roamResult )
3432{
3433 VOS_STATUS vosStatus;
3434
3435 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3436 switch( roamResult )
3437 {
3438 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3439 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003440 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303441 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003442
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303443 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3444 "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 -07003445 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3446 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003448
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3450
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
3452 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
3453 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
3454
3455 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05303456 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 pRoamInfo,
3458 pRoamInfo->staId,
3459 (v_MACADDR_t *)pRoamInfo->peerMac,
3460 pRoamInfo->pBssDesc );
3461 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3462 {
3463 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003464 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 vosStatus, vosStatus );
3466 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05303467 if (!roamSaveIbssStation(pAdapter,
3468 pRoamInfo->staId,
3469 (v_MACADDR_t *)pRoamInfo->peerMac))
3470 {
3471 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
3472 break;
3473 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003474 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303475
3476 staInfo = vos_mem_malloc(sizeof(*staInfo));
3477 if (staInfo == NULL) {
3478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3479 "memory allocation for station_info failed");
3480 return eHAL_STATUS_FAILED_ALLOC;
3481 }
3482
3483 memset(staInfo, 0, sizeof(*staInfo));
3484 staInfo->filled = 0;
3485 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003486
3487 cfg80211_new_sta(pAdapter->dev,
3488 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303489 staInfo, GFP_KERNEL);
3490 vos_mem_free(staInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003491
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003492 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3493 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3494 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3495 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
3496 {
3497 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05303498
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003499 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3500 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
3501
3502 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003503 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003504 pHddStaCtx->ibss_enc_key.encType);
3505
3506 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3507 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3508
3509 if ( VOS_STATUS_SUCCESS != vosStatus )
3510 {
3511 hddLog(VOS_TRACE_LEVEL_ERROR,
3512 "%s: sme_RoamSetKey failed, returned %d",
3513 __func__, vosStatus);
3514 return VOS_STATUS_E_FAILURE;
3515 }
3516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303518 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 netif_tx_start_all_queues(pAdapter->dev);
3520 break;
3521 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003522
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3524 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003525
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003527
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3531 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003532 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003533
Ravi Joshicc57ed42013-10-12 16:31:25 -07003534 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 {
3536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3537 "IBSS peer departed by cannot find peer in our registration table with TL" );
3538 }
3539
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303540 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3541 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003542 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3543 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
3544 pRoamInfo->staId );
3545
Katya Nigam47528772015-02-11 12:24:49 +05303546 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003547
3548 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003549 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003550
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003551 cfg80211_del_sta(pAdapter->dev,
3552 (const u8 *)&pRoamInfo->peerMac,
3553 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 break;
3555 }
3556 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3557 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003558 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
3559 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303561 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 netif_tx_disable(pAdapter->dev);
3563 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05303564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3565 "%s: Set HDD connState to eConnectionState_NotConnected",
3566 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003568
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 // Send the bssid address to the wext.
3570 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
3571 // clean up data path
3572 hdd_disconnect_tx_rx(pAdapter);
3573 break;
3574 }
3575 default:
3576 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003577
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003579
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 return( eHAL_STATUS_SUCCESS );
3581}
3582
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003583#ifdef FEATURE_WLAN_TDLS
3584/**============================================================================
3585 *
3586 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
3587 TL the new STA. This is called as part of ADD_STA in the TDLS setup
3588 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07003589
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003590 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303591VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
3592#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3593 const tANI_U8 *peerMac,
3594#else
3595 tANI_U8 *peerMac,
3596#endif
3597 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003598{
3599 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003600 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003601 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3602 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003603 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
3604 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003605 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3606 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003607
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003608 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3609 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003610 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003611 "%s not connected. ignored", __func__);
3612 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003613 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003614
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003615 /*
3616 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3617 * be peer MAC, here we are wokrking on direct Link
3618 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003619 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003620
3621 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003622
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003623 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003624 sizeof(tSirMacAddr) );
3625
3626 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
3627 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
3628
3629 /* set the QoS field appropriately ..*/
3630 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
3631 : (staDesc.ucQosEnabled = 0) ;
3632
3633 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08003634 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003635
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003636 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003637
3638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003639 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003640
Shailender Karmuchia734f332013-04-19 14:02:48 -07003641 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003642 * UMA is ready we inform TL to do frame translation.
3643 */
3644 staDesc.ucSwFrameTXXlation = 1;
3645 staDesc.ucSwFrameRXXlation = 1;
3646 staDesc.ucAddRmvLLC = 1;
3647
3648 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003649 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003650
3651 /* tdls Direct Link do not need bcastSig */
3652 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003653
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003654 if(staDesc.ucProtectedFrame)
3655 staDesc.ucIsReplayCheckValid = VOS_TRUE;
3656 else
3657 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003658
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303659 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003660
Shailender Karmuchia734f332013-04-19 14:02:48 -07003661 /* Register the Station with TL... */
3662 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
3663 hdd_rx_packet_cbk,
3664 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003665 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003666
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003667 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3668 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003669 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003670 "%s: WLANTL_RegisterSTAClient() failed to register. "
3671 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003672 return vosStatus;
3673 }
3674
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003675 if ( cfg_param->dynSplitscan &&
3676 ( VOS_TIMER_STATE_RUNNING !=
3677 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
3678 {
3679 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
3680 cfg_param->trafficMntrTmrForSplitScan);
3681 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003682 return( vosStatus );
3683}
3684
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303685VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003686{
3687 VOS_STATUS vosStatus;
3688 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
3689 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3690 {
3691 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3692 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003693 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003694 __func__, staId, vosStatus, vosStatus );
3695 }
3696 return( vosStatus );
3697}
3698
3699
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003700/*
3701 * HDD interface between SME and TL to ensure TDLS client registration with
3702 * TL in case of new TDLS client is added and deregistration at the time
3703 * TDLS client is deleted.
3704 */
3705
Shailender Karmuchia734f332013-04-19 14:02:48 -07003706eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
3707 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003708 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07003709 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003710 eCsrRoamResult roamResult)
3711{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003712 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003713 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003714 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003715
Kaushik, Sushant8489f472014-01-27 11:41:22 +05303716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08003717 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
3718 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
3719 "ADD_TDLS_PEER" :
3720 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
3721 "DEL_TDLS_PEER" :
3722 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
3723 "DEL_TDLS_PEER_IND" :
3724 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3725 "DEL_ALL_TDLS_PEER_IND" :
3726 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
3727 "UPDATE_TDLS_PEER" :
3728 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303729 "LINK_ESTABLISH_REQ_RSP" :
3730 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
3731 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08003732 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003733 switch( roamResult )
3734 {
3735 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3736 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003737 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3738 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303739 hddTdlsPeer_t *curr_peer;
3740
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003742 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05303743 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303744
3745 mutex_lock(&pHddCtx->tdls_lock);
3746 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3747 pRoamInfo->peerMac, FALSE);
3748 if (NULL != curr_peer)
3749 curr_peer->link_status = eTDLS_LINK_TEARING;
3750 else
3751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3752 "%s %d curr_peer is Null", __func__,__LINE__);
3753 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003754 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003755 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003756 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003757
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003758 /* check if there is available index for this new TDLS STA */
3759 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3760 {
3761 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3762 {
3763 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3764 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3765
3766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003767 ("TDLS: STA IDX at %d is %d "
3768 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003769 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003770 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003771
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003772 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003773 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3774 status = eHAL_STATUS_SUCCESS ;
3775 break ;
3776 }
3777 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003778 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003779 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003780 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003781 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3782 "wlan_hdd_tdls_set_sta_id() failed");
3783 return VOS_FALSE;
3784 }
3785
3786 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303787 /* store the ucast signature , if required for further reference. */
3788
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003789 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303790 /* start TDLS client registration with TL */
3791 status = hdd_roamRegisterTDLSSTA( pAdapter,
3792 pRoamInfo->peerMac,
3793 pRoamInfo->staId,
3794 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303795 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003796 }
3797 else
3798 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003799 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003801 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003802 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003803 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003804 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003805 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003806 break ;
3807 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003808 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3809 {
3810 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3811 {
3812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3813 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3814 }
3815 /* store the ucast signature which will be used later when
3816 * registering to TL
3817 */
3818 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3819 complete(&pAdapter->tdls_add_station_comp);
3820 break;
3821 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303822 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3823 {
3824 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3825 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303826 hddTdlsPeer_t *curr_peer;
3827
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3829 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303830
3831 mutex_lock(&pHddCtx->tdls_lock);
3832 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3833 pRoamInfo->peerMac, FALSE);
3834 if (curr_peer)
3835 curr_peer->link_status = eTDLS_LINK_TEARING;
3836 else
3837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3838 "%s %d curr_peer is Null",__func__,__LINE__);
3839 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303840 }
3841 complete(&pAdapter->tdls_link_establish_req_comp);
3842 break;
3843 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303844 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3845 {
3846 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3848 "%s: Channel switch request failed. %d", __func__,
3849 pRoamInfo->statusCode);
3850 else
3851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3852 "%s: Channel switch request Success", __func__);
3853 break;
3854 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003855 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003856 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003857 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003858 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003859 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003860 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3861 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003862 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003864 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3865
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303866 mutex_lock(&pHddCtx->tdls_lock);
3867 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3868 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303869 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003870 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3872 " Current status for peer" MAC_ADDRESS_STR "is %d",
3873 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303874 if (TDLS_IS_CONNECTED(curr_peer) ||
3875 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303876 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303877 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303878 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3879 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303880 else
3881 mutex_unlock(&pHddCtx->tdls_lock);
3882
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303883 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003884 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303885 else
3886 mutex_unlock(&pHddCtx->tdls_lock);
3887
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303888 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003889 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303890 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003891
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003892 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3893 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3894 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003895 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003896 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003897 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003898 break ;
3899 }
3900 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003901 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003902 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003903 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003904 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3905 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003906 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003907 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3908 "%s: Sending teardown to supplicant with reason code %u",
3909 __func__, pRoamInfo->reasonCode);
3910
3911#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303912 mutex_lock(&pHddCtx->tdls_lock);
3913 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3914 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003915 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303916 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3917 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303918 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003919#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003920 status = eHAL_STATUS_SUCCESS ;
3921 break ;
3922 }
3923 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3924 {
3925 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003926 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003927 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003928 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3929 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003930 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003932 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003933 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003934 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303935
3936 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003937 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303938 mutex_unlock(&pHddCtx->tdls_lock);
3939
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003940 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3941 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003942
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003943 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003944 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003945 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3946 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003947
3948 status = eHAL_STATUS_SUCCESS ;
3949 }
3950 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303951 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003952 break ;
3953 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003954 default:
3955 {
3956 break ;
3957 }
3958 }
3959
3960 return status ;
3961}
3962#endif
3963
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303964void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003965{
3966 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3967 hdd_context_t *pHddCtx = NULL;
3968 int ret;
3969
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303970 ENTER();
3971
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003972 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3973 {
3974 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003975 "%s: Bad param, pAdapter [%pK]",
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003976 __func__, pAdapter);
3977 return;
3978 }
3979
3980 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3981 ret = wlan_hdd_validate_context(pHddCtx);
3982 if (0 != ret)
3983 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003984 return;
3985 }
3986
3987 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3988 {
3989 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3990 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303991
3992 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003993}
3994
Shailender Karmuchia734f332013-04-19 14:02:48 -07003995eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3997{
3998 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3999 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304000 hdd_wext_state_t *pWextState = NULL;
4001 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004002 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304003 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07004004 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004005
4006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004007 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004008 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004009
4010 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304011 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004012 {
4013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304014 "invalid adapter or adapter has invalid magic");
4015 return eHAL_STATUS_FAILURE;
4016 }
4017
4018 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4019 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4020
4021 if ((NULL == pWextState) || (NULL == pHddStaCtx))
4022 {
4023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4024 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004025 return eHAL_STATUS_FAILURE;
4026 }
4027
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05304028 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4029 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 switch( roamStatus )
4031 {
4032 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05304033 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4034 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004036
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004037#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
4038 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07004040 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 * interface down */
4042 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304043 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
4044 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05304045 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4047 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4048 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4050 }
4051 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05304052 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 break;
4054
4055 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004056 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07004058 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 // eCSR_ROAM_SHOULD_ROAM will be received.
4060 // Where in we will not mark the link down
4061 // Also we want to stop tx at this point when we will be
4062 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004063 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 {
4065 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304066 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05304068 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4069 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
4070 {
4071 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
4072 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004073 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304074 * Deregister this STA with TL, but do not flush the packets
4075 * for this STA from wmm_tx_queue. Since there is no valid STA
4076 * for these packets they will not be transmitted. Eventually
4077 * after the reassociation is successful, these packets will be
4078 * transmitted after registering STA with TL again. This ensures
4079 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004080 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304081 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
4082 pHddStaCtx->conn_info.staId[0]);
4083 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004084 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4086 FL("WLANTL_ClearSTAClient failed for staID %d."
4087 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
4088 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004089 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 }
4092 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004093 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 break;
4095#endif
4096
4097 case eCSR_ROAM_SHOULD_ROAM:
4098 // Dont need to do anything
4099 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 struct net_device *dev = pAdapter->dev;
4101 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4102 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304103 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004105#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 if (pHddStaCtx->ft_carrier_on == FALSE)
4107 {
4108#endif
4109 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004110#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 }
4112#endif
4113
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004114#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 //We should clear all sta register with TL, for now, only one.
4116 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
4117 if ( !VOS_IS_STATUS_SUCCESS(status ) )
4118 {
4119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4120 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
4121 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004122 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004124#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 }
4126 break;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05304127 case eCSR_ROAM_LOSTLINK_DETECTED:
4128 {
4129 if (wlan_hdd_check_and_stop_mon(pAdapter, false))
4130 halStatus = eHAL_STATUS_FAILURE;
4131 }
4132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 case eCSR_ROAM_LOSTLINK:
4134 case eCSR_ROAM_DISASSOCIATED:
4135 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4137 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05304138 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4140 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07004141 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4142 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304143 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07004144 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08004145
4146 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
4147 pHddCtx->configuredMcastBcastFilter =
4148 pHddCtx->sus_res_mcastbcast_filter;
4149 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
4150 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304151
Amar Singhald53568e2013-09-26 11:03:45 -07004152 hddLog(VOS_TRACE_LEVEL_INFO,
4153 "offload: disassociation happening, restoring configuredMcastBcastFilter");
4154 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
4155 pHddCtx->configuredMcastBcastFilter);
4156 hddLog(VOS_TRACE_LEVEL_INFO,
4157 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07004158 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4159 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004160#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304161 /* Call to clear any MC Addr List filter applied after
4162 * successful connection.
4163 */
4164 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004165#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 }
4167 break;
4168 case eCSR_ROAM_IBSS_LEAVE:
4169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4170 "****eCSR_ROAM_IBSS_LEAVE****");
4171 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4172 break;
4173 case eCSR_ROAM_ASSOCIATION_COMPLETION:
4174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4175 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304176 // To Do - address probable memory leak with WEP encryption upon successful association
4177 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304179 //Clear saved connection information in HDD
4180 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304182 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004183
4184 break;
4185 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004186 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 pRoamInfo, roamId, roamStatus, roamResult );
4188 break;
4189 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07004190 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
4191 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 break;
4193
4194 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
4195 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004196 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004197
4198 case eCSR_ROAM_MIC_ERROR_IND:
4199 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4200 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05304201 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
4202 {
4203 /*
4204 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
4205 * adding the 100 value.
4206 */
4207 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
4208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4209 "%s : Rssi on Disconnect : %d",
4210 __func__, pAdapter->rssi_on_disconnect);
4211 break;
4212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004214 {
4215 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4216
4217 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004218 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304219 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304220 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004221 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004222 /* Send DTIM period to the FW; only if the wlan is already
4223 in suspend. This is the case with roaming (reassoc),
4224 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
4225 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
4226 before the ENTER_BMPS_REQ ensures Listen Interval is
4227 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004228 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004229
4230 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004231 if due to unexpected scenario, if we are in BMPS,
4232 then trigger Exit and Enter BMPS to take DTIM period
4233 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004234 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
4235 {
4236 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
4237
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004238 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4239 iw_full_power_cbfn, pAdapter,
4240 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004241 }
4242 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304243
4244 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304245 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
4246 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304247 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304248 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304249 {
4250 hddLog( LOG1, FL("Device in full power."
4251 "Stop and start traffic timer for roaming"));
4252 pmcStopTrafficTimer(pHddCtx->hHal);
4253 if (pmcStartTrafficTimer(pHddCtx->hHal,
4254 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
4255 {
4256 hddLog(LOGP, FL("Cannot start traffic timer"));
4257 }
4258 }
4259
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004260 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304261 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304262 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304263 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 break;
4266#ifdef WLAN_FEATURE_VOWIFI_11R
4267 case eCSR_ROAM_FT_RESPONSE:
4268 hdd_SendFTEvent(pAdapter);
4269 break;
4270#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004271#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004272 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004273 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07004274 {
4275 /* Notify the supplicant of a new candidate */
4276 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
4277 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004278 break;
4279#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004280
Yue Maef608272013-04-08 23:09:17 -07004281#ifdef FEATURE_WLAN_LFR_METRICS
4282 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4283 /* This event is to notify pre-auth initiation */
4284 if (VOS_STATUS_SUCCESS !=
4285 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
4286 {
4287 halStatus = eHAL_STATUS_FAILURE;
4288 }
4289 break;
4290 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4291 /* This event will notify pre-auth completion in case of success */
4292 if (VOS_STATUS_SUCCESS !=
4293 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4294 pRoamInfo, 1))
4295 {
4296 halStatus = eHAL_STATUS_FAILURE;
4297 }
4298 break;
4299 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4300 /* This event will notify pre-auth completion in case of failure. */
4301 if (VOS_STATUS_SUCCESS !=
4302 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4303 pRoamInfo, 0))
4304 {
4305 halStatus = eHAL_STATUS_FAILURE;
4306 }
4307 break;
4308 case eCSR_ROAM_HANDOVER_SUCCESS:
4309 /* This event is to notify handover success.
4310 It will be only invoked on success */
4311 if (VOS_STATUS_SUCCESS !=
4312 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
4313 {
4314 halStatus = eHAL_STATUS_FAILURE;
4315 }
4316 break;
4317#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 case eCSR_ROAM_REMAIN_CHAN_READY:
4319 hdd_remainChanReadyHandler( pAdapter );
4320 break;
4321 case eCSR_ROAM_SEND_ACTION_CNF:
4322 hdd_sendActionCnf( pAdapter,
4323 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
4324 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004325#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08004326 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004327 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08004328 roamId, roamStatus, roamResult );
4329 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004330 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4331 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
4332 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004333#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004334#ifdef WLAN_FEATURE_11W
4335 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4336 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
4337 pRoamInfo->pbFrames,
4338 pRoamInfo->frameType);
4339 break;
4340#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004341#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004342 case eCSR_ROAM_TSM_IE_IND:
4343 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
4344 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
4345 break;
4346
4347 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4348 {
4349 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
4350 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
4351 {
4352 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
4353 }
4354 break;
4355 }
4356
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004357 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004358 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004359 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004360 break;
4361 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004362
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004363 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004364 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004365 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004366 break;
4367 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004368#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05304369 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
4370 {
4371 pAdapter->maxRateFlags = roamResult;
4372 break;
4373 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304374 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4375 if (pRoamInfo && pRoamInfo->pBssDesc) {
4376 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4377 pRoamInfo->pBssDesc);
4378 if (bss_status)
4379 cfg80211_put_bss(
4380#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4381 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4382#endif
4383 bss_status);
4384 else
4385 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
4386 }
Abhinav Kumar118efd02019-08-07 16:41:07 +05304387
4388 case eCSR_ROAM_SAE_COMPUTE:
4389 if (pRoamInfo)
4390 wlan_hdd_sae_callback(pAdapter, pRoamInfo);
4391 break;
4392
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304393 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4394 {
4395 hdd_adapter_t *pHostapdAdapter = NULL;
4396 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4397 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4398
4399 if (!pHddCtx || !pHddStaCtx) {
4400 hddLog(LOG1, FL("Invalid pHddCtx or pHddStaCtx"));
4401 break;
4402 }
4403
4404 hddLog(LOG1, FL("eCSR_ROAM_STA_CHANNEL_SWITCH: new channel %hu"),
4405 pRoamInfo->chan_info.chan_id);
4406
4407 pHddStaCtx->conn_info.operationChannel =
4408 pRoamInfo->chan_info.chan_id;
4409
4410 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
4411 if (pHostapdAdapter &&
4412 (test_bit(SOFTAP_BSS_STARTED,
4413 &pHostapdAdapter->event_flags)))
4414 {
4415 /* Restart SAP if its operating channel is different
4416 * from AP channel.
4417 */
4418 hddLog(VOS_TRACE_LEVEL_INFO,"SAP chan %d, STA chan %d, force_scc_with_ecsa %d",
4419 pHostapdAdapter->sessionCtx.ap.operatingChannel,
4420 pRoamInfo->chan_info.chan_id,
4421 pHddCtx->cfg_ini->force_scc_with_ecsa);
4422 if ((pHddCtx->cfg_ini->force_scc_with_ecsa ) &&
4423 (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
4424 pRoamInfo->chan_info.chan_id))
4425 {
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05304426 schedule_delayed_work(&pHddCtx->ecsa_chan_change_work, 0);
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304427 }
4428 else
4429 hddLog(LOG1, FL("SAP restart not required"));
4430 } else
4431 hddLog(LOG1, FL("SAP not active, nothing to do"));
4432 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304433 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05304434 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 break;
4436 }
4437 return( halStatus );
4438}
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304439
4440#ifdef WLAN_FEATURE_SAE
4441/**
4442 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
4443 * @auth_suite: auth suite
4444 * @auth_type: pointer to eCsrAuthType
4445 *
4446 * Return: None
4447 */
4448static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4449 eCsrAuthType *auth_type)
4450{
4451 if (!memcmp(auth_suite, ccp_rsn_oui_80, 4))
4452 *auth_type = eCSR_AUTH_TYPE_SAE;
4453}
4454#else
4455static inline
4456void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4457 eCsrAuthType *auth_type)
4458{
4459}
4460#endif
4461
Shailender Karmuchia734f332013-04-19 14:02:48 -07004462eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004463{
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304464 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004466 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 {
4468 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004469 } else
4470 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 {
4472 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004473 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004474#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004475 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 {
4477 // Check for 11r FT Authentication with PSK
4478 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004479 } else
4480 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 {
4482 // Check for 11R FT Authentication with 802.1X
4483 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004484 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004485#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004486#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004487 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 {
4489 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4490 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004491#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07004492#ifdef WLAN_FEATURE_11W
4493 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
4494 {
4495 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4496 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304497 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
4498 {
4499 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4500 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004501#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004502 {
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304503 /* If auth suite is of SAE, auth_type will be
4504 * overwritten in hdd_translate_sae_rsn_to_csr_auth
4505 */
4506 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
4507 }
4508
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004510}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004511
Shailender Karmuchia734f332013-04-19 14:02:48 -07004512eCsrAuthType
4513hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004514{
4515 eCsrAuthType auth_type;
4516 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004517 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 {
4519 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004520 } else
4521 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 {
4523 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004524 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004525#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004526 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 {
4528 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004529 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004530#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004531 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4533 }
4534 hddLog(LOG1, FL("auth_type: %d"), auth_type);
4535 return auth_type;
4536}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004537
Shailender Karmuchia734f332013-04-19 14:02:48 -07004538eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004539hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004540{
4541 eCsrEncryptionType cipher_type;
4542 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004543 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 {
4545 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004546 }
4547 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 {
4549 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004550 }
4551 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 {
4553 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004554 }
4555 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 {
4557 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004558 }
4559 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
4560 {
4561 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4562 }
4563 else
4564 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4566 }
4567 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4568 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004569}
Jeff Johnson295189b2012-06-20 16:38:30 -07004570/* To find if the MAC address is NULL */
4571static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
4572{
4573 int i;
4574 for (i = 0; i < length; i++)
4575 {
4576 if (0x00 != (macAddr[i]))
4577 {
4578 return FALSE;
4579 }
4580 }
4581 return TRUE;
4582} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08004583
Shailender Karmuchia734f332013-04-19 14:02:48 -07004584eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004585hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004586{
4587 eCsrEncryptionType cipher_type;
4588 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004589 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 {
4591 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004592 } else
4593 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 {
4595 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004596 } else
4597 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 {
4599 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004600 } else
4601 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 {
4603 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004604 } else
4605 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004607 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4608 } else
4609 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4611 }
4612 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4613 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004614}
Jeff Johnson295189b2012-06-20 16:38:30 -07004615
Shailender Karmuchia734f332013-04-19 14:02:48 -07004616static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
4617 struct ether_addr *pBssid,
4618 eCsrEncryptionType *pEncryptType,
4619 eCsrEncryptionType *mcEncryptType,
4620 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004621#ifdef WLAN_FEATURE_11W
4622 u_int8_t *pMfpRequired,
4623 u_int8_t *pMfpCapable,
4624#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004625 u_int16_t gen_ie_len,
4626 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07004627{
4628 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004629 eHalStatus result;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304630 tDot11fIERSN dot11RSNIE = {0};
4631 tDot11fIEWPA dot11WPAIE = {0};
Shailender Karmuchia734f332013-04-19 14:02:48 -07004632 tANI_U32 i;
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304633 tANI_U32 status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004634 tANI_U8 *pRsnIe;
4635 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07004637 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004638
4639 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
4640 flag to 0 */
4641 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
4642 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
4643
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07004645 if ( gen_ie[0] == DOT11F_EID_RSN)
4646 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07004648 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
4650 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304651 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
4652 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 return -EINVAL;
4654 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004655 // Skip past the EID byte and length byte
4656 pRsnIe = gen_ie + 2;
4657 RSNIeLen = gen_ie_len - 2;
4658 // Unpack the RSN IE
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304659 status = sme_unpack_rsn_ie(halHandle,
4660 pRsnIe,
4661 RSNIeLen,
4662 &dot11RSNIE);
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304663 if (DOT11F_FAILED(status))
4664 {
4665 hddLog(LOGE,
4666 FL("Parse failure in hdd_ProcessGENIE (0x%08x)"),
4667 status);
4668 return -EINVAL;
4669 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304670 hddLog(LOG1, FL("%s: gp_cipher_suite_present: %d"),
4671 __func__, dot11RSNIE.gp_cipher_suite_present);
4672
Shailender Karmuchia734f332013-04-19 14:02:48 -07004673 // Copy out the encryption and authentication types
4674 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004675 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004676 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304677 __func__, dot11RSNIE.akm_suite_cnt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004678 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 but probably I suspect we can do something different*/
4680 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07004681 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304682 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004683 //dot11RSNIE.pwise_cipher_suite_count
4684 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
4685 //dot11RSNIE.gp_cipher_suite_count
4686 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07004687#ifdef WLAN_FEATURE_11W
4688 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
4689 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
4690#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07004692 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004694 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304696 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 break;
4698 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004699 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304701 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 break;
4703 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004704 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 // For right now, I assume setASSOCIATE() has passed in the bssid.
4706 vos_mem_copy(PMKIDCache[i].BSSID,
4707 pBssid, ETHER_ADDR_LEN);
4708 vos_mem_copy(PMKIDCache[i].PMKID,
4709 dot11RSNIE.pmkid[i],
4710 CSR_RSN_PMKID_SIZE);
4711 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004712
4713 if (updatePMKCache)
4714 {
4715 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004716 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004717 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07004718 // Finally set the PMKSA ID Cache in CSR
4719 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
4720 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304721 dot11RSNIE.pmkid_count,
4722 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07004723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 }
4725 else if (gen_ie[0] == DOT11F_EID_WPA)
4726 {
4727 // Validity checks
4728 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
4729 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
4730 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304731 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
4732 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 return -EINVAL;
4734 }
4735 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07004736 pRsnIe = gen_ie + 2 + 4;
4737 RSNIeLen = gen_ie_len - (2 + 4);
4738 // Unpack the WPA IE
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304739 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304740 pRsnIe, RSNIeLen, &dot11WPAIE);
4741 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304742 {
4743 hddLog(LOGE,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304744 FL("Invalid RSN IE: parse status %d"), status);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304745 return -EINVAL;
4746 }
4747
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 // Copy out the encryption and authentication types
4749 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004750 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004752 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 //dot11WPAIE.auth_suite_count
4754 // Just translate the FIRST one
4755 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
4756 //dot11WPAIE.unicast_cipher_count
4757 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
4758 //dot11WPAIE.unicast_cipher_count
4759 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
4760 }
4761 else
4762 {
4763 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004764 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 }
4766 return 0;
4767}
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304768
4769/**
4770 * hdd_set_def_rsne_override() - set default encryption type and auth type
4771 * in profile.
4772 * @roam_profile: pointer to adapter
4773 * @auth_type: pointer to auth type
4774 *
4775 * Set default value of encryption type and auth type in profile to
4776 * search the AP using filter, as in force_rsne_override the RSNIE can be
4777 * currupt and we might not get the proper encryption type and auth type
4778 * while parsing the RSNIE.
4779 *
4780 * Return: void
4781 */
4782static void hdd_set_def_rsne_override(
4783 tCsrRoamProfile *roam_profile, eCsrAuthType *auth_type)
4784{
4785 hddLog( LOG1, FL("Set def values in roam profile"));
4786 roam_profile->MFPCapable = roam_profile->MFPEnabled;
4787 roam_profile->EncryptionType.numEntries = 2;
4788 roam_profile->mcEncryptionType.numEntries = 2;
4789 /* Use the cipher type in the RSN IE */
4790 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
4791 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
4792 roam_profile->mcEncryptionType.encryptionType[0] =
4793 eCSR_ENCRYPT_TYPE_AES;
4794 roam_profile->mcEncryptionType.encryptionType[1] =
4795 eCSR_ENCRYPT_TYPE_TKIP;
4796 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
4797}
4798
Jeff Johnson295189b2012-06-20 16:38:30 -07004799int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
4800{
4801 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4802 v_U32_t status = 0;
4803 eCsrEncryptionType RSNEncryptType;
4804 eCsrEncryptionType mcRSNEncryptType;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304805 hdd_context_t *hdd_ctx;
Chet Lanctot186b5732013-03-18 10:26:30 -07004806#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304807 u_int8_t RSNMfpRequired = 0;
4808 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07004809#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 struct ether_addr bSsid; // MAC address of assoc peer
4811 // MAC address of assoc peer
4812 // But, this routine is only called when we are NOT associated.
4813 vos_mem_copy(bSsid.ether_addr_octet,
4814 pWextState->roamProfile.BSSIDs.bssid,
4815 sizeof(bSsid.ether_addr_octet));
4816 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
4817 {
4818 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07004819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 else
4821 {
4822 return 0;
4823 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304824
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 // The actual processing may eventually be more extensive than this.
4826 // Right now, just consume any PMKIDs that are sent in by the app.
4827 status = hdd_ProcessGENIE(pAdapter,
4828 &bSsid, // MAC address of assoc peer
4829 &RSNEncryptType,
4830 &mcRSNEncryptType,
4831 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004832#ifdef WLAN_FEATURE_11W
4833 &RSNMfpRequired,
4834 &RSNMfpCapable,
4835#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 pWextState->WPARSNIE[1]+2,
4837 pWextState->WPARSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 if (status == 0)
4840 {
4841 // Now copy over all the security attributes you have parsed out
4842 pWextState->roamProfile.EncryptionType.numEntries = 1;
4843 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
4846 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07004847
Shailender Karmuchi642e9812013-05-30 14:34:49 -07004848 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
4849 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
4850 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
4851 {
4852 /*For wpa none supplicant sends the WPA IE with unicast cipher as
4853 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
4854 either AES/TKIP based on group cipher configuration
4855 mentioned in the wpa_supplicant.conf.*/
4856
4857 /*Set the unicast cipher same as multicast cipher*/
4858 pWextState->roamProfile.EncryptionType.encryptionType[0]
4859 = mcRSNEncryptType;
4860 }
4861
Chet Lanctot186b5732013-03-18 10:26:30 -07004862#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304863 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
4864 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07004865 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
4866 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
4867#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304868 hddLog( LOG1,
4869 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
4870 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304871 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004872 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304873
4874 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4875 if (hdd_ctx->force_rsne_override &&
4876 (pWextState->WPARSNIE[0] == DOT11F_EID_RSN)) {
4877 hddLog(LOG1,
4878 FL("Test mode enabled set def Auth and enc type. RSN IE passed in connect req:"));
4879 vos_trace_hex_dump(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4880 pWextState->roamProfile.pRSNReqIE,
4881 pWextState->roamProfile.nRSNReqIELength);
4882
4883 pWextState->roamProfile.force_rsne_override = true;
4884 hddLog(LOG1,
4885 FL("MFPEnabled %d"), pWextState->roamProfile.MFPEnabled);
4886 /*
4887 * Reset MFPEnabled if testmode RSNE passed doesnt have MFPR
4888 * or MFPC bit set
4889 */
4890 if (pWextState->roamProfile.MFPEnabled &&
4891 !(pWextState->roamProfile.MFPRequired ||
4892 pWextState->roamProfile.MFPCapable)) {
4893 hddLog( LOG1,FL("Reset MFPEnabled"));
4894 pWextState->roamProfile.MFPEnabled = 0;
4895 }
4896
4897 /* If parsing failed set the def value for the roam profile */
4898 if (status)
4899 hdd_set_def_rsne_override(&pWextState->roamProfile,
4900 RSNAuthType);
4901 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304902 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004903}
4904int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
4905{
4906 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4907 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
4908 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4909 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004910
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004912 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004913
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 switch( pHddStaCtx->conn_info.authType)
4915 {
4916 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Abhinav Kumar62801ba2018-09-19 12:14:14 +05304917 case eCSR_AUTH_TYPE_AUTOSWITCH:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004918#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 case eCSR_AUTH_TYPE_CCKM_WPA:
4920 case eCSR_AUTH_TYPE_CCKM_RSN:
4921#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004922 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4923
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004925 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004927
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004928#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004929 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4930 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4931 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004932 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004933 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4934 } else
4935 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004936 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004937 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 } else
4939#endif
4940 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4941 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004942 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4943 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4945 == IW_AUTH_KEY_MGMT_PSK) {
4946 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004947 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 }
4951 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004952#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004953 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4954 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4955 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004956 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004957 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004959 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004960 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004961 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 } else
4963#endif
4964
4965#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004966 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4967 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004969 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004970 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004971 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4973 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004974 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 } else
4976#endif
4977
Chet Lanctot186b5732013-03-18 10:26:30 -07004978#ifdef WLAN_FEATURE_11W
4979 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4980 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4981 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304982 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4983 pRoamProfile->AuthType.authType[0] =
4984 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4985 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004986#endif
4987
Shailender Karmuchia734f332013-04-19 14:02:48 -07004988 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004990 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4991 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4993 == IW_AUTH_KEY_MGMT_PSK) {
4994 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004995 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004999 break;
5000
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005002
5003 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05305005 case eCSR_AUTH_TYPE_SAE:
5006 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5007 break;
5008
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005010
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005011#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08005012 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005013#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5015 break;
5016 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005017
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005019 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005020
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 EXIT();
5022 return 0;
5023}
5024
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05305025/**
5026 * hdd_rx_fwd_eapol() - forward cached eapol frames
5027 * @vosContext : pointer to vos global context
5028 * @pVosPacket: pointer to vos packet
5029 *
5030 * Return: None
5031 *
5032 */
5033void hdd_assoc_registerFwdEapolCB(void *pContext)
5034{
5035 WLANTL_RegisterFwdEapol(pContext, hdd_rx_fwd_eapol);
5036}
5037
Jeff Johnson295189b2012-06-20 16:38:30 -07005038/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005039
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305040 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07005042 to the CSR roam profile.
5043
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 \param - dev - Pointer to the net device.
5045 - info - Pointer to the iw_request_info.
5046 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005047 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005049
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 --------------------------------------------------------------------------*/
5051
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305052int __iw_set_essid(struct net_device *dev,
5053 struct iw_request_info *info,
5054 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005055{
5056 v_U32_t status = 0;
5057 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305058 hdd_adapter_t *pAdapter;
5059 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005060 v_U32_t roamId;
5061 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305063 tHalHandle hHal;
5064 hdd_station_ctx_t *pHddStaCtx;
5065 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005066
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305068 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5069 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05305071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305072 "%s: Adapter is NULL",__func__);
5073 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 }
5075
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305076 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5077 ret = wlan_hdd_validate_context(pHddCtx);
5078 if (0 != ret)
5079 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305080 return ret;
5081 }
5082
5083 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5084 if (NULL == hHal)
5085 {
5086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5087 "%s: Hal Context is NULL",__func__);
5088 return -EINVAL;
5089 }
5090 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5091 if (NULL == pHddStaCtx)
5092 {
5093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5094 "%s: STA Context is NULL",__func__);
5095 return -EINVAL;
5096 }
5097 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5098 if (NULL == pWextState)
5099 {
5100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5101 "%s: pWextState is NULL",__func__);
5102 return -EINVAL;
5103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
5105 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
5106 return -EBUSY;
5107 }
5108 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
5109 return -EINVAL;
5110 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005111
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305112 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
5113 return -EINVAL;
5114
Agrawal Ashishc407f192017-01-23 17:18:35 +05305115 /*Try disconnecting if already in connected state*/
5116 status = wlan_hdd_try_disconnect(pAdapter);
5117 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 {
Agrawal Ashishc407f192017-01-23 17:18:35 +05305119 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
5120 " connection"));
5121 return -EALREADY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005122 }
5123 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07005124 /** when cfg80211 defined, wpa_supplicant wext driver uses
5125 zero-length, null-string ssid for force disconnection.
5126 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 driver MUST return success */
5128 if ( 0 == wrqu->essid.length ) {
5129 return 0;
5130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005131
5132 status = hdd_wmm_get_uapsd_mask(pAdapter,
5133 &pWextState->roamProfile.uapsd_mask);
5134 if (VOS_STATUS_SUCCESS != status)
5135 {
5136 pWextState->roamProfile.uapsd_mask = 0;
5137 }
5138 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005139
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005141
5142 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
5144 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
5145 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005146
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 //set gen ie
5148 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5149
5150 //set auth
5151 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5152 }
5153#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005154 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005155 if (pAdapter->wapi_info.nWapiMode)
5156 {
5157 switch (pAdapter->wapi_info.wapiAuthMode)
5158 {
5159 case WAPI_AUTH_MODE_PSK:
5160 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005161 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 pRoamProfile->AuthType.numEntries = 1;
5163 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5164 break;
5165 }
5166 case WAPI_AUTH_MODE_CERT:
5167 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005168 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 pRoamProfile->AuthType.numEntries = 1;
5170 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5171 break;
5172 }
5173 } // End of switch
5174 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5175 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5176 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005177 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005178 pRoamProfile->EncryptionType.numEntries = 1;
5179 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5180 pRoamProfile->mcEncryptionType.numEntries = 1;
5181 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5182 }
5183 }
5184#endif /* FEATURE_WLAN_WAPI */
5185 /* if previous genIE is not NULL, update AssocIE */
5186 if (0 != pWextState->genIE.length)
5187 {
5188 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
5189 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
5190 pWextState->genIE.length);
5191 pWextState->assocAddIE.length = pWextState->genIE.length;
5192 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5193 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5194
5195 /* clear previous genIE after use it */
5196 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
5197 }
5198
5199 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
5200 pWextState->roamProfile.bWPSAssociation = FALSE;
5201
5202 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5203 pWextState->roamProfile.nAddIEAssocLength))
5204 pWextState->roamProfile.bWPSAssociation = TRUE;
5205
5206
5207 // Disable auto BMPS entry by PMC until DHCP is done
5208 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
5209
Shailender Karmuchia734f332013-04-19 14:02:48 -07005210 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005212
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005213 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
5214 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005215 hdd_select_cbmode(pAdapter,
5216 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
5217 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305218 /*
5219 * Change conn_state to connecting before sme_RoamConnect(),
5220 * because sme_RoamConnect() has a direct path to call
5221 * hdd_smeRoamCallback(), which will change the conn_state
5222 * If direct path, conn_state will be accordingly changed
5223 * to NotConnected or Associated by either
5224 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
5225 * in sme_RoamCallback()
5226 * if sme_RomConnect is to be queued,
5227 * Connecting state will remain until it is completed.
5228 *
5229 * If connection state is not changed,
5230 * connection state will remain in eConnectionState_NotConnected state.
5231 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
5232 * if conn state is eConnectionState_NotConnected.
5233 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5234 * informed of connect result indication which is an issue.
5235 */
5236 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5237 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
5238 {
5239 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5240 FL("Set HDD connState to eConnectionState_Connecting"));
5241 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5242 eConnectionState_Connecting);
5243 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005244 status = sme_RoamConnect( hHal,pAdapter->sessionId,
5245 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305246
5247 if ((eHAL_STATUS_SUCCESS != status) &&
5248 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5249 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5250 {
5251 hddLog(VOS_TRACE_LEVEL_ERROR,
5252 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
5253 pAdapter->sessionId, status);
5254 /* change back to NotAssociated */
5255 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5256 eConnectionState_NotConnected);
5257 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005258 pRoamProfile->ChannelInfo.ChannelList = NULL;
5259 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005260
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005261 EXIT();
5262 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005263}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005264
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305265int iw_set_essid(struct net_device *dev,
5266 struct iw_request_info *info,
5267 union iwreq_data *wrqu, char *extra)
5268{
5269 int ret;
5270
5271 vos_ssr_protect(__func__);
5272 ret = __iw_set_essid(dev, info, wrqu, extra);
5273 vos_ssr_unprotect(__func__);
5274
5275 return ret;
5276}
5277
Jeff Johnson295189b2012-06-20 16:38:30 -07005278/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005279
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305280 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005282
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 \param - dev - Pointer to the net device.
5284 - info - Pointer to the iw_request_info.
5285 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005286 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005288
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305290int __iw_get_essid(struct net_device *dev,
5291 struct iw_request_info *info,
5292 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005293{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305294 hdd_adapter_t *pAdapter;
5295 hdd_context_t *pHddCtx;
5296 hdd_wext_state_t *wextBuf;
5297 hdd_station_ctx_t *pHddStaCtx;
5298 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305299
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 ENTER();
5301
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305302 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5303 if (NULL == pAdapter)
5304 {
5305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5306 "%s: Adapter is NULL",__func__);
5307 return -EINVAL;
5308 }
5309
5310 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5311 ret = wlan_hdd_validate_context(pHddCtx);
5312 if (0 != ret)
5313 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305314 return ret;
5315 }
5316
5317 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5318 if (NULL == pHddStaCtx)
5319 {
5320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5321 "%s: STA Context is NULL",__func__);
5322 return -EINVAL;
5323 }
5324
5325 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5326 if (NULL == wextBuf)
5327 {
5328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5329 "%s: wextBuf is NULL",__func__);
5330 return -EINVAL;
5331 }
5332
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5334 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5335 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
5336 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
5337 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
5338 {
5339 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5340 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
5341 dwrq->flags = 1;
5342 } else {
5343 memset(extra, 0, dwrq->length);
5344 dwrq->length = 0;
5345 dwrq->flags = 0;
5346 }
5347 EXIT();
5348 return 0;
5349}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305350
5351int iw_get_essid(struct net_device *dev,
5352 struct iw_request_info *info,
5353 struct iw_point *dwrq, char *extra)
5354{
5355 int ret;
5356
5357 vos_ssr_protect(__func__);
5358 ret = __iw_get_essid(dev, info, dwrq, extra);
5359 vos_ssr_unprotect(__func__);
5360
5361 return ret;
5362}
Jeff Johnson295189b2012-06-20 16:38:30 -07005363/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005364
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305365 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005367
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 \param - dev - Pointer to the net device.
5369 - info - Pointer to the iw_request_info.
5370 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005371 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005373
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305375int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
5376 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005377{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305378 hdd_adapter_t *pAdapter;
5379 hdd_context_t *pHddCtx;
5380 hdd_wext_state_t *pWextState;
5381 hdd_station_ctx_t *pHddStaCtx;
5382 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005383 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305385 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005386
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005388
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305389 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5390 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005391 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5393 "%s: Adapter is NULL",__func__);
5394 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005395 }
5396
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305397 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5398 ret = wlan_hdd_validate_context(pHddCtx);
5399 if (0 != ret)
5400 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305401 return ret;
5402 }
5403
5404 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5405 if (NULL == pHddStaCtx)
5406 {
5407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5408 "%s: STA Context is NULL",__func__);
5409 return -EINVAL;
5410 }
5411
5412 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5413 if (NULL == pWextState)
5414 {
5415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5416 "%s: pWextState is NULL",__func__);
5417 return -EINVAL;
5418 }
5419
5420 pRoamProfile = &pWextState->roamProfile;
5421
Jeff Johnson295189b2012-06-20 16:38:30 -07005422 switch(wrqu->param.flags & IW_AUTH_INDEX)
5423 {
5424 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005425
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005427
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005429
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 case IW_AUTH_CIPHER_PAIRWISE:
5431 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005432 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5436 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5439 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005440 }
5441
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005443
5444 if( (IW_AUTH_KEY_MGMT_802_1X
5445 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
5447 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005448 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 else
5450 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005451 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005454
5455 if( ( IW_AUTH_KEY_MGMT_802_1X
5456 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5458 /*Dynamic WEP key*/
5459 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5460 else
5461 /*Static WEP key*/
5462 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005463
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 }
5465 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005466
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005468 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 return -EINVAL;
5470 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005471
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 pRoamProfile->EncryptionType.numEntries = 1;
5473 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 break;
5476 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005477 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5479 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5480 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005481
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5483 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5484 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005485
5486 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5488 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005489
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005491
5492 if( ( IW_AUTH_KEY_MGMT_802_1X
5493 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5494 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5495
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005497
5498 else
5499 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005501
5502 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
5503 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005505 if( ( IW_AUTH_KEY_MGMT_802_1X
5506 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5508 {
5509 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5510 }
5511 else
5512 {
5513 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5514 }
5515 }
5516 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005517
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005519 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 return -EINVAL;
5521 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005522
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 pRoamProfile->mcEncryptionType.numEntries = 1;
5524 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
5525 }
5526 break;
5527
5528 case IW_AUTH_80211_AUTH_ALG:
5529 {
5530 /*Save the auth algo here and set auth type to SME Roam profile
5531 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005532 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005534
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5536 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5537
5538 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
5539 /*Not supported*/
5540 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5541 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5542 }
5543 break;
5544
5545 case IW_AUTH_KEY_MGMT:
5546 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005547#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005548#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5549 /*Check for CCKM AKM type */
5550 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005551 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
5552 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005553 /* Set the CCKM bit in authKeyMgmt */
5554 /* Right now, this breaks all ref to authKeyMgmt because our
5555 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 */
5557 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5558 /*Set the key management to 802.1X*/
5559 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005560 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5562 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
5563 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5564 /*Save the key management*/
5565 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5566 //pWextState->authKeyMgmt = wrqu->param.value;
5567 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5568 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5569 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5570 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
5571 /*Save the key management anyway*/
5572 pWextState->authKeyMgmt = wrqu->param.value;
5573 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
5574 /*Save the key management*/
5575 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5576 //pWextState->authKeyMgmt = wrqu->param.value;
5577 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5578 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5579 }
5580#else
5581 /*Save the key management*/
5582 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005583#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 }
5585 break;
5586
5587 case IW_AUTH_TKIP_COUNTERMEASURES:
5588 {
5589 if(wrqu->param.value) {
5590 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5591 "Counter Measure started %d", wrqu->param.value);
5592 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
5593 }
5594 else {
5595 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5596 "Counter Measure stopped=%d", wrqu->param.value);
5597 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
5598 }
5599 }
5600 break;
5601 case IW_AUTH_DROP_UNENCRYPTED:
5602 case IW_AUTH_WPA_ENABLED:
5603 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5604 case IW_AUTH_ROAMING_CONTROL:
5605 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005606
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005608
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005609 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 wrqu->param.flags & IW_AUTH_INDEX);
5611 break;
5612 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005613
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 EXIT();
5615 return 0;
5616}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305617
5618int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5619 union iwreq_data *wrqu, char *extra)
5620{
5621 int ret;
5622
5623 vos_ssr_protect(__func__);
5624 ret = __iw_set_auth(dev, info, wrqu, extra);
5625 vos_ssr_unprotect(__func__);
5626
5627 return ret;
5628}
5629
Jeff Johnson295189b2012-06-20 16:38:30 -07005630/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005631
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305632 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005634
Jeff Johnson295189b2012-06-20 16:38:30 -07005635 \param - dev - Pointer to the net device.
5636 - info - Pointer to the iw_request_info.
5637 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005638 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005640
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305642int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5643 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005644{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305645 hdd_adapter_t* pAdapter;
5646 hdd_wext_state_t *pWextState;
5647 tCsrRoamProfile *pRoamProfile;
5648 hdd_context_t *pHddCtx;
5649 int ret = 0;
5650
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005652
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305653 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5654 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005655 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5657 "%s: Adapter is NULL",__func__);
5658 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005659 }
5660
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305661 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5662 ret = wlan_hdd_validate_context(pHddCtx);
5663 if (0 != ret)
5664 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305665 return ret;
5666 }
5667
5668 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5669 if (NULL == pWextState)
5670 {
5671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5672 "%s: pWextState is NULL",__func__);
5673 return -EINVAL;
5674 }
5675 pRoamProfile = &pWextState->roamProfile;
5676
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 switch(pRoamProfile->negotiatedAuthType)
5678 {
5679 case eCSR_AUTH_TYPE_WPA_NONE:
5680 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5681 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
5682 break;
5683 case eCSR_AUTH_TYPE_WPA:
5684 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5685 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
5686 break;
5687#ifdef WLAN_FEATURE_VOWIFI_11R
5688 case eCSR_AUTH_TYPE_FT_RSN:
5689#endif
5690 case eCSR_AUTH_TYPE_RSN:
5691 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5692 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
5693 break;
5694 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5695 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5696 break;
5697 case eCSR_AUTH_TYPE_SHARED_KEY:
5698 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
5699 break;
5700 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005701 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5703 break;
5704 case eCSR_AUTH_TYPE_AUTOSWITCH:
5705 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5706 break;
5707 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305708 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5710 return -EIO;
5711#ifdef WLAN_FEATURE_VOWIFI_11R
5712 case eCSR_AUTH_TYPE_FT_RSN_PSK:
5713#endif
5714 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07005715#ifdef WLAN_FEATURE_11W
5716 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05305717 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07005718#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05305719 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5721 return -EIO;
5722 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305723 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5725 return -EIO;
5726 }
5727 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
5728 {
5729 switch(pRoamProfile->negotiatedUCEncryptionType)
5730 {
5731 case eCSR_ENCRYPT_TYPE_NONE:
5732 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5733 break;
5734 case eCSR_ENCRYPT_TYPE_WEP40:
5735 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5736 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5737 break;
5738 case eCSR_ENCRYPT_TYPE_TKIP:
5739 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5740 break;
5741 case eCSR_ENCRYPT_TYPE_WEP104:
5742 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5743 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5744 break;
5745 case eCSR_ENCRYPT_TYPE_AES:
5746 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5747 break;
5748 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305749 hddLog(LOG1, "%s called with unknown auth type %d ",
5750 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 return -EIO;
5752 }
5753 }
5754
Shailender Karmuchia734f332013-04-19 14:02:48 -07005755 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 {
5757 switch(pRoamProfile->negotiatedMCEncryptionType)
5758 {
5759 case eCSR_ENCRYPT_TYPE_NONE:
5760 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5761 break;
5762 case eCSR_ENCRYPT_TYPE_WEP40:
5763 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5764 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5765 break;
5766 case eCSR_ENCRYPT_TYPE_TKIP:
5767 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5768 break;
5769 case eCSR_ENCRYPT_TYPE_WEP104:
5770 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5771 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5772 break;
5773 case eCSR_ENCRYPT_TYPE_AES:
5774 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5775 break;
5776 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305777 hddLog(LOG1, "%s called with unknown auth type %d ",
5778 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 return -EIO;
5780 }
5781 }
5782
5783 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005784 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 EXIT();
5786 return 0;
5787}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305788
5789int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5790 union iwreq_data *wrqu,char *extra)
5791{
5792 int ret;
5793
5794 vos_ssr_protect(__func__);
5795 ret = __iw_get_auth(dev, info, wrqu, extra);
5796 vos_ssr_unprotect(__func__);
5797
5798 return ret;
5799}
5800
Jeff Johnson295189b2012-06-20 16:38:30 -07005801/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005802
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305803 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07005804 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 \param - dev - Pointer to the net device.
5808 - info - Pointer to the iw_request_info.
5809 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005810 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005812
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305814int __iw_set_ap_address(struct net_device *dev,
5815 struct iw_request_info *info,
5816 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005817{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305818 hdd_station_ctx_t *pHddStaCtx;
5819 hdd_adapter_t *pAdapter;
5820 hdd_context_t *pHddCtx;
5821 v_U8_t *pMacAddress = NULL;
5822 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305823
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305825
5826 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5827 if (NULL == pAdapter)
5828 {
5829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5830 "%s: Adapter is NULL", __func__);
5831 return -EINVAL;
5832 }
5833 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5834 ret = wlan_hdd_validate_context(pHddCtx);
5835 if (0 != ret)
5836 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305837 return ret;
5838 }
5839 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5840 if (NULL == pHddStaCtx)
5841 {
5842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5843 "%s: pHddStaCtx is NULL", __func__);
5844 return -EINVAL;
5845 }
5846
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08005848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
5849 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07005851
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305852 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 return 0;
5854}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305855
5856int iw_set_ap_address(struct net_device *dev,
5857 struct iw_request_info *info,
5858 union iwreq_data *wrqu, char *extra)
5859{
5860 int ret;
5861
5862 vos_ssr_protect(__func__);
5863 ret = __iw_set_ap_address(dev, info, wrqu, extra);
5864 vos_ssr_unprotect(__func__);
5865
5866 return ret;
5867}
5868
Jeff Johnson295189b2012-06-20 16:38:30 -07005869/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005870
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305871 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 This function returns the BSSID to the wpa_supplicant
5873 \param - dev - Pointer to the net device.
5874 - info - Pointer to the iw_request_info.
5875 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005876 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005878
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305880int __iw_get_ap_address(struct net_device *dev,
5881 struct iw_request_info *info,
5882 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005883{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305884 hdd_station_ctx_t *pHddStaCtx;
5885 hdd_adapter_t *pAdapter;
5886 hdd_context_t *pHddCtx;
5887 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305888
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 ENTER();
5890
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305891 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5892 if (NULL == pAdapter)
5893 {
5894 hddLog(VOS_TRACE_LEVEL_ERROR,
5895 "%s: Adapter is NULL", __func__);
5896 return -EINVAL;
5897 }
5898 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5899 ret = wlan_hdd_validate_context(pHddCtx);
5900 if (0 != ret)
5901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305902 return ret;
5903 }
5904 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5905 if (NULL == pHddStaCtx)
5906 {
5907 hddLog(VOS_TRACE_LEVEL_ERROR,
5908 "%s: pHddStaCtx is NULL", __func__);
5909 return -EINVAL;
5910 }
5911
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
5913 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
5914 {
Jeff Johnson4416a782013-03-25 14:17:50 -07005915 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 }
5917 else
5918 {
5919 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
5920 }
5921 EXIT();
5922 return 0;
5923}
Jeff Johnsond13512a2012-07-17 11:42:19 -07005924
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305925int iw_get_ap_address(struct net_device *dev,
5926 struct iw_request_info *info,
5927 union iwreq_data *wrqu, char *extra)
5928{
5929 int ret;
5930
5931 vos_ssr_protect(__func__);
5932 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5933 vos_ssr_unprotect(__func__);
5934
5935 return ret;
5936}
5937
Chet Lanctot186b5732013-03-18 10:26:30 -07005938#ifdef WLAN_FEATURE_11W
5939/**---------------------------------------------------------------------------
5940
5941 \brief hdd_indicateUnprotMgmtFrame -
5942 This function forwards the unprotected management frame to the supplicant
5943 \param - pAdapter - Pointer to HDD adapter
5944 - nFrameLength - Length of the unprotected frame being passed
5945 - pbFrames - Pointer to the frame buffer
5946 - frameType - 802.11 frame type
5947 \return - nothing
5948
5949 --------------------------------------------------------------------------*/
5950void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5951 tANI_U32 nFrameLength,
5952 tANI_U8* pbFrames,
5953 tANI_U8 frameType )
5954{
5955 tANI_U8 type = 0;
5956 tANI_U8 subType = 0;
5957
5958 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5959 __func__, frameType, nFrameLength);
5960
5961 /* Sanity Checks */
5962 if (NULL == pAdapter)
5963 {
5964 hddLog( LOGE, FL("pAdapter is NULL"));
5965 return;
5966 }
5967
5968 if (NULL == pAdapter->dev)
5969 {
5970 hddLog( LOGE, FL("pAdapter->dev is NULL"));
5971 return;
5972 }
5973
5974 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5975 {
5976 hddLog( LOGE, FL("pAdapter has invalid magic"));
5977 return;
5978 }
5979
5980 if( !nFrameLength )
5981 {
5982 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
5983 return;
5984 }
5985
5986 if (NULL == pbFrames) {
5987 hddLog( LOGE, FL("pbFrames is NULL"));
5988 return;
5989 }
5990
5991 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5992 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5993
5994 /* Get pAdapter from Destination mac address of the frame */
5995 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5996 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305997#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5998 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5999#else
Chet Lanctot186b5732013-03-18 10:26:30 -07006000 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306001#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006002 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
6003 }
6004 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
6005 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306006#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
6007 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
6008#else
Chet Lanctot186b5732013-03-18 10:26:30 -07006009 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306010#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006011 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
6012 }
6013 else
6014 {
6015 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
6016 return;
6017 }
6018}
6019#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006020
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006021#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006022void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
6023 tANI_U8 state,
6024 tANI_U16 measInterval )
6025{
6026 union iwreq_data wrqu;
6027 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006028 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006029
6030 if (NULL == pAdapter)
6031 return;
6032
6033 // create the event
6034 memset(&wrqu, '\0', sizeof(wrqu));
6035 memset(buf, '\0', sizeof(buf));
6036
6037 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
6038 tid, state, measInterval);
6039
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006040 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006041
6042 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006043 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006044 // send the event
6045 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6046}
6047
6048void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
6049{
6050 union iwreq_data wrqu;
6051 char buf[IW_CUSTOM_MAX + 1];
6052 char *pos = buf;
6053 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6054
6055 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6056 return;
6057
6058 // create the event
6059 memset(&wrqu, '\0', sizeof(wrqu));
6060 memset(buf, '\0', sizeof(buf));
6061
6062 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306063 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
6064 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
6065 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
6066 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006067
6068 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
6069 pos += nBytes;
6070 freeBytes -= nBytes;
6071
6072 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
6073 pos += WNI_CFG_BSSID_LEN;
6074 freeBytes -= WNI_CFG_BSSID_LEN;
6075
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006076 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
6077 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006078
6079 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006080 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006081
6082 // send the event
6083 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6084}
6085
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006086void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006087{
6088 union iwreq_data wrqu;
6089 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006090 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006091
6092 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6093 return;
6094
6095 // create the event
6096 memset(&wrqu, '\0', sizeof(wrqu));
6097 memset(buf, '\0', sizeof(buf));
6098
6099 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
6100
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006101 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006102
6103 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006104 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006105
6106 // send the event
6107 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6108}
6109
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006110void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
6111 const tANI_U16 measurementToken,
6112 const tANI_BOOLEAN flag,
6113 const tANI_U8 numBss)
6114{
6115 union iwreq_data wrqu;
6116 char buf[IW_CUSTOM_MAX];
6117 char *pos = buf;
6118 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6119
6120 memset(&wrqu, '\0', sizeof(wrqu));
6121 memset(buf, '\0', sizeof(buf));
6122
6123 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
6124 numBss);
6125
6126 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
6127 flag, numBss);
6128
6129 wrqu.data.pointer = buf;
6130 wrqu.data.length = nBytes;
6131 // send the event
6132 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6133}
6134
6135
6136static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006137 const tCsrRoamInfo *pRoamInfo)
6138{
6139 union iwreq_data wrqu;
6140 char buf[IW_CUSTOM_MAX + 1];
6141 char *pos = buf;
6142 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6143 tANI_U8 i = 0, len = 0;
6144 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
6145 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006146 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
6147 tANI_U8 ieLenByte = 1;
6148 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
6149#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006150
6151 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6152 return;
6153
6154 /* Custom event can pass maximum of 256 bytes of data,
6155 based on the IE len we need to identify how many BSS info can
6156 be filled in to custom event data */
6157 /*
6158 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
6159 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
6160 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
6161 */
6162
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006163 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006164 {
6165 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
6166 /* If the measurement is none and no scan results found,
6167 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006168 hdd_indicateEseBcnReportNoResults(pAdapter,
6169 pRoamInfo->pEseBcnReportRsp->measurementToken,
6170 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006171 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006172 }
6173 else
6174 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006175 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006176 {
6177 memset(&wrqu, '\0', sizeof(wrqu));
6178 memset(buf, '\0', sizeof(buf));
6179 tot_bcn_ieLen = 0;
6180 sendBss = 0;
6181 pos = buf;
6182 freeBytes = IW_CUSTOM_MAX;
6183
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006184 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006185 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006186 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
6187 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006188 {
6189 break;
6190 }
6191 tot_bcn_ieLen += len;
6192 sendBss++;
6193 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
6194 "IeLength(%d) Length of Ie(%d) totLen(%d)",
6195 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006196 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006197 tot_bcn_ieLen);
6198 }
6199
6200 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
6201 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006202 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6203 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006204
6205 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006206 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6207 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006208 pos += nBytes;
6209 freeBytes -= nBytes;
6210
6211 /* Copy total Beacon report data length */
6212 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
6213 pos += sizeof(tot_bcn_ieLen);
6214 freeBytes -= sizeof(tot_bcn_ieLen);
6215
6216 for (i = 0; i < sendBss; i++)
6217 {
6218 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306219 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
6220 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006221 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006222 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
6223 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
6224 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
6225 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
6226 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
6227 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
6228 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
6229 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
6230 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
6231 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
6232 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
6233 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
6234 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
6235 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
6236 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
6237 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006238
6239 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006240 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
6241 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006242 pos += len;
6243 freeBytes -= len;
6244
6245 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006246 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006247 vos_mem_copy(pos, (char*)&len, sizeof(len));
6248 pos += sizeof(len);
6249 freeBytes -= sizeof(len);
6250
6251 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006252 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006253 pos += len;
6254 freeBytes -= len;
6255 }
6256
6257 wrqu.data.pointer = buf;
6258 wrqu.data.length = strlen(buf);
6259
6260 // send the event
6261 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6262 lastSent += sendBss;
6263 }
6264 }
6265}
6266
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006267#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006268
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306269hdd_adapter_t *hdd_get_sta_connection_in_progress(hdd_context_t *hdd_ctx)
6270{
6271 hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
6272 hdd_adapter_t *adapter = NULL;
6273 VOS_STATUS status;
6274 hdd_station_ctx_t *hdd_sta_ctx;
6275
6276 if (!hdd_ctx) {
6277 hddLog(LOGE, FL("HDD context is NULL"));
6278 return NULL;
6279 }
6280
6281 status = hdd_get_front_adapter(hdd_ctx, &adapter_node);
6282 while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
6283 adapter = adapter_node->pAdapter;
6284 if (!adapter)
6285 goto end;
6286
6287 if ((WLAN_HDD_INFRA_STATION == adapter->device_mode) ||
6288 (WLAN_HDD_P2P_CLIENT == adapter->device_mode) ||
6289 (WLAN_HDD_P2P_DEVICE == adapter->device_mode)) {
6290 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6291 if (eConnectionState_Connecting ==
6292 hdd_sta_ctx->conn_info.connState) {
6293 hddLog(LOG1, FL("session_id %d: Connection is in progress"),
6294 adapter->sessionId);
6295 return adapter;
6296 } else if ((eConnectionState_Associated ==
6297 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +05306298 sme_is_sta_key_exchange_in_progress(
6299 hdd_ctx->hHal, adapter->sessionId)) {
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306300 hddLog(LOG1, FL("session_id %d: Key exchange is in progress"),
6301 adapter->sessionId);
6302 return adapter;
6303 }
6304 }
6305end:
6306 status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next);
6307 adapter_node = next;
6308 }
6309 return NULL;
6310}
6311