blob: bdd2d938e11de811338f88bec3fb7592a2996aab [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**
20 * DOC: wlan_hdd_assoc.c
21 *
22 * WLAN Host Device Driver implementation
23 *
24 */
25
26#include "wlan_hdd_includes.h"
27#include <ani_global.h>
28#include "dot11f.h"
29#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053030#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031#include <linux/ieee80211.h>
32#include <linux/wireless.h>
33#include <linux/etherdevice.h>
34#include <net/cfg80211.h>
35#include "wlan_hdd_cfg80211.h"
36#include "csr_inside_api.h"
37#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#include "sme_api.h"
40#include "wlan_hdd_hostapd.h"
Jeff Johnson8bb61112018-03-31 13:33:54 -070041#include <wlan_hdd_green_ap.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070043#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070044#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include <cds_sched.h>
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -080046#include "wlan_policy_mgr_api.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053047#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070049#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070050#include <cdp_txrx_cmn.h>
51#include <cdp_txrx_flow_ctrl_legacy.h>
52#include <cdp_txrx_peer_ops.h>
53#include <cdp_txrx_misc.h>
Kabilan Kannan256e3182017-05-02 16:02:37 -070054#include <cdp_txrx_ctrl.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053055#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080056#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080057#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053058#include "wlan_pmo_ucfg_api.h"
Yu Wang000dc2f2017-05-26 17:38:48 +080059#include "wlan_hdd_tsf.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070060#include "wlan_utility.h"
Wu Gaoc02785d2017-09-07 18:17:13 +080061#include "wlan_p2p_ucfg_api.h"
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +053062#include "wlan_ipa_ucfg_api.h"
Qiwei Cai3719efe2018-06-11 21:09:29 +080063#include "wlan_hdd_stats.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Alok Kumarb64650c2018-03-23 17:05:11 +053065#include "wlan_hdd_nud_tracking.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066/* These are needed to recognize WPA and RSN suite types */
67#define HDD_WPA_OUI_SIZE 4
68#define HDD_RSN_OUI_SIZE 4
69uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
70uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
71uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
72uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
73uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
74uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
75
76#ifdef FEATURE_WLAN_ESE
77/* CCKM */
78uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
79/* CCKM */
80uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
81#endif /* FEATURE_WLAN_ESE */
82
83/* group cipher */
84uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
85
86/* WEP-40 or RSN */
87uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
88
89/* TKIP or RSN-PSK */
90uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
91
92/* Reserved */
93uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
94
95/* AES-CCMP */
96uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
97
98/* WEP-104 */
99uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
100
101#ifdef WLAN_FEATURE_11W
102/* RSN-PSK-SHA256 */
103uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
104
105/* RSN-8021X-SHA256 */
106uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
107#endif
108
Mukul Sharma05504ac2017-06-08 12:35:53 +0530109/* AES-GCMP-128 */
110uint8_t ccp_rsn_oui09[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x08 };
111
112/* AES-GCMP-256 */
113uint8_t ccp_rsn_oui0a[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x09 };
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +0530114#ifdef WLAN_FEATURE_FILS_SK
115uint8_t ccp_rsn_oui_0e[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0E};
116uint8_t ccp_rsn_oui_0f[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0F};
117uint8_t ccp_rsn_oui_10[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x10};
118uint8_t ccp_rsn_oui_11[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x11};
119#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +0530120uint8_t ccp_rsn_oui_12[HDD_RSN_OUI_SIZE] = {0x50, 0x6F, 0x9A, 0x02};
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +0530121uint8_t ccp_rsn_oui_0b[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0B};
122uint8_t ccp_rsn_oui_0c[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0C};
Mukul Sharma05504ac2017-06-08 12:35:53 +0530123
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +0530124/* OWE https://tools.ietf.org/html/rfc8110 */
125uint8_t ccp_rsn_oui_18[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x12};
126
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530127#ifdef WLAN_FEATURE_SAE
128uint8_t ccp_rsn_oui_80[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x08};
129uint8_t ccp_rsn_oui_90[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x09};
130#endif
131
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800132/* Offset where the EID-Len-IE, start. */
133#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
134#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135
136#define BEACON_FRAME_IES_OFFSET 12
137#define HDD_PEER_AUTHORIZE_WAIT 10
138
139/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700140 * beacon_filter_table - table of IEs used for beacon filtering
141 */
142static const int beacon_filter_table[] = {
143 SIR_MAC_DS_PARAM_SET_EID,
144 SIR_MAC_ERP_INFO_EID,
145 SIR_MAC_EDCA_PARAM_SET_EID,
146 SIR_MAC_QOS_CAPABILITY_EID,
147 SIR_MAC_HT_INFO_EID,
148 SIR_MAC_VHT_OPMODE_EID,
149 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700150#ifdef WLAN_FEATURE_11AX_BSS_COLOR
151 /*
152 * EID: 221 vendor IE is being used temporarily by 11AX
153 * bss-color-change IE till it gets any fixed number. This
154 * vendor EID needs to be replaced with bss-color-change IE
155 * number.
156 */
157 SIR_MAC_EID_VENDOR,
158#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700159};
160
Padma, Santhosh Kumareb90a552018-01-16 19:41:58 +0530161#if defined(WLAN_FEATURE_SAE) && \
162 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
163/**
164 * wlan_hdd_sae_callback() - Sends SAE info to supplicant
165 * @adapter: pointer adapter context
166 * @roam_info: pointer to roam info
167 *
168 * This API is used to send required SAE info to trigger SAE in supplicant.
169 *
170 * Return: None
171 */
172static void wlan_hdd_sae_callback(struct hdd_adapter *adapter,
173 struct csr_roam_info *roam_info)
174{
175 struct hdd_context *hdd_ctx = adapter->hdd_ctx;
176 int flags;
177 struct sir_sae_info *sae_info = roam_info->sae_info;
178 struct cfg80211_external_auth_params params = {0};
179
180 if (wlan_hdd_validate_context(hdd_ctx))
181 return;
182
183 if (!sae_info) {
184 hdd_err("SAE info in NULL");
185 return;
186 }
187
188 flags = cds_get_gfp_flags();
189
190 params.key_mgmt_suite = 0x00;
191 params.key_mgmt_suite |= 0x0F << 8;
192 params.key_mgmt_suite |= 0xAC << 16;
193 params.key_mgmt_suite |= 0x8 << 24;
194
195 params.action = NL80211_EXTERNAL_AUTH_START;
196 qdf_mem_copy(params.bssid, sae_info->peer_mac_addr.bytes,
197 QDF_MAC_ADDR_SIZE);
198 qdf_mem_copy(params.ssid.ssid, sae_info->ssid.ssId,
199 sae_info->ssid.length);
200 params.ssid.ssid_len = sae_info->ssid.length;
201
202 cfg80211_external_auth_request(adapter->dev, &params, flags);
203 hdd_debug("SAE: sent cmd");
204}
205#else
206static inline void wlan_hdd_sae_callback(struct hdd_adapter *adapter,
207 struct csr_roam_info *roam_info)
208{ }
209#endif
210
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700211/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 * hdd_conn_set_authenticated() - set authentication state
Jeff Johnsonba388342017-10-02 13:31:01 -0700213 * @adapter: pointer to the adapter
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530214 * @auth_state: authentication state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800215 *
216 * This function updates the global HDD station context
217 * authentication state.
218 *
219 * Return: none
220 */
221static void
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530222hdd_conn_set_authenticated(struct hdd_adapter *adapter, uint8_t auth_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700224 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530225 char *auth_time;
226 uint32_t time_buffer_size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227
228 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700229 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530230 sta_ctx->conn_info.uIsAuthenticated, auth_state);
231 sta_ctx->conn_info.uIsAuthenticated = auth_state;
232
233 auth_time = sta_ctx->conn_info.auth_time;
234 time_buffer_size = sizeof(sta_ctx->conn_info.auth_time);
235
236 if (auth_state)
237 qdf_get_time_of_the_day_in_hr_min_sec_usec(auth_time,
238 time_buffer_size);
239 else
240 qdf_mem_set(auth_time, 0x00, time_buffer_size);
241
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242}
243
244/**
245 * hdd_conn_set_connection_state() - set connection state
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700246 * @adapter: pointer to the adapter
247 * @conn_state: connection state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 *
249 * This function updates the global HDD station context connection state.
250 *
251 * Return: none
252 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700253void hdd_conn_set_connection_state(struct hdd_adapter *adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700254 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700256 struct hdd_station_ctx *hdd_sta_ctx =
257 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530258 char *connect_time;
259 uint32_t time_buffer_size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260
261 /* save the new connection state */
Jun Wang92cd8362018-07-27 16:52:47 +0800262 hdd_debug("Changed conn state from old:%d to new:%d for dev %s",
263 hdd_sta_ctx->conn_info.connState, conn_state,
264 adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800265
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700266 hdd_tsf_notify_wlan_state_change(adapter,
267 hdd_sta_ctx->conn_info.connState,
268 conn_state);
269 hdd_sta_ctx->conn_info.connState = conn_state;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530270
271 connect_time = hdd_sta_ctx->conn_info.connect_time;
272 time_buffer_size = sizeof(hdd_sta_ctx->conn_info.connect_time);
273 if (conn_state == eConnectionState_Associated)
274 qdf_get_time_of_the_day_in_hr_min_sec_usec(connect_time,
275 time_buffer_size);
276 else
277 qdf_mem_set(connect_time, 0x00, time_buffer_size);
278
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279}
280
281/**
282 * hdd_conn_get_connection_state() - get connection state
Jeff Johnsonba388342017-10-02 13:31:01 -0700283 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 * @pConnState: pointer to connection state
285 *
286 * This function updates the global HDD station context connection state.
287 *
288 * Return: true if (Infra Associated or IBSS Connected)
289 * and sets output parameter pConnState;
290 * false otherwise
291 */
Jeff Johnson435e1b82017-10-07 14:13:10 -0700292static inline bool
293hdd_conn_get_connection_state(struct hdd_station_ctx *sta_ctx,
Dustin Brown0127a732018-07-19 14:06:34 -0700294 eConnectionState *out_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295{
Dustin Brown0127a732018-07-19 14:06:34 -0700296 eConnectionState state = sta_ctx->conn_info.connState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297
Dustin Brown0127a732018-07-19 14:06:34 -0700298 if (out_state)
299 *out_state = state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300
Dustin Brown0127a732018-07-19 14:06:34 -0700301 switch (state) {
302 case eConnectionState_Associated:
303 case eConnectionState_IbssConnected:
304 case eConnectionState_IbssDisconnected:
305 case eConnectionState_NdiConnected:
306 return true;
307 default:
308 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310}
311
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700312bool hdd_is_connecting(struct hdd_station_ctx *hdd_sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313{
314 return hdd_sta_ctx->conn_info.connState ==
315 eConnectionState_Connecting;
316}
317
Jeff Johnsond377dce2017-10-04 10:32:42 -0700318bool hdd_conn_is_connected(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700320 return hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321}
322
Dustin Brown0127a732018-07-19 14:06:34 -0700323bool hdd_adapter_is_connected_sta(struct hdd_adapter *adapter)
324{
325 switch (adapter->device_mode) {
326 case QDF_STA_MODE:
327 case QDF_P2P_CLIENT_MODE:
328 case QDF_NDI_MODE:
329 return hdd_conn_is_connected(&adapter->session.station);
330 default:
331 return false;
332 }
333}
334
Jeff Johnsond377dce2017-10-04 10:32:42 -0700335enum band_info hdd_conn_get_connected_band(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336{
337 uint8_t staChannel = 0;
338
Jeff Johnsond377dce2017-10-04 10:32:42 -0700339 if (eConnectionState_Associated == sta_ctx->conn_info.connState)
340 staChannel = sta_ctx->conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341
342 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700343 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700345 return BAND_5G;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800346 else /* If station is not connected return as BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700347 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348}
349
350/**
351 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
Jeff Johnsond377dce2017-10-04 10:32:42 -0700352 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 * @pConnectedCipherAlgo: pointer to connected cipher algo
354 *
355 * Return: false if any errors encountered, true otherwise
356 */
357static inline bool
Jeff Johnsond377dce2017-10-04 10:32:42 -0700358hdd_conn_get_connected_cipher_algo(struct hdd_station_ctx *sta_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 eCsrEncryptionType *pConnectedCipherAlgo)
360{
Jeff Johnson389e16b2018-05-05 23:32:55 -0700361 bool connected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362
Jeff Johnson389e16b2018-05-05 23:32:55 -0700363 connected = hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364
365 if (pConnectedCipherAlgo)
Jeff Johnsond377dce2017-10-04 10:32:42 -0700366 *pConnectedCipherAlgo = sta_ctx->conn_info.ucEncryptionType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367
Jeff Johnson389e16b2018-05-05 23:32:55 -0700368 return connected;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369}
370
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530371struct hdd_adapter *hdd_get_sta_connection_in_progress(
372 struct hdd_context *hdd_ctx)
373{
374 struct hdd_adapter *adapter = NULL;
375 struct hdd_station_ctx *hdd_sta_ctx;
376
377 if (!hdd_ctx) {
378 hdd_err("HDD context is NULL");
379 return NULL;
380 }
381
382 hdd_for_each_adapter(hdd_ctx, adapter) {
383 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
384 if ((QDF_STA_MODE == adapter->device_mode) ||
385 (QDF_P2P_CLIENT_MODE == adapter->device_mode) ||
386 (QDF_P2P_DEVICE_MODE == adapter->device_mode)) {
387 if (eConnectionState_Connecting ==
388 hdd_sta_ctx->conn_info.connState) {
389 hdd_debug("session_id %d: Connection is in progress",
390 adapter->session_id);
391 return adapter;
392 } else if ((eConnectionState_Associated ==
393 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0a569292018-02-14 15:34:47 +0530394 sme_is_sta_key_exchange_in_progress(
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700395 hdd_ctx->mac_handle,
396 adapter->session_id)) {
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530397 hdd_debug("session_id %d: Key exchange is in progress",
398 adapter->session_id);
399 return adapter;
400 }
401 }
402 }
403 return NULL;
404}
405
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700407 * hdd_remove_beacon_filter() - remove beacon filter
408 * @adapter: Pointer to the hdd adapter
409 *
410 * Return: 0 on success and errno on failure
411 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700412static int hdd_remove_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700413{
414 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700415 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700416
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700417 status = sme_remove_beacon_filter(hdd_ctx->mac_handle,
418 adapter->session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700419 if (!QDF_IS_STATUS_SUCCESS(status)) {
420 hdd_err("sme_remove_beacon_filter() failed");
421 return -EFAULT;
422 }
423
424 return 0;
425}
426
427/**
428 * hdd_add_beacon_filter() - add beacon filter
429 * @adapter: Pointer to the hdd adapter
430 *
431 * Return: 0 on success and errno on failure
432 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700433static int hdd_add_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700434{
435 int i;
436 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
437 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700438 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700439
440 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530441 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700442 (unsigned long int *)ie_map);
443
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700444 status = sme_add_beacon_filter(hdd_ctx->mac_handle,
445 adapter->session_id, ie_map);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700446 if (!QDF_IS_STATUS_SUCCESS(status)) {
447 hdd_err("sme_add_beacon_filter() failed");
448 return -EFAULT;
449 }
450 return 0;
451}
452
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530453void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
454 tDot11fIEHTCaps *roam_ht_cap)
455
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530456{
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530457 uint32_t i, temp_ht_cap;
458
459 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
460
461 if (roam_ht_cap->advCodingCap)
462 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
463 if (roam_ht_cap->supportedChannelWidthSet)
464 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
465 temp_ht_cap = roam_ht_cap->mimoPowerSave &
466 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
467 if (temp_ht_cap)
468 hdd_ht_cap->cap_info |=
469 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
470 if (roam_ht_cap->greenField)
471 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
472 if (roam_ht_cap->shortGI20MHz)
473 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
474 if (roam_ht_cap->shortGI40MHz)
475 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
476 if (roam_ht_cap->txSTBC)
477 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
478 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
479 IEEE80211_HT_CAP_RX_STBC_SHIFT);
480 if (temp_ht_cap)
481 hdd_ht_cap->cap_info |=
482 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
483 if (roam_ht_cap->delayedBA)
484 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
485 if (roam_ht_cap->maximalAMSDUsize)
486 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
487 if (roam_ht_cap->dsssCckMode40MHz)
488 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
489 if (roam_ht_cap->psmp)
490 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
491 if (roam_ht_cap->stbcControlFrame)
492 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
493 if (roam_ht_cap->lsigTXOPProtection)
494 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
495
496 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
497 if (roam_ht_cap->maxRxAMPDUFactor)
498 hdd_ht_cap->ampdu_params_info |=
499 IEEE80211_HT_AMPDU_PARM_FACTOR;
500 temp_ht_cap = roam_ht_cap->mpduDensity &
501 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
502 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
503 if (temp_ht_cap)
504 hdd_ht_cap->ampdu_params_info |=
505 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
506
507 /* 802.11n HT extended capabilities masks */
508 if (roam_ht_cap->pco)
509 hdd_ht_cap->extended_ht_cap_info |=
510 IEEE80211_HT_EXT_CAP_PCO;
511 temp_ht_cap = roam_ht_cap->transitionTime &
512 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
513 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
514 if (temp_ht_cap)
515 hdd_ht_cap->extended_ht_cap_info |=
516 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
517 temp_ht_cap = roam_ht_cap->mcsFeedback &
518 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
519 if (temp_ht_cap)
520 hdd_ht_cap->extended_ht_cap_info |=
521 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
522
523 /* tx_bf_cap_info capabilities */
524 if (roam_ht_cap->txBF)
525 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
526 if (roam_ht_cap->rxStaggeredSounding)
527 hdd_ht_cap->tx_BF_cap_info |=
528 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
529 if (roam_ht_cap->txStaggeredSounding)
530 hdd_ht_cap->tx_BF_cap_info |=
531 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
532 if (roam_ht_cap->rxZLF)
533 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
534 if (roam_ht_cap->txZLF)
535 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
536 if (roam_ht_cap->implicitTxBF)
537 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
538 temp_ht_cap = roam_ht_cap->calibration &
539 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
540 if (temp_ht_cap)
541 hdd_ht_cap->tx_BF_cap_info |=
542 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
543 if (roam_ht_cap->explicitCSITxBF)
544 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
545 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
546 hdd_ht_cap->tx_BF_cap_info |=
547 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
548 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
549 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
550 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
551 if (temp_ht_cap)
552 hdd_ht_cap->tx_BF_cap_info |=
553 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
554 temp_ht_cap =
555 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
556 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
557 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
558 if (temp_ht_cap)
559 hdd_ht_cap->tx_BF_cap_info |=
560 temp_ht_cap <<
561 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
562 temp_ht_cap =
563 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
564 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
565 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
566 if (temp_ht_cap)
567 hdd_ht_cap->tx_BF_cap_info |=
568 temp_ht_cap <<
569 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
570 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
571 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
572 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
573 if (temp_ht_cap)
574 hdd_ht_cap->tx_BF_cap_info |=
575 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
576 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
577 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
578 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
579 if (temp_ht_cap)
580 hdd_ht_cap->tx_BF_cap_info |=
581 temp_ht_cap <<
582 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
583 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
584 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
585 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
586 if (temp_ht_cap)
587 hdd_ht_cap->tx_BF_cap_info |=
588 temp_ht_cap <<
589 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
590
591 /* antenna selection */
592 if (roam_ht_cap->antennaSelection)
593 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
594 if (roam_ht_cap->explicitCSIFeedbackTx)
595 hdd_ht_cap->antenna_selection_info |=
596 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
597 if (roam_ht_cap->antennaIndicesFeedbackTx)
598 hdd_ht_cap->antenna_selection_info |=
599 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
600 if (roam_ht_cap->explicitCSIFeedback)
601 hdd_ht_cap->antenna_selection_info |=
602 ANTENNA_SEL_INFO_EXP_CSI_FB;
603 if (roam_ht_cap->antennaIndicesFeedback)
604 hdd_ht_cap->antenna_selection_info |=
605 ANTENNA_SEL_INFO_ANT_ID_FB;
606 if (roam_ht_cap->rxAS)
607 hdd_ht_cap->antenna_selection_info |=
608 ANTENNA_SEL_INFO_RX_AS;
609 if (roam_ht_cap->txSoundingPPDUs)
610 hdd_ht_cap->antenna_selection_info |=
611 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
612
613 /* mcs data rate */
614 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
615 hdd_ht_cap->mcs.rx_mask[i] =
616 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800617 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530618 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
619 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800620 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530621 roam_ht_cap->supportedMCSSet[12];
622}
623
624#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
625#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
626#define VHT_CAP_RXSTBC_MASK_SHIFT 8
627#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
628#define VHT_CAP_BEAMFORMEE_STS_MASK \
629 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
630#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
631#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
632 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
633#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
634#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
635 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
636#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
637
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530638void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
639 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530640{
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530641 uint32_t temp_vht_cap;
642
643 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
644
645 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
646 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
647 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
648 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
649 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800650 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530651 if (roam_vht_cap->supportedChannelWidthSet &
652 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
653 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
654 hdd_vht_cap->vht_cap_info |=
655 temp_vht_cap <<
656 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
657 if (roam_vht_cap->supportedChannelWidthSet &
658 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
659 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
660 hdd_vht_cap->vht_cap_info |=
661 temp_vht_cap <<
662 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800663 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530664 if (roam_vht_cap->ldpcCodingCap)
665 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
666 if (roam_vht_cap->shortGI80MHz)
667 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
668 if (roam_vht_cap->shortGI160and80plus80MHz)
669 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
670 if (roam_vht_cap->txSTBC)
671 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
672 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
673 VHT_CAP_RXSTBC_MASK_SHIFT);
674 if (temp_vht_cap)
675 hdd_vht_cap->vht_cap_info |=
676 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
677 if (roam_vht_cap->suBeamFormerCap)
678 hdd_vht_cap->vht_cap_info |=
679 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
680 if (roam_vht_cap->suBeamformeeCap)
681 hdd_vht_cap->vht_cap_info |=
682 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
683 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
684 (VHT_CAP_BEAMFORMEE_STS_MASK);
685 if (temp_vht_cap)
686 hdd_vht_cap->vht_cap_info |=
687 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
688 temp_vht_cap = roam_vht_cap->numSoundingDim &
689 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
690 if (temp_vht_cap)
691 hdd_vht_cap->vht_cap_info |=
692 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
693 if (roam_vht_cap->muBeamformerCap)
694 hdd_vht_cap->vht_cap_info |=
695 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
696 if (roam_vht_cap->muBeamformeeCap)
697 hdd_vht_cap->vht_cap_info |=
698 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
699 if (roam_vht_cap->vhtTXOPPS)
700 hdd_vht_cap->vht_cap_info |=
701 IEEE80211_VHT_CAP_VHT_TXOP_PS;
702 if (roam_vht_cap->htcVHTCap)
703 hdd_vht_cap->vht_cap_info |=
704 IEEE80211_VHT_CAP_HTC_VHT;
705 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
706 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
707 if (temp_vht_cap)
708 hdd_vht_cap->vht_cap_info |=
709 temp_vht_cap <<
710 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
711 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
712 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
713 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
714 if (temp_vht_cap)
715 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
716 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
717 if (roam_vht_cap->rxAntPattern)
718 hdd_vht_cap->vht_cap_info |=
719 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
720 if (roam_vht_cap->txAntPattern)
721 hdd_vht_cap->vht_cap_info |=
722 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
723 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
724 hdd_vht_cap->supp_mcs.rx_highest =
725 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
726 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
727 hdd_vht_cap->supp_mcs.tx_highest =
728 ((uint16_t)roam_vht_cap->txSupDataRate);
729}
730
731/* ht param */
732#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
733#define HT_PARAM_SERVICE_INT_GRAN 0xe0
734#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
735
736/* operatinon mode */
737#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
738
739/* stbc_param */
740#define HT_STBC_PARAM_MCS 0x007f
741
742/**
743 * hdd_copy_ht_operation()- copy HT operation element from roam info to
744 * hdd station context.
745 * @hdd_sta_ctx: pointer to hdd station context
746 * @roam_info: pointer to roam info
747 *
748 * Return: None
749 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700750static void hdd_copy_ht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800751 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530752{
753 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
754 struct ieee80211_ht_operation *hdd_ht_ops =
755 &hdd_sta_ctx->conn_info.ht_operation;
756 uint32_t i, temp_ht_ops;
757
758 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
759
760 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
761
762 /* HT_PARAMS */
763 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
764 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
765 if (temp_ht_ops)
766 hdd_ht_ops->ht_param |= temp_ht_ops;
767 else
768 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
769 if (roam_ht_ops->recommendedTxWidthSet)
770 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
771 if (roam_ht_ops->rifsMode)
772 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
773 if (roam_ht_ops->controlledAccessOnly)
774 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
775 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
776 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
777 if (temp_ht_ops)
778 hdd_ht_ops->ht_param |= temp_ht_ops <<
779 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
780
781 /* operation mode */
782 temp_ht_ops = roam_ht_ops->opMode &
783 IEEE80211_HT_OP_MODE_PROTECTION;
784 switch (temp_ht_ops) {
785 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
786 hdd_ht_ops->operation_mode |=
787 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
788 break;
789 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
790 hdd_ht_ops->operation_mode |=
791 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
792 break;
793 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
794 hdd_ht_ops->operation_mode |=
795 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
796 break;
797 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
798 default:
799 hdd_ht_ops->operation_mode |=
800 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
801 }
802 if (roam_ht_ops->nonGFDevicesPresent)
803 hdd_ht_ops->operation_mode |=
804 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
805 if (roam_ht_ops->transmitBurstLimit)
806 hdd_ht_ops->operation_mode |=
807 HT_OP_MODE_TX_BURST_LIMIT;
808 if (roam_ht_ops->obssNonHTStaPresent)
809 hdd_ht_ops->operation_mode |=
810 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
811
812 /* stbc_param */
813 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
814 HT_STBC_PARAM_MCS;
815 if (temp_ht_ops)
816 hdd_ht_ops->stbc_param |= temp_ht_ops;
817 if (roam_ht_ops->dualCTSProtection)
818 hdd_ht_ops->stbc_param |=
819 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
820 if (roam_ht_ops->secondaryBeacon)
821 hdd_ht_ops->stbc_param |=
822 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
823 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
824 hdd_ht_ops->stbc_param |=
825 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
826 if (roam_ht_ops->pcoActive)
827 hdd_ht_ops->stbc_param |=
828 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
829 if (roam_ht_ops->pcoPhase)
830 hdd_ht_ops->stbc_param |=
831 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
832
833 /* basic MCs set */
834 for (i = 0; i < 16; ++i)
835 hdd_ht_ops->basic_set[i] =
836 roam_ht_ops->basicMCSSet[i];
837}
838
Dustin Brown8aef46d2017-08-10 15:44:50 -0700839#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
840static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
841 tDot11fIEVHTOperation *roam_ops)
842{
843 ieee_ops->center_freq_seg0_idx = roam_ops->chanCenterFreqSeg1;
844 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg2;
845}
846#else
847static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
848 tDot11fIEVHTOperation *roam_ops)
849{
850 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg1;
851 ieee_ops->center_freq_seg2_idx = roam_ops->chanCenterFreqSeg2;
852}
853#endif /* KERNEL_VERSION(4, 12, 0) */
854
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530855/**
856 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
857 * hdd station context.
858 * @hdd_sta_ctx: pointer to hdd station context
859 * @roam_info: pointer to roam info
860 *
861 * Return: None
862 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700863static void hdd_copy_vht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800864 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530865{
866 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
867 struct ieee80211_vht_operation *hdd_vht_ops =
868 &hdd_sta_ctx->conn_info.vht_operation;
869
870 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
871
872 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
Dustin Brown8aef46d2017-08-10 15:44:50 -0700873 hdd_copy_vht_center_freq(hdd_vht_ops, roam_vht_ops);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530874 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
875}
876
877
878/**
879 * hdd_save_bss_info() - save connection info in hdd sta ctx
880 * @adapter: Pointer to adapter
881 * @roam_info: pointer to roam info
882 *
883 * Return: None
884 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700885static void hdd_save_bss_info(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -0800886 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530887{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700888 struct hdd_station_ctx *hdd_sta_ctx =
889 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530890
891 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
892 hdd_sta_ctx->conn_info.operationChannel);
893 if (roam_info->vht_caps.present) {
894 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530895 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
896 &roam_info->vht_caps);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530897 } else {
898 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
899 }
900 if (roam_info->ht_caps.present) {
901 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530902 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps,
903 &roam_info->ht_caps);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530904 } else {
905 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
906 }
907 if (roam_info->reassoc)
908 hdd_sta_ctx->conn_info.roam_count++;
909 if (roam_info->hs20vendor_ie.present) {
910 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
911 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
912 &roam_info->hs20vendor_ie,
913 sizeof(roam_info->hs20vendor_ie));
914 } else {
915 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
916 }
917 if (roam_info->ht_operation.present) {
918 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
919 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
920 } else {
921 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
922 }
923 if (roam_info->vht_operation.present) {
924 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
925 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
926 } else {
927 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
928 }
Ashish Kumar Dhanotiya36d19b02018-02-22 00:59:49 +0530929 /* Cache last connection info */
930 qdf_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
931 sizeof(struct connection_info));
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530932}
933
934/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 * hdd_conn_save_connect_info() - save current connection information
Jeff Johnsonba388342017-10-02 13:31:01 -0700936 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -0700937 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 * @eBssType: bss type
939 *
940 * Return: none
941 */
942static void
Jeff Johnson172237b2017-11-07 15:32:59 -0800943hdd_conn_save_connect_info(struct hdd_adapter *adapter,
944 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 eCsrRoamBssType eBssType)
946{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700947 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
949
Jeff Johnsonfd060852017-10-04 10:50:51 -0700950 QDF_ASSERT(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
Jeff Johnsonfd060852017-10-04 10:50:51 -0700952 if (roam_info) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 /* Save the BSSID for the connection */
954 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Jeff Johnsonfd060852017-10-04 10:50:51 -0700955 QDF_ASSERT(roam_info->pBssDesc);
Jeff Johnsond377dce2017-10-04 10:32:42 -0700956 qdf_copy_macaddr(&sta_ctx->conn_info.bssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700957 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958
959 /*
960 * Save the Station ID for this station from
961 * the 'Roam Info'. For IBSS mode, staId is
962 * assigned in NEW_PEER_IND. For reassoc,
963 * the staID doesn't change and it may be invalid
964 * in this structure so no change here.
965 */
Jeff Johnsonfd060852017-10-04 10:50:51 -0700966 if (!roam_info->fReassocReq) {
Jeff Johnsond377dce2017-10-04 10:32:42 -0700967 sta_ctx->conn_info.staId[0] =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700968 roam_info->staId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 }
970 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Jeff Johnsond377dce2017-10-04 10:32:42 -0700971 qdf_copy_macaddr(&sta_ctx->conn_info.bssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700972 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 } else {
974 /*
975 * can't happen. We need a valid IBSS or Infra setting
976 * in the BSSDescription or we can't function.
977 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530978 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 }
980
981 /* notify WMM */
Jeff Johnsonfd060852017-10-04 10:50:51 -0700982 hdd_wmm_connect(adapter, roam_info, eBssType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983
Jeff Johnsonfd060852017-10-04 10:50:51 -0700984 if (!roam_info->u.pConnectedProfile) {
985 QDF_ASSERT(roam_info->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 } else {
987 /* Get Multicast Encryption Type */
988 encryptType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700989 roam_info->u.pConnectedProfile->mcEncryptionType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700990 sta_ctx->conn_info.mcEncryptionType = encryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 /* Get Unicast Encryption Type */
992 encryptType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700993 roam_info->u.pConnectedProfile->EncryptionType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700994 sta_ctx->conn_info.ucEncryptionType = encryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995
Jeff Johnsond377dce2017-10-04 10:32:42 -0700996 sta_ctx->conn_info.authType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700997 roam_info->u.pConnectedProfile->AuthType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700998 sta_ctx->conn_info.last_auth_type =
999 sta_ctx->conn_info.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000
Jeff Johnsond377dce2017-10-04 10:32:42 -07001001 sta_ctx->conn_info.operationChannel =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001002 roam_info->u.pConnectedProfile->operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003
1004 /* Save the ssid for the connection */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001005 qdf_mem_copy(&sta_ctx->conn_info.SSID.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001006 &roam_info->u.pConnectedProfile->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007 sizeof(tSirMacSSid));
Jeff Johnsond377dce2017-10-04 10:32:42 -07001008 qdf_mem_copy(&sta_ctx->conn_info.last_ssid.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001009 &roam_info->u.pConnectedProfile->SSID,
Zhang Qian32fd43e2017-08-24 18:36:28 +08001010 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011
1012 /* Save dot11mode in which STA associated to AP */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001013 sta_ctx->conn_info.dot11Mode =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001014 roam_info->u.pConnectedProfile->dot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015
Jeff Johnsond377dce2017-10-04 10:32:42 -07001016 sta_ctx->conn_info.proxyARPService =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001017 roam_info->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301018
Jeff Johnsonfd060852017-10-04 10:50:51 -07001019 sta_ctx->conn_info.nss = roam_info->chan_info.nss;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301020
Jeff Johnsond377dce2017-10-04 10:32:42 -07001021 sta_ctx->conn_info.rate_flags =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001022 roam_info->chan_info.rate_flags;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +05301023
1024 sta_ctx->conn_info.ch_width =
1025 roam_info->chan_info.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 }
Jeff Johnsonfd060852017-10-04 10:50:51 -07001027 hdd_save_bss_info(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029}
1030
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031/**
1032 * hdd_send_ft_assoc_response() - send fast transition assoc response
1033 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07001034 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 * @pCsrRoamInfo: pointer to roam info
1036 *
1037 * Send the 11R key information to the supplicant. Only then can the supplicant
1038 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
1039 * for the same purpose.)
1040 *
1041 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
1042 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
1043 * This is the Assoc Response.
1044 *
1045 * Return: none
1046 */
1047static void
1048hdd_send_ft_assoc_response(struct net_device *dev,
Jeff Johnsonba388342017-10-02 13:31:01 -07001049 struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001050 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051{
1052 union iwreq_data wrqu;
1053 char *buff;
1054 unsigned int len = 0;
1055 u8 *pFTAssocRsp = NULL;
1056
1057 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001058 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 return;
1060 }
1061
1062 pFTAssocRsp =
1063 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1064 pCsrRoamInfo->nAssocReqLength);
1065 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001066 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 return;
1068 }
1069 /* pFTAssocRsp needs to point to the IEs */
1070 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001071 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001072 (unsigned int)pFTAssocRsp[0],
1073 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074
1075 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001076 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001078 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 return;
1080 }
1081 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
1082 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1083 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 memcpy(buff, pFTAssocRsp, len);
1085 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
1086
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001087 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090/**
1091 * hdd_send_ft_event() - send fast transition event
Jeff Johnsonba388342017-10-02 13:31:01 -07001092 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 *
1094 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
1095 * FT events to the supplicant. At the reception of Auth2 we send the RIC
1096 * followed by the auth response IEs to the supplicant.
1097 * Once both are received in the supplicant, an FT event is generated
1098 * to the supplicant.
1099 *
1100 * Return: none
1101 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001102static void hdd_send_ft_event(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103{
1104 uint16_t auth_resp_len = 0;
1105 uint32_t ric_ies_length = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001106 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001107 mac_handle_t mac_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108
1109#if defined(KERNEL_SUPPORT_11R_CFG80211)
1110 struct cfg80211_ft_event_params ftEvent;
1111 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1112 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
Jeff Johnsonba388342017-10-02 13:31:01 -07001113 struct net_device *dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001114#else
1115 char *buff;
1116 union iwreq_data wrqu;
1117 uint16_t str_len;
1118#endif
1119
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001120 mac_handle = hdd_ctx->mac_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301122 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1123 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001125 sme_get_rici_es(mac_handle, adapter->session_id, (u8 *) ricIe,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001127 if (ric_ies_length == 0)
1128 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129
1130 ftEvent.ric_ies = ricIe;
1131 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001132 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001134 sme_get_ft_pre_auth_response(mac_handle, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1136 &auth_resp_len);
1137
1138 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001139 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 return;
1141 }
1142
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001143 sme_set_ft_pre_auth_state(mac_handle, adapter->session_id, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144
1145 ftEvent.target_ap = ftIe;
1146
Anurag Chouhan6d760662016-02-20 16:05:43 +05301147 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1148 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001150 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1151 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1152 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 ftEvent.target_ap[0], ftEvent.target_ap[1],
1154 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1155 ftEvent.target_ap[5]);
1156
1157 (void)cfg80211_ft_event(dev, &ftEvent);
1158
1159#else
1160 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001161 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001163 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 return;
1165 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166
1167 /* Sme needs to send the RIC IEs first */
1168 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001169 sme_get_rici_es(mac_handle, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1171 &ric_ies_length);
1172 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001173 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174 } else {
1175 wrqu.data.length = str_len + ric_ies_length;
Jeff Johnsonba388342017-10-02 13:31:01 -07001176 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 }
1178
1179 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301180 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001182 sme_get_ft_pre_auth_response(mac_handle, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183 (u8 *) &buff[str_len],
1184 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1185
1186 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001187 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001188 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189 return;
1190 }
1191
1192 wrqu.data.length = str_len + auth_resp_len;
Jeff Johnsonba388342017-10-02 13:31:01 -07001193 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001195 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196#endif
1197}
1198
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001199#ifdef FEATURE_WLAN_ESE
1200/**
1201 * hdd_send_new_ap_channel_info() - send new ap channel info
1202 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07001203 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 * @pCsrRoamInfo: pointer to roam info
1205 *
1206 * Send the ESE required "new AP Channel info" to the supplicant.
1207 * (This keeps the supplicant "up to date" on the current channel.)
1208 *
1209 * The current (new AP) channel information is passed in.
1210 *
1211 * Return: none
1212 */
1213static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07001214hdd_send_new_ap_channel_info(struct net_device *dev,
1215 struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001216 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217{
1218 union iwreq_data wrqu;
Jeff Johnson4ba73cb2017-10-06 11:12:33 -07001219 struct bss_description *descriptor = pCsrRoamInfo->pBssDesc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220
1221 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001222 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 return;
1224 }
1225 /*
1226 * Send the Channel event, the supplicant needs this to generate
1227 * the Adjacent AP report.
1228 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001229 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001230 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 memset(&wrqu, '\0', sizeof(wrqu));
1232 wrqu.freq.m = descriptor->channelId;
1233 wrqu.freq.e = 0;
1234 wrqu.freq.i = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001235 wireless_send_event(adapter->dev, SIOCGIWFREQ, &wrqu, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236}
1237
1238#endif /* FEATURE_WLAN_ESE */
1239
1240/**
1241 * hdd_send_update_beacon_ies_event() - send update beacons ie event
Jeff Johnsonba388342017-10-02 13:31:01 -07001242 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 * @pCsrRoamInfo: pointer to roam info
1244 *
1245 * Return: none
1246 */
1247static void
Jeff Johnsonba388342017-10-02 13:31:01 -07001248hdd_send_update_beacon_ies_event(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001249 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250{
1251 union iwreq_data wrqu;
Jeff Johnson04e00082017-10-04 12:15:58 -07001252 u8 *beacon_ies;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 u8 currentLen = 0;
1254 char *buff;
1255 int totalIeLen = 0, currentOffset = 0, strLen;
1256
1257 memset(&wrqu, '\0', sizeof(wrqu));
1258
1259 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001260 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 return;
1262 }
Jeff Johnson04e00082017-10-04 12:15:58 -07001263 beacon_ies = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1264 if (beacon_ies == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001265 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 return;
1267 }
Jeff Johnson04e00082017-10-04 12:15:58 -07001268 /* beacon_ies needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001269 hdd_debug("Beacon IEs is now at %02x%02x",
Jeff Johnson04e00082017-10-04 12:15:58 -07001270 (unsigned int)beacon_ies[0],
1271 (unsigned int)beacon_ies[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001272 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001273 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274
1275 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001276 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001278 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001279 return;
1280 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281
1282 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1283 currentLen = strLen + 1;
1284
1285 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1286 do {
1287 /*
1288 * If the beacon size exceeds max CUSTOM event size, break it
1289 * into chunks of CUSTOM event max size and send it to
1290 * supplicant. Changes are done in supplicant to handle this.
1291 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301292 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301294 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Jeff Johnson04e00082017-10-04 12:15:58 -07001295 qdf_mem_copy(&buff[strLen + 1], beacon_ies + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 currentLen);
1297 currentOffset += currentLen;
1298 totalIeLen -= currentLen;
1299 wrqu.data.length = strLen + 1 + currentLen;
1300 if (totalIeLen)
1301 buff[strLen] = 1; /* more chunks pending */
1302 else
1303 buff[strLen] = 0; /* last chunk */
1304
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001305 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001306 currentLen);
Jeff Johnsonba388342017-10-02 13:31:01 -07001307 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 } while (totalIeLen > 0);
1309
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001310 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311}
1312
1313/**
1314 * hdd_send_association_event() - send association event
1315 * @dev: pointer to net device
1316 * @pCsrRoamInfo: pointer to roam info
1317 *
1318 * Return: none
1319 */
1320static void hdd_send_association_event(struct net_device *dev,
Jeff Johnson172237b2017-11-07 15:32:59 -08001321 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322{
Rajeev Kumar78427682017-01-13 16:13:11 -08001323 int ret;
Jeff Johnsonba388342017-10-02 13:31:01 -07001324 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1325 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001326 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 union iwreq_data wrqu;
1328 int we_event;
1329 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301330 struct qdf_mac_addr peerMacAddr;
Jeff Johnson844eec72018-03-13 11:48:18 -07001331 struct csr_roam_profile *roam_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332
Jeff Johnson844eec72018-03-13 11:48:18 -07001333 roam_profile = hdd_roam_profile(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 memset(&wrqu, '\0', sizeof(wrqu));
1335 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1336 we_event = SIOCGIWAP;
1337#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1338 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301339 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001341 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301342 /* Update tdls module about the disconnection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001343 hdd_notify_sta_disconnect(adapter->session_id,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001344 true, false,
1345 adapter->hdd_vdev);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301346 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347#endif
Jeff Johnsond377dce2017-10-04 10:32:42 -07001348 if (eConnectionState_Associated == sta_ctx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001349 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301350
Rajeev Kumar Sirasanagandlae5582aa2018-05-02 18:20:20 +05301351 if (!pCsrRoamInfo || !pCsrRoamInfo->pBssDesc) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001352 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 return;
1354 }
1355
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05301356 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo)) {
Jeff Johnson8095a312017-09-03 09:13:24 -07001357 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001358 adapter->device_mode, adapter->session_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07001359 hdd_green_ap_start_state_mc(hdd_ctx,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05301360 adapter->device_mode, true);
1361 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1363 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1364
Wu Gaoc02785d2017-09-07 18:17:13 +08001365 ucfg_p2p_status_connect(adapter->hdd_vdev);
1366
Abhinav Kumar50d4dc72018-06-15 16:35:50 +05301367 hdd_info("wlan: " MAC_ADDRESS_STR " connected to "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 MAC_ADDRESS_STR "\n",
Jeff Johnson1e851a12017-10-28 14:36:12 -07001369 MAC_ADDR_ARRAY(adapter->mac_addr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnsonba388342017-10-02 13:31:01 -07001371 hdd_send_update_beacon_ies_event(adapter, pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372
1373 /*
1374 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1375 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001376 * fFTEnable is true.
1377 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001379 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 eCSR_AUTH_TYPE_FT_RSN_PSK)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001381 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 eCSR_AUTH_TYPE_FT_RSN)
1383#ifdef FEATURE_WLAN_ESE
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001384 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 eCSR_AUTH_TYPE_CCKM_RSN)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001386 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 eCSR_AUTH_TYPE_CCKM_WPA)
1388#endif
1389 ) {
Jeff Johnsonba388342017-10-02 13:31:01 -07001390 hdd_send_ft_assoc_response(dev, adapter, pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301392 qdf_copy_macaddr(&peerMacAddr,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001393 &sta_ctx->conn_info.bssId);
Abhishek Singh1c676222016-05-09 14:20:28 +05301394 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1395 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1396 chan_info.info = pCsrRoamInfo->chan_info.info;
1397 chan_info.band_center_freq1 =
1398 pCsrRoamInfo->chan_info.band_center_freq1;
1399 chan_info.band_center_freq2 =
1400 pCsrRoamInfo->chan_info.band_center_freq2;
1401 chan_info.reg_info_1 =
1402 pCsrRoamInfo->chan_info.reg_info_1;
1403 chan_info.reg_info_2 =
1404 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301405
Jeff Johnsonba388342017-10-02 13:31:01 -07001406 ret = hdd_objmgr_set_peer_mlme_state(adapter->hdd_vdev,
Dustin Brown7d043f62017-03-27 12:07:36 -07001407 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301408 if (ret)
1409 hdd_err("Peer object %pM fail to set associated state",
1410 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301411
Abhishek Singh1c676222016-05-09 14:20:28 +05301412 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001413 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1414 ePeerConnected,
1415 pCsrRoamInfo->timingMeasCap,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001416 adapter->session_id, &chan_info,
Jeff Johnsonba388342017-10-02 13:31:01 -07001417 adapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001418 /* Update tdls module about connection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001419 hdd_notify_sta_connect(adapter->session_id,
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001420 pCsrRoamInfo->tdls_chan_swit_prohibited,
1421 pCsrRoamInfo->tdls_prohibited,
Jeff Johnsonba388342017-10-02 13:31:01 -07001422 adapter->hdd_vdev);
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424#ifdef MSM_PLATFORM
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 /* start timer in sta/p2p_cli */
Jeff Johnson8095a312017-09-03 09:13:24 -07001426 spin_lock_bh(&hdd_ctx->bus_bw_lock);
Jeff Johnsonba388342017-10-02 13:31:01 -07001427 adapter->prev_tx_packets = adapter->stats.tx_packets;
1428 adapter->prev_rx_packets = adapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001429 cdp_get_intra_bss_fwd_pkts_count(
Jeff Johnson1b780e42017-10-31 14:11:45 -07001430 cds_get_context(QDF_MODULE_ID_SOC), adapter->session_id,
Jeff Johnsonba388342017-10-02 13:31:01 -07001431 &adapter->prev_fwd_tx_packets,
1432 &adapter->prev_fwd_rx_packets);
Jeff Johnson8095a312017-09-03 09:13:24 -07001433 spin_unlock_bh(&hdd_ctx->bus_bw_lock);
1434 hdd_bus_bw_compute_timer_start(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 } else if (eConnectionState_IbssConnected == /* IBss Associated */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001437 sta_ctx->conn_info.connState) {
Jeff Johnson8095a312017-09-03 09:13:24 -07001438 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001439 adapter->session_id);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001440 memcpy(wrqu.ap_addr.sa_data, sta_ctx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001441 ETH_ALEN);
Abhishek Singh44725482017-11-02 16:53:23 +05301442 hdd_debug("wlan: new IBSS peer connection to BSSID " MAC_ADDRESS_STR,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001443 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 } else { /* Not Associated */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301445 hdd_debug("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Jeff Johnson8095a312017-09-03 09:13:24 -07001447 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001448 adapter->device_mode, adapter->session_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07001449 hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05301450 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451
1452#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001453 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454#endif
1455
Jeff Johnsonba388342017-10-02 13:31:01 -07001456 if ((adapter->device_mode == QDF_STA_MODE) ||
Jeff Johnson844eec72018-03-13 11:48:18 -07001457 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301458 qdf_copy_macaddr(&peerMacAddr,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001459 &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460
1461 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001462 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301463 ePeerDisconnected, 0,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001464 adapter->session_id,
Abhishek Singh1c676222016-05-09 14:20:28 +05301465 NULL,
Jeff Johnsonba388342017-10-02 13:31:01 -07001466 adapter->device_mode);
Abhishek Singh44725482017-11-02 16:53:23 +05301467 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301468
Jeff Johnsonba388342017-10-02 13:31:01 -07001469 hdd_lpass_notify_disconnect(adapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001470 /* Update tdls module about the disconnection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001471 hdd_notify_sta_disconnect(adapter->session_id,
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001472 false,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001473 false,
Jeff Johnsonba388342017-10-02 13:31:01 -07001474 adapter->hdd_vdev);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001475
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476#ifdef MSM_PLATFORM
1477 /* stop timer in sta/p2p_cli */
Jeff Johnson8095a312017-09-03 09:13:24 -07001478 spin_lock_bh(&hdd_ctx->bus_bw_lock);
Jeff Johnsonba388342017-10-02 13:31:01 -07001479 adapter->prev_tx_packets = 0;
1480 adapter->prev_rx_packets = 0;
1481 adapter->prev_fwd_tx_packets = 0;
1482 adapter->prev_fwd_rx_packets = 0;
Jeff Johnson8095a312017-09-03 09:13:24 -07001483 spin_unlock_bh(&hdd_ctx->bus_bw_lock);
1484 hdd_bus_bw_compute_timer_try_stop(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485#endif
1486 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001487 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488
1489 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001490 /* During the WLAN uninitialization,supplicant is stopped before the
1491 * driver so not sending the status of the connection to supplicant
1492 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001493 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494 wireless_send_event(dev, we_event, &wrqu, msg);
1495#ifdef FEATURE_WLAN_ESE
1496 if (eConnectionState_Associated ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001497 sta_ctx->conn_info.connState) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001498 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 eCSR_AUTH_TYPE_CCKM_RSN) ||
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001500 (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 eCSR_AUTH_TYPE_CCKM_WPA))
Jeff Johnsonba388342017-10-02 13:31:01 -07001502 hdd_send_new_ap_channel_info(dev, adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503 pCsrRoamInfo);
1504 }
1505#endif
1506 }
1507}
1508
1509/**
1510 * hdd_conn_remove_connect_info() - remove connection info
Jeff Johnsond377dce2017-10-04 10:32:42 -07001511 * @sta_ctx: pointer to global HDD station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512 * @pCsrRoamInfo: pointer to roam info
1513 *
1514 * Return: none
1515 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001516static void hdd_conn_remove_connect_info(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517{
1518 /* Remove staId, bssId and peerMacAddress */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001519 sta_ctx->conn_info.staId[0] = HDD_WLAN_INVALID_STA_ID;
1520 qdf_mem_zero(&sta_ctx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1521 qdf_mem_zero(&sta_ctx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301522 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523
1524 /* Clear all security settings */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001525 sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1526 sta_ctx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1527 sta_ctx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528
Jeff Johnsond377dce2017-10-04 10:32:42 -07001529 qdf_mem_zero(&sta_ctx->conn_info.Keys, sizeof(tCsrKeys));
1530 qdf_mem_zero(&sta_ctx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531
Jeff Johnsond377dce2017-10-04 10:32:42 -07001532 sta_ctx->conn_info.proxyARPService = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533
Jeff Johnsond377dce2017-10-04 10:32:42 -07001534 qdf_mem_zero(&sta_ctx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535}
1536
1537/**
Jeff Johnson7f2c5912018-03-23 11:42:28 -07001538 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
1539 * @adapter: adapter who's IEs are to be cleared
1540 *
1541 * Return: None
1542 */
1543static void hdd_clear_roam_profile_ie(struct hdd_adapter *adapter)
1544{
1545 struct hdd_station_ctx *sta_ctx;
1546 struct csr_roam_profile *roam_profile;
1547
1548 hdd_enter();
1549
1550 /* clear WPA/RSN/WSC IE information in the profile */
1551 roam_profile = hdd_roam_profile(adapter);
1552
1553 roam_profile->nWPAReqIELength = 0;
1554 roam_profile->pWPAReqIE = NULL;
1555 roam_profile->nRSNReqIELength = 0;
1556 roam_profile->pRSNReqIE = NULL;
1557
1558#ifdef FEATURE_WLAN_WAPI
1559 roam_profile->nWAPIReqIELength = 0;
1560 roam_profile->pWAPIReqIE = NULL;
1561#endif
1562
1563 roam_profile->bWPSAssociation = false;
1564 roam_profile->bOSENAssociation = false;
1565 roam_profile->pAddIEScan = NULL;
1566 roam_profile->nAddIEScanLength = 0;
1567 roam_profile->pAddIEAssoc = NULL;
1568 roam_profile->nAddIEAssocLength = 0;
1569
1570 roam_profile->EncryptionType.numEntries = 1;
1571 roam_profile->EncryptionType.encryptionType[0] =
1572 eCSR_ENCRYPT_TYPE_NONE;
1573
1574 roam_profile->mcEncryptionType.numEntries = 1;
1575 roam_profile->mcEncryptionType.encryptionType[0] =
1576 eCSR_ENCRYPT_TYPE_NONE;
1577
1578 roam_profile->AuthType.numEntries = 1;
1579 roam_profile->AuthType.authType[0] =
1580 eCSR_AUTH_TYPE_OPEN_SYSTEM;
1581
1582 qdf_mem_zero(roam_profile->bssid_hint.bytes, QDF_MAC_ADDR_SIZE);
1583
1584#ifdef WLAN_FEATURE_11W
1585 roam_profile->MFPEnabled = false;
1586 roam_profile->MFPRequired = 0;
1587 roam_profile->MFPCapable = 0;
1588#endif
1589
1590 qdf_mem_zero(roam_profile->Keys.KeyLength, CSR_MAX_NUM_KEY);
1591
1592#ifdef FEATURE_WLAN_WAPI
1593 adapter->wapi_info.wapi_auth_mode = WAPI_AUTH_MODE_OPEN;
1594 adapter->wapi_info.wapi_mode = false;
1595#endif
1596
1597 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1598 sta_ctx->auth_key_mgmt = 0;
1599 qdf_zero_macaddr(&sta_ctx->requested_bssid);
1600 hdd_exit();
1601}
1602
1603/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 * hdd_roam_deregister_sta() - deregister station
Jeff Johnsonba388342017-10-02 13:31:01 -07001605 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 * @staId: station identifier
1607 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301608 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07001610QDF_STATUS hdd_roam_deregister_sta(struct hdd_adapter *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301612 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001614 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001615 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301616 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301617 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301618 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1619 staid, qdf_status, qdf_status);
1620 }
1621
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301622 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623}
1624
1625/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301626 * hdd_print_bss_info() - print bss info
1627 * @hdd_sta_ctx: pointer to hdd station context
1628 *
1629 * Return: None
1630 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001631static void hdd_print_bss_info(struct hdd_station_ctx *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301632{
1633 uint32_t *cap_info;
1634
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301635 hdd_debug("WIFI DATA LOGGER");
1636 hdd_debug("channel: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301637 hdd_sta_ctx->conn_info.freq);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301638 hdd_debug("dot11mode: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301639 hdd_sta_ctx->conn_info.dot11Mode);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301640 hdd_debug("AKM: %d",
1641 hdd_sta_ctx->conn_info.last_auth_type);
1642 hdd_debug("ssid: %.*s",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001643 hdd_sta_ctx->conn_info.last_ssid.SSID.length,
1644 hdd_sta_ctx->conn_info.last_ssid.SSID.ssId);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301645 hdd_debug("roam count: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301646 hdd_sta_ctx->conn_info.roam_count);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301647 hdd_debug("ant_info: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301648 hdd_sta_ctx->conn_info.txrate.nss);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301649 hdd_debug("datarate legacy %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301650 hdd_sta_ctx->conn_info.txrate.legacy);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301651 hdd_debug("datarate mcs: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301652 hdd_sta_ctx->conn_info.txrate.mcs);
1653 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1654 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301655 hdd_debug("ht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301656 }
1657 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1658 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301659 hdd_debug("vht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301660 }
1661 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301662 hdd_debug("hs20 info: %x",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301663 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301664 hdd_debug("signal: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301665 hdd_sta_ctx->conn_info.signal);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301666 hdd_debug("noise: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301667 hdd_sta_ctx->conn_info.noise);
1668}
1669
1670/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 * hdd_dis_connect_handler() - disconnect event handler
Jeff Johnsonba388342017-10-02 13:31:01 -07001672 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07001673 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 * @roamId: roam identifier
1675 * @roamStatus: roam status
1676 * @roamResult: roam result
1677 *
1678 * This function handles disconnect event:
1679 * 1. Disable transmit queues;
1680 * 2. Clean up internal connection states and data structures;
1681 * 3. Send disconnect indication to supplicant.
1682 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301683 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001685static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001686 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 uint32_t roamId,
1688 eRoamCmdStatus roamStatus,
1689 eCsrRoamResult roamResult)
1690{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301691 QDF_STATUS status = QDF_STATUS_SUCCESS;
1692 QDF_STATUS vstatus;
Jeff Johnsonba388342017-10-02 13:31:01 -07001693 struct net_device *dev = adapter->dev;
1694 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001695 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 uint8_t sta_id;
1697 bool sendDisconInd = true;
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001698 mac_handle_t mac_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699
1700 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001701 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301702 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 }
1704 /* notify apps that we can't pass traffic anymore */
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001705 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07001706 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301707 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1708 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709
gaurank kathpalia63311d12018-04-12 14:34:26 +05301710 if (ucfg_ipa_is_enabled() &&
1711 (sta_ctx->conn_info.staId[0] != HDD_WLAN_INVALID_STA_ID))
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05301712 ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev, adapter->dev,
1713 adapter->device_mode,
1714 sta_ctx->conn_info.staId[0],
1715 adapter->session_id,
1716 WLAN_IPA_STA_DISCONNECT,
1717 sta_ctx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718
1719#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001720 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721#endif
1722
Nirav Shah1da77682016-05-03 20:16:39 +05301723 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001724 adapter->session_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001725 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301726 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727
1728 /* HDD has initiated disconnect, do not send disconnect indication
1729 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301730 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 * to cfg80211_disconnected.
1732 */
1733 if ((eConnectionState_Disconnecting ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001734 sta_ctx->conn_info.connState) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 (eConnectionState_NotConnected ==
Abhinav Kumar74948192018-05-09 17:17:50 +05301736 sta_ctx->conn_info.connState) ||
1737 (eConnectionState_Connecting ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001738 sta_ctx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001739 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 sendDisconInd = false;
Abhinav Kumar74948192018-05-09 17:17:50 +05301741 } else {
Jeff Johnsonba388342017-10-02 13:31:01 -07001742 INIT_COMPLETION(adapter->disconnect_comp_var);
1743 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 eConnectionState_Disconnecting);
1745 }
1746
Jeff Johnsonba388342017-10-02 13:31:01 -07001747 hdd_clear_roam_profile_ie(adapter);
1748 hdd_wmm_init(adapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001749 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301750 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751
1752 /* indicate 'disconnect' status to wpa_supplicant... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07001753 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 /* indicate disconnected event to nl80211 */
1755 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1756 /*
1757 * Only send indication to kernel if not initiated
1758 * by kernel
1759 */
1760 if (sendDisconInd) {
1761 /*
1762 * To avoid wpa_supplicant sending "HANGED" CMD
1763 * to ICS UI.
1764 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001765 if (eCSR_ROAM_LOSTLINK == roamStatus) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07001766 if (roam_info->reasonCode ==
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001767 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
Jeff Johnson435e1b82017-10-07 14:13:10 -07001768 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n",
1769 roam_info->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301770 wlan_hdd_cfg80211_indicate_disconnect(
1771 dev, false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001772 roam_info->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001773 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301774 wlan_hdd_cfg80211_indicate_disconnect(
1775 dev, false,
1776 WLAN_REASON_UNSPECIFIED
1777 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001778 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301780 hdd_debug("sent disconnected event to nl80211, reason code %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301781 (eCSR_ROAM_LOSTLINK == roamStatus) ?
Jeff Johnsonfd060852017-10-04 10:50:51 -07001782 roam_info->reasonCode :
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301783 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785
Wu Gaoc02785d2017-09-07 18:17:13 +08001786 /* update P2P connection status */
1787 ucfg_p2p_status_disconnect(adapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 }
1789
Jeff Johnsonba388342017-10-02 13:31:01 -07001790 hdd_wmm_adapter_clear(adapter);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001791 mac_handle = hdd_ctx->mac_handle;
1792 sme_ft_reset(mac_handle, adapter->session_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001793 if (hdd_remove_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001794 hdd_err("hdd_remove_beacon_filter() failed");
1795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301797 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001798
Jeff Johnsond377dce2017-10-04 10:32:42 -07001799 sta_id = sta_ctx->broadcast_staid;
Jeff Johnsonba388342017-10-02 13:31:01 -07001800 vstatus = hdd_roam_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301801 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001802 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301803 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001806 if (sta_id < HDD_MAX_ADAPTERS)
1807 hdd_ctx->sta_to_adapter[sta_id] = NULL;
1808 else
1809 hdd_debug("invalid sta id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301810 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001811 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001812 if (HDD_WLAN_INVALID_STA_ID ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001813 sta_ctx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301814 continue;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001815 sta_id = sta_ctx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001816 hdd_debug("Deregister StaID %d", sta_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001817 vstatus = hdd_roam_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301818 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001819 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301820 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301821 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301822 }
1823 /* set the staid and peer mac as 0, all other
1824 * reset are done in hdd_connRemoveConnectInfo.
1825 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001826 sta_ctx->conn_info.staId[i] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301827 HDD_WLAN_INVALID_STA_ID;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001828 qdf_mem_zero(&sta_ctx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301829 sizeof(struct qdf_mac_addr));
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001830 if (sta_id < HDD_MAX_ADAPTERS)
Jeff Johnson8095a312017-09-03 09:13:24 -07001831 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001832 else
1833 hdd_debug("invalid sta_id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301834 }
1835 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07001836 sta_id = sta_ctx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001837 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301838
1839 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001840 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1841 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301842 eCSR_ROAM_LOSTLINK == roamStatus) {
Jeff Johnsonba388342017-10-02 13:31:01 -07001843 wlan_hdd_cfg80211_update_bss_list(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001844 sta_ctx->conn_info.bssId.bytes);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001845 sme_remove_bssid_from_scan_list(mac_handle,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001846 sta_ctx->conn_info.bssId.bytes);
Abhishek Singhc9941602016-08-09 16:06:22 +05301847 }
Rajeev Kumar4bc998f2017-10-19 14:41:43 -07001848 if (sta_id < HDD_MAX_ADAPTERS)
1849 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001850 else
1851 hdd_debug("invalid sta_id %d", sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 /* Clear saved connection information in HDD */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001854 hdd_conn_remove_connect_info(sta_ctx);
Abhinav Kumar74948192018-05-09 17:17:50 +05301855 /*
1856 * eConnectionState_Connecting state mean that connection is in
1857 * progress so no need to set state to eConnectionState_NotConnected
1858 */
1859 if ((eConnectionState_Connecting != sta_ctx->conn_info.connState)) {
1860 hdd_conn_set_connection_state(adapter,
1861 eConnectionState_NotConnected);
1862 }
Jeff Johnsonba388342017-10-02 13:31:01 -07001863 pmo_ucfg_flush_gtk_offload_req(adapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864
Jeff Johnsonba388342017-10-02 13:31:01 -07001865 if ((QDF_STA_MODE == adapter->device_mode) ||
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001866 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
1867 sme_ps_disable_auto_ps_timer(mac_handle,
1868 adapter->session_id);
Yeshwanth Sriram Guntuka4fe30bd2018-06-13 11:41:42 +05301869 adapter->send_mode_change = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 }
Jeff Johnsonba388342017-10-02 13:31:01 -07001871 wlan_hdd_clear_link_layer_stats(adapter);
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301872
Bala Venkatesh9f958142018-06-27 12:36:08 +05301873 hdd_debug("check for SAP restart");
1874 policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->hdd_psoc);
Jeff Johnson6ced42c2017-10-20 12:48:11 -07001875 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 /* Unblock anyone waiting for disconnect to complete */
Jeff Johnsonba388342017-10-02 13:31:01 -07001878 complete(&adapter->disconnect_comp_var);
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +05301879
Alok Kumarb64650c2018-03-23 17:05:11 +05301880 hdd_nud_reset_tracking(adapter);
1881
1882 hdd_set_disconnect_status(adapter, false);
1883
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +05301884 hdd_reset_limit_off_chan(adapter);
1885
Jeff Johnsond377dce2017-10-04 10:32:42 -07001886 hdd_print_bss_info(sta_ctx);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05301887
1888 if (policy_mgr_is_sta_active_connection_exists(hdd_ctx->hdd_psoc))
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001889 sme_enable_roaming_on_connected_sta(mac_handle);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05301890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 return status;
1892}
1893
1894/**
1895 * hdd_set_peer_authorized_event() - set peer_authorized_event
1896 * @vdev_id: vdevid
1897 *
1898 * Return: None
1899 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001900static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901{
Jeff Johnson49432062017-08-28 12:08:45 -07001902 struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Jeff Johnsonb1704c82017-08-29 14:40:57 -07001903 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904
Ashish Kumar Dhanotiyaab2a9292018-06-16 15:11:27 +05301905 if (!hdd_ctx) {
1906 hdd_err("Invalid hdd context");
1907 return;
1908 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1910 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001911 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001912 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 }
1914 complete(&adapter->sta_authorized_event);
1915}
1916
1917/**
1918 * hdd_change_peer_state() - change peer state
Jeff Johnsonba388342017-10-02 13:31:01 -07001919 * @adapter: HDD adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920 * @sta_state: peer state
1921 * @roam_synch_in_progress: roam synch in progress
1922 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301923 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001925QDF_STATUS hdd_change_peer_state(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926 uint8_t sta_id,
1927 enum ol_txrx_peer_state sta_state,
1928 bool roam_synch_in_progress)
1929{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301930 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001931 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001932 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1933 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1934 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935
1936 if (!pdev) {
1937 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301938 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 }
1940
1941 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001942 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301943 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 }
1945
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001946 peer = cdp_peer_find_by_local_id(soc,
1947 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301949 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950
Leo Changfdb45c32016-10-28 11:09:23 -07001951 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001952 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001953 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001954 return QDF_STATUS_E_FAULT;
1955 }
1956
Leo Changfdb45c32016-10-28 11:09:23 -07001957 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301958 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001959 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301960 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 }
1962#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1963 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301964 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965#endif
1966
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001967 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1969 /* make sure event is reset */
Jeff Johnsonba388342017-10-02 13:31:01 -07001970 INIT_COMPLETION(adapter->sta_authorized_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971#endif
1972
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001973 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 hdd_set_peer_authorized_event,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001975 adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301976 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001977 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301978 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 }
1980
Jeff Johnsonba388342017-10-02 13:31:01 -07001981 if (adapter->device_mode == QDF_STA_MODE ||
1982 adapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001984 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 unsigned long rc;
1986
1987 /* wait for event from firmware to set the event */
1988 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07001989 &adapter->sta_authorized_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001991 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001992 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001993
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001994 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1995 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001996 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997#endif
1998 }
1999 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302000 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001}
2002
2003/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07002004 * hdd_update_dp_vdev_flags() - update datapath vdev flags
2005 * @cbk_data: callback data
2006 * @sta_id: station id
2007 * @vdev_param: vdev parameter
2008 * @is_link_up: link state up or down
2009 *
2010 * Return: QDF status
2011 */
2012QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
2013 uint8_t sta_id,
2014 uint32_t vdev_param,
2015 bool is_link_up)
2016{
2017 struct cdp_vdev *data_vdev;
2018 QDF_STATUS status = QDF_STATUS_SUCCESS;
2019 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Jeff Johnson49432062017-08-28 12:08:45 -07002020 struct hdd_context *hdd_ctx;
Yun Park0dad1002017-07-14 14:57:01 -07002021 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Kabilan Kannan256e3182017-05-02 16:02:37 -07002022 struct wlan_objmgr_psoc **psoc;
2023
2024 if (!cbk_data)
2025 return status;
2026
2027 psoc = cbk_data;
Kabilan Kannan256e3182017-05-02 16:02:37 -07002028
Kabilan Kannanc0e3d582017-09-13 00:26:33 -07002029 hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Sourav Mohapatra5febc932018-01-08 14:38:30 +05302030 if (!hdd_ctx) {
2031 hdd_err("Invalid HDD Context");
2032 return QDF_STATUS_E_INVAL;
2033 }
2034
Kabilan Kannan256e3182017-05-02 16:02:37 -07002035 if (!hdd_ctx->tdls_nap_active)
2036 return status;
2037
Yun Park0dad1002017-07-14 14:57:01 -07002038 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, pdev, sta_id);
Kabilan Kannan256e3182017-05-02 16:02:37 -07002039 if (NULL == data_vdev) {
2040 status = QDF_STATUS_E_FAILURE;
2041 return status;
2042 }
2043
2044 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
2045
2046 return status;
2047}
2048
2049/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 * hdd_roam_register_sta() - register station
Jeff Johnsonba388342017-10-02 13:31:01 -07002051 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002052 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 * @staId: station identifier
2054 * @pPeerMacAddress: peer MAC address
2055 * @pBssDesc: pointer to BSS description
2056 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302057 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 */
Jeff Johnsonba388342017-10-02 13:31:01 -07002059QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002060 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302062 struct qdf_mac_addr *pPeerMacAddress,
Jeff Johnson4ba73cb2017-10-06 11:12:33 -07002063 struct bss_description *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302065 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsond377dce2017-10-04 10:32:42 -07002067 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08002068 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07002069 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2070 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071
2072 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302073 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074
2075 /* Get the Station ID from the one saved during the association */
2076 staDesc.sta_id = staId;
2077
2078 /* set the QoS field appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07002079 if (hdd_wmm_is_active(adapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 staDesc.is_qos_enabled = 1;
2081 else
2082 staDesc.is_qos_enabled = 0;
2083
2084#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07002085 hdd_debug("WAPI STA Registered: %d",
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002086 adapter->wapi_info.is_wapi_sta);
2087 if (adapter->wapi_info.is_wapi_sta)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 staDesc.is_wapi_supported = 1;
2089 else
2090 staDesc.is_wapi_supported = 0;
2091#endif /* FEATURE_WLAN_WAPI */
2092
Dhanashri Atre50141c52016-04-07 13:15:29 -07002093 /* Register the vdev transmit and receive functions */
2094 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
Mohit Khanna70322002018-05-15 19:21:32 -07002095
2096 if (adapter->hdd_ctx->enable_dp_rx_threads) {
2097 txrx_ops.rx.rx = hdd_rx_pkt_thread_enqueue_cbk;
2098 txrx_ops.rx.rx_stack = hdd_rx_packet_cbk;
2099 } else {
2100 txrx_ops.rx.rx = hdd_rx_packet_cbk;
2101 txrx_ops.rx.rx_stack = NULL;
2102 }
2103
Poddar, Siddarth31797fa2018-01-22 17:24:15 +05302104 txrx_ops.rx.stats_rx = hdd_tx_rx_collect_connectivity_stats_info;
Leo Changfdb45c32016-10-28 11:09:23 -07002105
Jeff Johnsonba388342017-10-02 13:31:01 -07002106 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002107 (struct cdp_pdev *)pdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002108 adapter->session_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07002109 if (!adapter->txrx_vdev) {
Leo Changfdb45c32016-10-28 11:09:23 -07002110 hdd_err("%s find vdev fail", __func__);
2111 return QDF_STATUS_E_FAILURE;
2112 }
2113
2114 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002115 cdp_vdev_register(soc,
Sravan Kumar Kairam43f191b2018-05-04 17:00:39 +05302116 (struct cdp_vdev *)adapter->txrx_vdev, adapter,
2117 (struct cdp_ctrl_objmgr_vdev *)adapter->hdd_vdev, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07002118 if (!txrx_ops.tx.tx) {
2119 hdd_err("%s vdev register fail", __func__);
2120 return QDF_STATUS_E_FAILURE;
2121 }
2122
Jeff Johnsonba388342017-10-02 13:31:01 -07002123 adapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002124 qdf_status = cdp_peer_register(soc,
2125 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302126 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002127 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002128 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302129 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 }
2131
Jeff Johnsonfd060852017-10-04 10:50:51 -07002132 if (!roam_info->fAuthRequired) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 /*
2134 * Connections that do not need Upper layer auth, transition
2135 * TLSHIM directly to 'Authenticated' state
2136 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302137 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002138 hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002139 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002141 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142#else
2143 false
2144#endif
2145 );
2146
Jeff Johnsonba388342017-10-02 13:31:01 -07002147 hdd_conn_set_authenticated(adapter, true);
2148 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002150 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002151 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302152 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002153 hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002154 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002156 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157#else
2158 false
2159#endif
2160 );
Jeff Johnsonba388342017-10-02 13:31:01 -07002161 hdd_conn_set_authenticated(adapter, false);
2162 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302164 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165}
2166
2167/**
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302168 * hdd_send_roamed_ind() - send roamed indication to cfg80211
2169 * @dev: network device
2170 * @bss: cfg80211 roamed bss pointer
2171 * @req_ie: IEs used in reassociation request
2172 * @req_ie_len: Length of the @req_ie
2173 * @resp_ie: IEs received in successful reassociation response
2174 * @resp_ie_len: Length of @resp_ie
2175 *
2176 * Return: none
2177 */
2178#if defined CFG80211_ROAMED_API_UNIFIED || \
2179 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
2180static void hdd_send_roamed_ind(struct net_device *dev,
2181 struct cfg80211_bss *bss, const uint8_t *req_ie,
2182 size_t req_ie_len, const uint8_t *resp_ie,
2183 size_t resp_ie_len)
2184{
2185 struct cfg80211_roam_info info = {0};
2186
2187 info.bss = bss;
2188 info.req_ie = req_ie;
2189 info.req_ie_len = req_ie_len;
2190 info.resp_ie = resp_ie;
2191 info.resp_ie_len = resp_ie_len;
2192 cfg80211_roamed(dev, &info, GFP_KERNEL);
2193}
2194#else
2195static inline void hdd_send_roamed_ind(struct net_device *dev,
2196 struct cfg80211_bss *bss,
2197 const uint8_t *req_ie, size_t req_ie_len,
2198 const uint8_t *resp_ie,
2199 size_t resp_ie_len)
2200{
2201 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
2202 GFP_KERNEL);
2203}
2204#endif
2205
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302206#if defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302207#if defined(WLAN_FEATURE_FILS_SK)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302208void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002209 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302210{
2211 uint8_t *kek;
2212 uint32_t kek_len;
2213
2214 if (is_reassoc) {
2215 kek = csr_roam_info->kek;
2216 kek_len = csr_roam_info->kek_len;
2217 } else {
2218 /*
2219 * This should come for FILS case only.
2220 * Caller should make sure fils_join_rsp is
2221 * not NULL, if there is need to use else where.
2222 */
2223 kek = csr_roam_info->fils_join_rsp->kek;
2224 kek_len = csr_roam_info->fils_join_rsp->kek_len;
2225 }
2226
2227 wlan_hdd_save_gtk_offload_params(adapter, NULL, kek, kek_len,
2228 csr_roam_info->replay_ctr, true);
2229
2230 hdd_debug("Kek len %d", kek_len);
2231}
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302232#else
2233void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002234 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302235{
2236 uint8_t *kek;
2237 uint32_t kek_len;
2238
2239 /*
2240 * is_reassoc is set to true always for Legacy GTK offload
2241 * case, It is false only for FILS case
2242 */
2243 kek = csr_roam_info->kek;
2244 kek_len = csr_roam_info->kek_len;
2245
2246 wlan_hdd_save_gtk_offload_params(adapter, NULL, kek, kek_len,
2247 csr_roam_info->replay_ctr, true);
2248
2249 hdd_debug("Kek len %d", kek_len);
2250}
2251#endif
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302252#endif
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302253/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 * hdd_send_re_assoc_event() - send reassoc event
2255 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07002256 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 * @pCsrRoamInfo: pointer to roam info
2258 * @reqRsnIe: pointer to RSN Information element
2259 * @reqRsnLength: length of RSN IE
2260 *
2261 * Return: none
2262 */
2263static void hdd_send_re_assoc_event(struct net_device *dev,
Jeff Johnson172237b2017-11-07 15:32:59 -08002264 struct hdd_adapter *adapter, struct csr_roam_info *pCsrRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2266{
2267 unsigned int len = 0;
2268 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002269 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2270 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 uint32_t rspRsnLength = 0;
2272 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2274 uint8_t *buf_ptr, ssid_ie_len;
2275 struct cfg80211_bss *bss = NULL;
2276 uint8_t *final_req_ie = NULL;
2277 tCsrRoamConnectedProfile roam_profile;
Jeff Johnsonba388342017-10-02 13:31:01 -07002278 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302279 int chan_no;
2280 int freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002282 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2283
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002285 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002286 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 }
2288
Naveen Rawat14298b92015-11-25 16:27:41 -08002289 if (!assoc_req_ies) {
2290 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002291 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002292 }
Rajeev Kumar Sirasanagandlae5582aa2018-05-02 18:20:20 +05302293
2294 if (!pCsrRoamInfo || !pCsrRoamInfo->pBssDesc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002295 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 goto done;
2297 }
2298
2299 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002300 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 goto done;
2302 }
2303
2304 pFTAssocRsp =
2305 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2306 pCsrRoamInfo->nAssocReqLength);
2307 if (pFTAssocRsp == NULL)
2308 goto done;
2309
2310 /* pFTAssocRsp needs to point to the IEs */
2311 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002312 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002313 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314
2315 /*
2316 * Active session count is decremented upon disconnection, but during
2317 * roaming, there is no disconnect indication and hence active session
2318 * count is not decremented.
2319 * After roaming is completed, active session count is incremented
2320 * as a part of connect indication but effectively after roaming the
2321 * active session count should still be the same and hence upon
2322 * successful reassoc decrement the active session count here.
2323 */
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05302324 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo)) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002325 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002326 adapter->device_mode, adapter->session_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07002327 hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05302328 false);
2329 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330
2331 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2332 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2333 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302334 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2335 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302337 chan_no = pCsrRoamInfo->pBssDesc->channelId;
2338 if (chan_no <= 14)
2339 freq = ieee80211_channel_to_frequency(chan_no,
2340 NL80211_BAND_2GHZ);
2341 else
2342 freq = ieee80211_channel_to_frequency(chan_no,
2343 NL80211_BAND_5GHZ);
Jeff Johnsonba388342017-10-02 13:31:01 -07002344 chan = ieee80211_get_channel(adapter->wdev.wiphy, freq);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302345
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002346 sme_roam_get_connect_profile(hdd_ctx->mac_handle, adapter->session_id,
2347 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302348
Jeff Johnsonba388342017-10-02 13:31:01 -07002349 bss = hdd_cfg80211_get_bss(adapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302350 chan, pCsrRoamInfo->bssid.bytes,
2351 &roam_profile.SSID.ssId[0],
2352 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353
2354 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002355 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 buf_ptr = buf_ssid_ie;
2357 *buf_ptr = SIR_MAC_SSID_EID;
2358 buf_ptr++;
2359 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2360 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302361 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 roam_profile.SSID.length);
2363 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002364 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302365 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002366 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002367 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Kapil Gupta8731e812017-07-11 18:42:39 +05302368 if (final_req_ie == NULL) {
2369 if (bss)
Jeff Johnsonba388342017-10-02 13:31:01 -07002370 cfg80211_put_bss(adapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302372 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302374 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302376 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2377 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2378 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002380 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302381 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002382 final_req_ie, (ssid_ie_len + reqRsnLength));
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302383 hdd_send_roamed_ind(dev, bss, final_req_ie,
2384 (ssid_ie_len + reqRsnLength), rspRsnIe,
2385 rspRsnLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302387 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002388 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2389 pCsrRoamInfo->nAssocReqLength);
2390
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302391 hdd_save_gtk_params(adapter, pCsrRoamInfo, true);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302392
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002393 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302394 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002395 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2396
Jeff Johnsonba388342017-10-02 13:31:01 -07002397 wlan_hdd_send_roam_auth_event(adapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002398 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2399 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002400 pCsrRoamInfo);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302401
2402 hdd_update_hlp_info(dev, pCsrRoamInfo);
2403
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002405 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002407 qdf_mem_free(final_req_ie);
2408 qdf_mem_free(rspRsnIe);
2409 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410}
2411
2412/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302413 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002414 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302415 *
2416 * Return: roam sync status if roaming offloaded else false
2417 */
2418#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson172237b2017-11-07 15:32:59 -08002419bool hdd_is_roam_sync_in_progress(struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302420{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002421 if (roaminfo)
2422 return roaminfo->roamSynchInProgress;
2423 else
2424 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302425}
2426#endif
2427
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002428/**
2429 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2430 * @hddstactx: pointer to HDD sta context
2431 * @roaminfo: pointer to roaminfo structure
2432 *
2433 * This function returns staid for IBSS peer. If peer is broadcast
2434 * MAC address return self staid(0) else find the peer sta id of
2435 * the peer.
2436 *
2437 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2438 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002439static uint8_t hdd_get_ibss_peer_staid(struct hdd_station_ctx *hddstactx,
Jeff Johnson172237b2017-11-07 15:32:59 -08002440 struct csr_roam_info *roaminfo)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002441{
2442 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2443 QDF_STATUS status;
2444
2445 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2446 staid = 0;
2447 } else {
2448 status = hdd_get_peer_sta_id(hddstactx,
2449 &roaminfo->peerMac, &staid);
2450 if (status != QDF_STATUS_SUCCESS) {
2451 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2452 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2453 }
2454 }
2455
2456 return staid;
2457}
Govind Singhedc5cda2015-10-23 17:11:35 +05302458
2459/**
2460 * hdd_change_sta_state_authenticated()-
2461 * This function changes STA state to authenticated
2462 * @adapter: pointer to the adapter structure.
2463 * @roaminfo: pointer to the RoamInfo structure.
2464 *
2465 * This is called from hdd_RoamSetKeyCompleteHandler
2466 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2467 *
2468 * Return: 0 on success and errno on failure
2469 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002470static int hdd_change_sta_state_authenticated(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002471 struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302472{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002473 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002474 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002475 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Jeff Johnson435e1b82017-10-07 14:13:10 -07002476 struct hdd_station_ctx *hddstactx =
2477 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson49432062017-08-28 12:08:45 -07002478 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302479
Jeff Johnson690fe952017-10-25 11:48:39 -07002480 timeout = hddstactx->hdd_reassoc_scenario ?
Dustin Brownf660fb42016-09-09 12:04:00 -07002481 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002482 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002483
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002484 if (QDF_IBSS_MODE == adapter->device_mode)
2485 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2486 else
2487 staid = hddstactx->conn_info.staId[0];
2488
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002489 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302490
2491 /* Connections that do not need Upper layer authentication,
2492 * transition TL to 'Authenticated' state after the keys are set
2493 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002494 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302495 hdd_is_roam_sync_in_progress(roaminfo));
2496 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002497 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2498
Krunal Sonibe766b02016-03-10 13:00:44 -08002499 if ((QDF_STA_MODE == adapter->device_mode) ||
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002500 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
2501 sme_ps_enable_auto_ps_timer(hdd_ctx->mac_handle,
2502 adapter->session_id,
2503 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302504 }
2505
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002506 return qdf_status_to_os_return(status);
2507}
2508
2509/**
2510 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2511 * if key installation is required
2512 * @encr_type: encryption type
2513 *
2514 * Return: true if key installation is required and false otherwise.
2515 */
2516static inline bool hdd_is_key_install_required_for_ibss(
2517 eCsrEncryptionType encr_type)
2518{
2519 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2520 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2521 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05302522 eCSR_ENCRYPT_TYPE_AES_GCMP == encr_type ||
2523 eCSR_ENCRYPT_TYPE_AES_GCMP_256 == encr_type ||
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002524 eCSR_ENCRYPT_TYPE_AES == encr_type)
2525 return true;
2526 else
2527 return false;
2528}
2529
2530/**
2531 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2532 * complete
2533 * @adapter: pointer to HDD adapter
2534 * @roaminfo: pointer to roam info
2535 * @roam_result: roam result
2536 *
2537 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2538 * This function checks for the successful set key completion and update
2539 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2540 *
2541 * Return: None
2542 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002543static void hdd_change_peer_state_after_set_key(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002544 struct csr_roam_info *roaminfo,
2545 eCsrRoamResult roam_result)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002546{
Jeff Johnson435e1b82017-10-07 14:13:10 -07002547 struct hdd_station_ctx *hdd_sta_ctx =
2548 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002549 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2550
2551 /*
2552 * If the security mode is one of the following, IBSS peer will be
2553 * waiting in CONN state and we will move the peer state to AUTH
2554 * here. For non-secure connection, no need to wait for set-key complete
2555 * peer will be moved to AUTH in hdd_roam_register_sta.
2556 */
2557 if (QDF_IBSS_MODE == adapter->device_mode) {
2558 if (hdd_is_key_install_required_for_ibss(encr_type))
2559 hdd_change_sta_state_authenticated(adapter, roaminfo);
2560
2561 return;
2562 }
2563
2564 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2565 hdd_sta_ctx->conn_info.gtk_installed = true;
2566 /*
2567 * PTK exchange happens in preauthentication itself if key_mgmt
2568 * is FT-PSK, ptk_installed was false as there is no set PTK
2569 * after roaming. STA TL state moves to authenticated only if
2570 * ptk_installed is true. So, make ptk_installed to true in
2571 * case of 11R roaming.
2572 */
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002573 if (sme_neighbor_roam_is11r_assoc(adapter->hdd_ctx->mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002574 adapter->session_id))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002575 hdd_sta_ctx->conn_info.ptk_installed = true;
2576 } else {
2577 hdd_sta_ctx->conn_info.ptk_installed = true;
2578 }
2579
2580 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2581 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2582 * unicast key and it was resulting in sending few un-encrypted packet.
2583 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2584 * set the unicast and broadcast key.
2585 */
2586 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2587 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2588 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2589 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2590 if (hdd_sta_ctx->conn_info.gtk_installed &&
2591 hdd_sta_ctx->conn_info.ptk_installed)
2592 hdd_change_sta_state_authenticated(adapter, roaminfo);
2593 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2594 hdd_change_sta_state_authenticated(adapter, roaminfo);
2595 }
2596
2597 if (hdd_sta_ctx->conn_info.gtk_installed &&
2598 hdd_sta_ctx->conn_info.ptk_installed) {
2599 hdd_sta_ctx->conn_info.gtk_installed = false;
2600 hdd_sta_ctx->conn_info.ptk_installed = false;
2601 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302602}
2603
2604/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 * hdd_roam_set_key_complete_handler() - Update the security parameters
Jeff Johnsonba388342017-10-02 13:31:01 -07002606 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002607 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 * @roamId: roam id
2609 * @roamStatus: roam status
2610 * @roamResult: roam result
2611 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302612 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 */
Jeff Johnson172237b2017-11-07 15:32:59 -08002614static QDF_STATUS
2615hdd_roam_set_key_complete_handler(struct hdd_adapter *adapter,
2616 struct csr_roam_info *roam_info,
2617 uint32_t roamId,
2618 eRoamCmdStatus roamStatus,
2619 eCsrRoamResult roamResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620{
2621 eCsrEncryptionType connectedCipherAlgo;
Jeff Johnson389e16b2018-05-05 23:32:55 -07002622 bool connected = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002623 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302624
Dustin Brown491d54b2018-03-14 12:39:11 -07002625 hdd_enter();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626
Jeff Johnsonfd060852017-10-04 10:50:51 -07002627 if (NULL == roam_info) {
2628 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302629 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 }
2631 /*
2632 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2633 * then go to 'authenticated'. For all other authentication types
2634 * (those that do not require upper layer authentication) we can put TL
2635 * directly into 'authenticated' state.
2636 */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05302637 hdd_debug("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638 MAC_ADDRESS_STR, roamStatus, roamResult,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002639 MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640
Jeff Johnson389e16b2018-05-05 23:32:55 -07002641 connected = hdd_conn_get_connected_cipher_algo(sta_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 &connectedCipherAlgo);
Jeff Johnson389e16b2018-05-05 23:32:55 -07002643 if (connected) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002644 hdd_change_peer_state_after_set_key(adapter, roam_info,
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002645 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646 }
2647
Dustin Browne74003f2018-03-14 12:51:58 -07002648 hdd_exit();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302649 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650}
2651
2652/**
2653 * hdd_perform_roam_set_key_complete() - perform set key complete
Jeff Johnsonba388342017-10-02 13:31:01 -07002654 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 *
2656 * Return: none
2657 */
Jeff Johnsonba388342017-10-02 13:31:01 -07002658void hdd_perform_roam_set_key_complete(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302660 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002661 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson172237b2017-11-07 15:32:59 -08002662 struct csr_roam_info roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002663
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302665 qdf_mem_copy(roamInfo.bssid.bytes,
Jeff Johnsond377dce2017-10-04 10:32:42 -07002666 sta_ctx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302667 qdf_mem_copy(roamInfo.peerMac.bytes,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002668 sta_ctx->roam_info.peer_mac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302670 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002671 hdd_roam_set_key_complete_handler(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 &roamInfo,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002673 sta_ctx->roam_info.roam_id,
2674 sta_ctx->roam_info.roam_status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302676 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002677 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002679 sta_ctx->roam_info.defer_key_complete = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680}
2681
Vignesh Viswanathan3fa1d382017-08-02 19:36:43 +05302682#if defined(WLAN_FEATURE_FILS_SK) && \
2683 (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \
2684 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)))
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002685void hdd_clear_fils_connection_info(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302686{
Jeff Johnson844eec72018-03-13 11:48:18 -07002687 struct csr_roam_profile *roam_profile;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302688
2689 if ((adapter->device_mode == QDF_SAP_MODE) ||
2690 (adapter->device_mode == QDF_P2P_GO_MODE))
2691 return;
2692
Jeff Johnson844eec72018-03-13 11:48:18 -07002693 roam_profile = hdd_roam_profile(adapter);
2694 if (roam_profile->fils_con_info) {
2695 qdf_mem_free(roam_profile->fils_con_info);
2696 roam_profile->fils_con_info = NULL;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302697 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302698
Jeff Johnson844eec72018-03-13 11:48:18 -07002699 if (roam_profile->hlp_ie) {
2700 qdf_mem_free(roam_profile->hlp_ie);
2701 roam_profile->hlp_ie = NULL;
2702 roam_profile->hlp_ie_len = 0;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302703 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302704}
2705#endif
2706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707/**
2708 * hdd_association_completion_handler() - association completion handler
Jeff Johnsonba388342017-10-02 13:31:01 -07002709 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002710 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 * @roamId: roam id
2712 * @roamStatus: roam status
2713 * @roamResult: roam result
2714 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302715 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 */
Jeff Johnson435e1b82017-10-07 14:13:10 -07002717static QDF_STATUS
2718hdd_association_completion_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002719 struct csr_roam_info *roam_info,
Jeff Johnson435e1b82017-10-07 14:13:10 -07002720 uint32_t roamId,
2721 eRoamCmdStatus roamStatus,
2722 eCsrRoamResult roamResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723{
Jeff Johnsonba388342017-10-02 13:31:01 -07002724 struct net_device *dev = adapter->dev;
2725 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002726 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302727 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002729 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 bool hddDisconInProgress = false;
2732 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302733 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302734 bool ok;
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002735 mac_handle_t mac_handle;
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05302736 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737
Jeff Johnson8095a312017-09-03 09:13:24 -07002738 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302740 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 }
2742
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302743 /* validate config */
Jeff Johnson8095a312017-09-03 09:13:24 -07002744 if (!hdd_ctx->config) {
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302745 hdd_err("config is NULL");
2746 return QDF_STATUS_E_NULL_VALUE;
2747 }
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05302748
2749 /*
2750 * Enable roaming on other STA iface except this one.
2751 * Firmware dosent support connection on one STA iface while
2752 * roaming on other STA iface
2753 */
2754 wlan_hdd_enable_roaming(adapter);
2755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 /* HDD has initiated disconnect, do not send connect result indication
2757 * to kernel as it will be handled by __cfg80211_disconnect.
2758 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302759 if (((eConnectionState_Disconnecting ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07002760 sta_ctx->conn_info.connState) ||
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302761 (eConnectionState_NotConnected ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07002762 sta_ctx->conn_info.connState)) &&
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302763 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2764 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002765 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002766 sta_ctx->conn_info.connState,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002767 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 hddDisconInProgress = true;
2769 }
2770
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002771 mac_handle = hdd_ctx->mac_handle;
2772
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002774 if (NULL == roam_info) {
2775 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302776 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777 }
2778 if (!hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07002779 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 eConnectionState_Associated);
2781 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002784 hdd_conn_save_connect_info(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002786
Jeff Johnsonba388342017-10-02 13:31:01 -07002787 if (hdd_add_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002788 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789#ifdef FEATURE_WLAN_WAPI
Jeff Johnsonfd060852017-10-04 10:50:51 -07002790 if (roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
Jeff Johnsonfd060852017-10-04 10:50:51 -07002792 || roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002794 adapter->wapi_info.is_wapi_sta = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 } else {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002796 adapter->wapi_info.is_wapi_sta = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 }
2798#endif /* FEATURE_WLAN_WAPI */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002799 hdd_debug("bss_descr[%d] devicemode[%d]", !!roam_info->pBssDesc,
Jeff Johnsonba388342017-10-02 13:31:01 -07002800 adapter->device_mode);
2801 if ((QDF_STA_MODE == adapter->device_mode) &&
Jeff Johnsonfd060852017-10-04 10:50:51 -07002802 roam_info->pBssDesc) {
2803 ie_len = GET_IE_LEN_IN_BSS(roam_info->pBssDesc->length);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002804 sta_ctx->ap_supports_immediate_power_save =
Krunal Soni364e0872017-05-10 21:24:34 -07002805 wlan_hdd_is_ap_supports_immediate_power_save(
Jeff Johnsonfd060852017-10-04 10:50:51 -07002806 (uint8_t *) roam_info->pBssDesc->ieFields,
Krunal Soni364e0872017-05-10 21:24:34 -07002807 ie_len);
2808 hdd_debug("ap_supports_immediate_power_save flag [%d]",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002809 sta_ctx->ap_supports_immediate_power_save);
Krunal Soni364e0872017-05-10 21:24:34 -07002810 }
2811
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 /* Indicate 'connect' status to user space */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002813 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814
Jeff Johnson8095a312017-09-03 09:13:24 -07002815 if (policy_mgr_is_mcc_in_24G(hdd_ctx->hdd_psoc)) {
2816 if (hdd_ctx->miracast_value)
Jeff Johnsonba388342017-10-02 13:31:01 -07002817 wlan_hdd_set_mas(adapter,
Jeff Johnson8095a312017-09-03 09:13:24 -07002818 hdd_ctx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819 }
2820
2821 /* Initialize the Linkup event completion variable */
Jeff Johnsonba388342017-10-02 13:31:01 -07002822 INIT_COMPLETION(adapter->linkup_event_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823
2824 /*
2825 * Sometimes Switching ON the Carrier is taking time to activate
2826 * the device properly. Before allowing any packet to go up to
2827 * the application, device activation has to be ensured for
2828 * proper queue mapping by the kernel. we have registered net
2829 * device notifier for device change notification. With this we
2830 * will come to know that the device is getting
2831 * activated properly.
2832 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07002833 if (sta_ctx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002834 /*
2835 * Enable Linkup Event Servicing which allows the net
2836 * device notifier to set the linkup event variable.
2837 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002838 adapter->is_link_up_service_needed = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002840 /* Switch on the Carrier to activate the device */
Jeff Johnsonba388342017-10-02 13:31:01 -07002841 wlan_hdd_netif_queue_control(adapter,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002842 WLAN_NETIF_CARRIER_ON,
2843 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002845 /*
2846 * Wait for the Link to up to ensure all the queues
2847 * are set properly by the kernel.
2848 */
2849 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07002850 &adapter->linkup_event_var,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002851 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2852 );
2853 if (!rc)
2854 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002856 /*
2857 * Disable Linkup Event Servicing - no more service
2858 * required from the net device notifier call.
2859 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002860 adapter->is_link_up_service_needed = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002861 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07002862 sta_ctx->ft_carrier_on = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002863 ft_carrier_on = true;
2864 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07002865 if (roam_info->staId < HDD_MAX_ADAPTERS)
Jeff Johnsonfd060852017-10-04 10:50:51 -07002866 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 else
Jeff Johnsonfd060852017-10-04 10:50:51 -07002868 hdd_err("Wrong Staid: %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05302870 if (ucfg_ipa_is_enabled())
2871 ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev, adapter->dev,
2872 adapter->device_mode,
2873 roam_info->staId,
2874 adapter->session_id,
2875 WLAN_IPA_STA_CONNECT,
2876 roam_info->bssid.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877
2878#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07002879 wlan_hdd_auto_shutdown_enable(hdd_ctx, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880#endif
2881
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302882 hdd_debug("check if STA chan ok for DNBS");
Jeff Johnson8095a312017-09-03 09:13:24 -07002883 if (policy_mgr_is_chan_ok_for_dnbs(hdd_ctx->hdd_psoc,
Jeff Johnsond377dce2017-10-04 10:32:42 -07002884 sta_ctx->conn_info.operationChannel,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302885 &ok)) {
2886 hdd_err("Unable to check DNBS eligibility for chan:%d",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002887 sta_ctx->conn_info.operationChannel);
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302888 return QDF_STATUS_E_FAILURE;
2889 }
2890
2891 if (!ok) {
2892 hdd_err("Chan:%d not suitable for DNBS",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002893 sta_ctx->conn_info.operationChannel);
Jeff Johnsonba388342017-10-02 13:31:01 -07002894 wlan_hdd_netif_queue_control(adapter,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302895 WLAN_NETIF_CARRIER_OFF,
2896 WLAN_CONTROL_PATH);
2897 if (!hddDisconInProgress) {
2898 hdd_err("Disconnecting...");
2899 sme_roam_disconnect(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002900 mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002901 adapter->session_id,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302902 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2903 }
2904 return QDF_STATUS_E_FAILURE;
2905 }
2906
Nirav Shah1da77682016-05-03 20:16:39 +05302907 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002908 adapter->session_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002909 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302910 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2911
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 /*
2913 * For reassoc, the station is already registered, all we need
2914 * is to change the state of the STA in TL.
2915 * If authentication is required (WPA/WPA2/DWEP), change TL to
2916 * CONNECTED instead of AUTHENTICATED.
2917 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002918 if (!roam_info->fReassocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 u8 *pFTAssocRsp = NULL;
2921 unsigned int assocRsplen = 0;
2922 u8 *pFTAssocReq = NULL;
2923 unsigned int assocReqlen = 0;
2924 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2926 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2927
2928 /* add bss_id to cfg80211 data base */
2929 bss =
Jeff Johnsonba388342017-10-02 13:31:01 -07002930 wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002931 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302933 hdd_err("wlan: Not able to create BSS entry");
Jeff Johnsonba388342017-10-02 13:31:01 -07002934 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 WLAN_NETIF_CARRIER_OFF,
2936 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302937 if (!hddDisconInProgress) {
2938 /*
2939 * Here driver was not able to add bss
2940 * in cfg80211 database this can happen
2941 * if connected channel is not valid,
2942 * i.e reg domain was changed during
2943 * connection. Queue disconnect for the
2944 * session if disconnect is not in
2945 * progress.
2946 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002947 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302948 sme_roam_disconnect(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002949 mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002950 adapter->session_id,
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302951 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2952 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302953 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 }
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302955
Jeff Johnsonc66d3102018-02-28 11:58:26 -08002956 cfg80211_put_bss(hdd_ctx->wiphy, bss);
2957
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302958 /* Association Response */
2959 pFTAssocRsp =
2960 (u8 *) (roam_info->pbFrames +
2961 roam_info->nBeaconLength +
2962 roam_info->nAssocReqLength);
2963 if (pFTAssocRsp != NULL) {
2964 /*
2965 * pFTAssocRsp needs to point to the IEs
2966 */
2967 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2968 hdd_debug("AssocRsp is now at %02x%02x",
2969 (unsigned int)pFTAssocRsp[0],
2970 (unsigned int)pFTAssocRsp[1]);
2971 assocRsplen =
2972 roam_info->nAssocRspLength -
2973 FT_ASSOC_RSP_IES_OFFSET;
2974
2975 hdd_debug("assocRsplen %d", assocRsplen);
2976 hdd_debug("Assoc Rsp IE dump");
2977 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
2978 QDF_TRACE_LEVEL_DEBUG,
2979 pFTAssocRsp,
2980 assocRsplen);
2981 } else {
2982 hdd_debug("AssocRsp is NULL");
2983 assocRsplen = 0;
2984 }
2985
2986 /* Association Request */
2987 pFTAssocReq = (u8 *) (roam_info->pbFrames +
2988 roam_info->nBeaconLength);
2989 if (pFTAssocReq != NULL) {
2990 if (!ft_carrier_on) {
2991 /*
2992 * pFTAssocReq needs to point to
2993 * the IEs
2994 */
2995 pFTAssocReq +=
2996 FT_ASSOC_REQ_IES_OFFSET;
2997 hdd_debug("pFTAssocReq is now at %02x%02x",
2998 (unsigned int)
2999 pFTAssocReq[0],
3000 (unsigned int)
3001 pFTAssocReq[1]);
3002 assocReqlen =
3003 roam_info->nAssocReqLength -
3004 FT_ASSOC_REQ_IES_OFFSET;
3005 } else {
3006 /*
3007 * This should contain only the
3008 * FTIEs
3009 */
3010 assocReqlen =
3011 roam_info->nAssocReqLength;
3012 }
3013
3014 hdd_debug("assocReqlen %d", assocReqlen);
3015 hdd_debug("Assoc/Reassoc Req IE dump");
3016 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
3017 QDF_TRACE_LEVEL_DEBUG,
3018 pFTAssocReq,
3019 assocReqlen);
3020 } else {
3021 hdd_debug("AssocReq is NULL");
3022 assocReqlen = 0;
3023 }
3024
Jeff Johnsonfd060852017-10-04 10:50:51 -07003025 if (roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 eCSR_AUTH_TYPE_FT_RSN
Jeff Johnsonfd060852017-10-04 10:50:51 -07003027 || roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 eCSR_AUTH_TYPE_FT_RSN_PSK) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08003030 if (!hddDisconInProgress &&
Jeff Johnsonfd060852017-10-04 10:50:51 -07003031 roam_info->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05303032 struct cfg80211_bss *roam_bss;
3033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 /*
3035 * After roaming is completed,
3036 * active session count is
3037 * incremented as a part of
3038 * connect indication but
3039 * effectively the active
3040 * session count should still
3041 * be the same and hence upon
3042 * successful reassoc
3043 * decrement the active session
3044 * count here.
3045 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08003046 if (!hdd_is_roam_sync_in_progress
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303047 (roam_info)) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003048 policy_mgr_decr_session_set_pcl(
Jeff Johnson8095a312017-09-03 09:13:24 -07003049 hdd_ctx->hdd_psoc,
Jeff Johnsonba388342017-10-02 13:31:01 -07003050 adapter->device_mode,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003051 adapter->session_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07003052 hdd_green_ap_start_state_mc(
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303053 hdd_ctx,
3054 adapter->device_mode,
3055 false);
3056 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003057 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003058 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 chan =
3060 ieee80211_get_channel
Jeff Johnsonba388342017-10-02 13:31:01 -07003061 (adapter->wdev.wiphy,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003062 (int)roam_info->pBssDesc->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 channelId);
Naveen Rawat14298b92015-11-25 16:27:41 -08003064
Abhishek Singh533c9da2017-05-04 10:23:34 +05303065 roam_bss =
3066 hdd_cfg80211_get_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07003067 adapter->wdev.wiphy,
Abhishek Singh533c9da2017-05-04 10:23:34 +05303068 chan,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003069 roam_info->bssid.bytes,
3070 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05303071 pConnectedProfile->SSID.ssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003072 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05303073 pConnectedProfile->SSID.length);
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303074
3075 cdp_hl_fc_set_td_limit(soc,
3076 adapter->session_id,
3077 sta_ctx->
3078 conn_info.operationChannel);
3079
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05303080 hdd_send_roamed_ind(
3081 dev,
3082 roam_bss,
3083 pFTAssocReq,
3084 assocReqlen,
3085 pFTAssocRsp,
3086 assocRsplen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05303087 wlan_hdd_send_roam_auth_event(
Jeff Johnsonba388342017-10-02 13:31:01 -07003088 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003089 roam_info->bssid.bytes,
Abhishek Singh533c9da2017-05-04 10:23:34 +05303090 pFTAssocReq,
3091 assocReqlen,
3092 pFTAssocRsp,
3093 assocRsplen,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003094 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 }
3096 if (sme_get_ftptk_state
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003097 (mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003098 adapter->session_id)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 sme_set_ftptk_state
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003100 (mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003101 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 false);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003103 roam_info->fAuthRequired =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 false;
3105
Jeff Johnsond377dce2017-10-04 10:32:42 -07003106 qdf_mem_copy(sta_ctx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 roam_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003108 roam_info->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303109 QDF_MAC_ADDR_SIZE);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003110 qdf_mem_copy(sta_ctx->
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003111 roam_info.peer_mac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003112 roam_info->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303113 QDF_MAC_ADDR_SIZE);
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003114 sta_ctx->roam_info.roam_id =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 roamId;
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003116 sta_ctx->roam_info.roam_status =
3117 roamStatus;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003118 sta_ctx->roam_info.
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003119 defer_key_complete = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 }
3121 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003122 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003123 ft_carrier_on);
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303124 cdp_hl_fc_set_td_limit(soc,
3125 adapter->session_id,
3126 sta_ctx->conn_info.operationChannel);
Anurag Chouhanc4092922016-09-08 15:56:11 +05303127 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003128 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303129 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003130 roam_info,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303131 pFTAssocReq,
3132 assocReqlen,
3133 pFTAssocRsp,
3134 assocRsplen,
3135 WLAN_STATUS_SUCCESS,
3136 GFP_KERNEL,
3137 false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003138 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003139 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08003140 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 /*
3142 * wpa supplicant expecting WPA/RSN IE in
3143 * connect result.
3144 */
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003145 sme_roam_get_wpa_rsn_req_ie(mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003146 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 &reqRsnLength,
3148 reqRsnIe);
3149
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003150 sme_roam_get_wpa_rsn_rsp_ie(mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003151 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 &rspRsnLength,
3153 rspRsnIe);
3154 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 if (ft_carrier_on)
3156 hdd_send_re_assoc_event(dev,
Jeff Johnsonba388342017-10-02 13:31:01 -07003157 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003158 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 reqRsnIe,
3160 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07003161 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003162 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003163 MAC_ADDRESS_STR
3164 " result:%d and Status:%d",
3165 MAC_ADDR_ARRAY
Jeff Johnsonfd060852017-10-04 10:50:51 -07003166 (roam_info->bssid.bytes),
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003167 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168
3169 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05303170 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003171 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303172 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003173 roam_info,
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303174 pFTAssocReq,
3175 assocReqlen,
3176 pFTAssocRsp,
3177 assocRsplen,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303178 WLAN_STATUS_SUCCESS,
3179 GFP_KERNEL,
3180 false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003181 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 }
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303183 cdp_hl_fc_set_td_limit(soc,
3184 adapter->session_id,
3185 sta_ctx->conn_info.operationChannel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 }
3187 }
3188 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 /*
3190 * Perform any WMM-related association
3191 * processing.
3192 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003193 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 eCSR_BSS_TYPE_INFRASTRUCTURE);
3195
3196 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08003197 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003199 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003200 roam_info,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003201 sta_ctx->conn_info.staId[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07003202 NULL, roam_info->pBssDesc);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303203 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003204 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 WLAN_WAKE_ALL_NETIF_QUEUE,
3206 WLAN_CONTROL_PATH);
3207
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 }
3209 } else {
3210 /*
3211 * wpa supplicant expecting WPA/RSN IE in connect result
3212 * in case of reassociation also need to indicate it to
3213 * supplicant.
3214 */
Jeff Johnson0a078b52018-06-01 16:15:54 -07003215 sme_roam_get_wpa_rsn_req_ie(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003216 mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003217 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 &reqRsnLength, reqRsnIe);
3219
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303220 cdp_hl_fc_set_td_limit(soc,
3221 adapter->session_id,
3222 sta_ctx->conn_info.operationChannel);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003223 hdd_send_re_assoc_event(dev, adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 reqRsnIe, reqRsnLength);
3225 /* Reassoc successfully */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003226 if (roam_info->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303227 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003228 hdd_change_peer_state(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003229 sta_ctx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003230 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003232 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233#else
3234 false
3235#endif
3236 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003237 hdd_conn_set_authenticated(adapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003238 hdd_objmgr_set_peer_mlme_auth_state(
Jeff Johnsonba388342017-10-02 13:31:01 -07003239 adapter->hdd_vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003240 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003242 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Jeff Johnsond377dce2017-10-04 10:32:42 -07003243 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303244 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003245 hdd_change_peer_state(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003246 sta_ctx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003247 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003249 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250#else
3251 false
3252#endif
3253 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003254 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003255 hdd_objmgr_set_peer_mlme_auth_state(
Jeff Johnsonba388342017-10-02 13:31:01 -07003256 adapter->hdd_vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003257 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 }
3259
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303260 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 /*
3262 * Perform any WMM-related association
3263 * processing
3264 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003265 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 eCSR_BSS_TYPE_INFRASTRUCTURE);
3267 }
3268
3269 /* Start the tx queues */
3270#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003271 if (roam_info->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003272 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273#endif
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303274 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003275 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 WLAN_WAKE_ALL_NETIF_QUEUE,
3277 WLAN_CONTROL_PATH);
3278 }
3279
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303280 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003281 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303282 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 }
3284#ifdef WLAN_FEATURE_11W
Jeff Johnsondc179f42017-10-21 11:27:26 -07003285 qdf_mem_zero(&adapter->hdd_stats.hdd_pmf_stats,
3286 sizeof(adapter->hdd_stats.hdd_pmf_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287#endif
Frank Liu064ebd42018-05-03 14:22:39 +08003288 hdd_debug("check for SAP restart");
3289 policy_mgr_check_concurrent_intf_and_restart_sap(
3290 hdd_ctx->hdd_psoc);
Dundi Ravitejaffa9bf42018-08-21 19:40:36 +05303291 if (roam_info->pBssDesc)
3292 policy_mgr_checkn_update_hw_mode_single_mac_mode
3293 (hdd_ctx->hdd_psoc,
3294 roam_info->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05303296 bool connect_timeout = false;
Tushnim Bhattacharyya3f780532018-08-01 19:11:40 -07003297 /* do we need to change the HW mode */
3298 policy_mgr_check_n_start_opportunistic_timer(hdd_ctx->hdd_psoc);
Vignesh Viswanathan014096a2017-12-07 01:24:44 +05303299 if (roam_info && roam_info->is_fils_connection &&
3300 eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult)
3301 qdf_copy_macaddr(&roam_info->bssid,
3302 &sta_ctx->requested_bssid);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003303 if (roam_info)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303304 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003305 " result: %d and Status: %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003306 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303307 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303309 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003310 " result: %d and Status: %d",
Jeff Johnson731bc322017-10-14 19:53:44 -07003311 MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303312 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05303313
3314 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
Jeff Johnsonfd060852017-10-04 10:50:51 -07003315 (roam_info &&
Abhishek Singhc9941602016-08-09 16:06:22 +05303316 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003317 roam_info->statusCode) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303318 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003319 roam_info->statusCode) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303320 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003321 roam_info->statusCode)))) {
Jeff Johnsonba388342017-10-02 13:31:01 -07003322 wlan_hdd_cfg80211_update_bss_list(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003323 roam_info ?
3324 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003325 sta_ctx->requested_bssid.bytes);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003326 sme_remove_bssid_from_scan_list(mac_handle,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003327 roam_info ?
3328 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003329 sta_ctx->requested_bssid.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303330 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303331 }
3332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 /*
3334 * CR465478: Only send up a connection failure result when CSR
3335 * has completed operation - with a ASSOCIATION_FAILURE status.
3336 */
3337 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3338 && !hddDisconInProgress) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003339 if (roam_info) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003340 hdd_err("send connect failure to nl80211: for bssid "
3341 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003342 " result: %d and Status: %d reasoncode: %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003343 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003344 roamResult, roamStatus,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003345 roam_info->reasonCode);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003346 sta_ctx->conn_info.assoc_status_code =
Jeff Johnsonfd060852017-10-04 10:50:51 -07003347 roam_info->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003348 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003349 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003351 " result: %d and status: %d ",
Jeff Johnson731bc322017-10-14 19:53:44 -07003352 MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003354 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003355 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303356 wlan_deregister_txrx_packetdump();
3357
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 /* inform association failure event to nl80211 */
3359 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3360 roamResult) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003361 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303362 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003363 roam_info->bssid.bytes,
3364 roam_info, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303366 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303367 connect_timeout,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003368 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303370 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003371 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303372 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303374 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303375 connect_timeout,
3376 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003378 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303379 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003380 roam_info->bssid.bytes,
3381 roam_info, NULL, 0, NULL, 0,
3382 roam_info->reasonCode ?
3383 roam_info->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303385 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303386 connect_timeout,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003387 roam_info->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003388 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303389 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003390 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303391 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303393 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303394 connect_timeout,
3395 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003397 hdd_clear_roam_profile_ie(adapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003398 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3399 && !hddDisconInProgress)) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003400 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003401 sta_ctx->requested_bssid.bytes,
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003402 NULL, NULL, 0, NULL, 0,
3403 WLAN_STATUS_UNSPECIFIED_FAILURE,
3404 GFP_KERNEL,
3405 connect_timeout,
3406 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 }
3408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 /*
3410 * Set connection state to eConnectionState_NotConnected only
3411 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003412 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003414 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3415 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 && !hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07003417 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 eConnectionState_NotConnected);
3419 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003420 hdd_wmm_init(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303422 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003423 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303424 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 WLAN_CONTROL_PATH);
Abhishek Singh0edeba02018-06-05 10:04:08 +05303426 /*
3427 * if hddDisconInProgress is set and roamResult is
3428 * eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE that mean HDD is
3429 * waiting on disconnect_comp_var so unblock anyone waiting for
3430 * disconnect to complete.
3431 */
3432 if ((roamResult == eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE) &&
3433 hddDisconInProgress)
3434 complete(&adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 }
3436
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303437 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438}
3439
3440/**
3441 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
Jeff Johnsonba388342017-10-02 13:31:01 -07003442 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003443 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 * @roamId: roam id
3445 * @roamStatus: roam status
3446 * @roamResult: roam result
3447 *
3448 * Here we update the status of the Ibss when we receive information that we
3449 * have started/joined an ibss session.
3450 *
3451 * Return: none
3452 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003453static void hdd_roam_ibss_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003454 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 uint32_t roamId,
3456 eRoamCmdStatus roamStatus,
3457 eCsrRoamResult roamResult)
3458{
Jeff Johnsonba388342017-10-02 13:31:01 -07003459 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003460
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003461 hdd_debug("%s: id %d, status %d, result %d",
Jeff Johnsonba388342017-10-02 13:31:01 -07003462 adapter->dev->name, roamId,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003463 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464
3465 switch (roamResult) {
3466 /* both IBSS Started and IBSS Join should come in here. */
3467 case eCSR_ROAM_RESULT_IBSS_STARTED:
3468 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3469 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3470 {
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003471 struct hdd_station_ctx *hdd_sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003472 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dustin Brownce5b3d32018-01-17 15:07:38 -08003473 struct qdf_mac_addr broadcastMacAddr = QDF_MAC_ADDR_BCAST_INIT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474
Jeff Johnsonfd060852017-10-04 10:50:51 -07003475 if (NULL == roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303476 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 return;
3478 }
3479
3480 /* When IBSS Started comes from CSR, we need to move
3481 * connection state to IBSS Disconnected (meaning no peers
3482 * are in the IBSS).
3483 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003484 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 eConnectionState_IbssDisconnected);
3486 /* notify wmm */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003487 hdd_wmm_connect(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303489
Jeff Johnsonfd060852017-10-04 10:50:51 -07003490 hdd_sta_ctx->broadcast_staid = roam_info->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303491
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003492 if (roam_info->staId < HDD_MAX_ADAPTERS)
3493 hdd_ctx->sta_to_adapter[roam_info->staId] =
3494 adapter;
3495 else
3496 hdd_debug("invalid sta id %d", roam_info->staId);
Abhishek Singh44725482017-11-02 16:53:23 +05303497
Jeff Johnsonfd060852017-10-04 10:50:51 -07003498 hdd_roam_register_sta(adapter, roam_info,
3499 roam_info->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 &broadcastMacAddr,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003501 roam_info->pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502
Jeff Johnsonfd060852017-10-04 10:50:51 -07003503 if (roam_info->pBssDesc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 struct cfg80211_bss *bss;
3505#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3506 struct ieee80211_channel *chan;
3507 int chan_no;
3508 unsigned int freq;
3509#endif
3510 /* we created the IBSS, notify supplicant */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303511 hdd_debug("%s: created ibss " MAC_ADDRESS_STR,
Jeff Johnsonba388342017-10-02 13:31:01 -07003512 adapter->dev->name,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003513 MAC_ADDR_ARRAY(
Jeff Johnsonfd060852017-10-04 10:50:51 -07003514 roam_info->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515
3516 /* we must first give cfg80211 the BSS information */
Jeff Johnsonba388342017-10-02 13:31:01 -07003517 bss = wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003518 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003520 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003521 adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 return;
3523 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303524 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003525 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3527 WLAN_CONTROL_PATH);
3528
3529#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003530 chan_no = roam_info->pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531
3532 if (chan_no <= 14)
3533 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003534 HDD_NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 else
3536 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003537 HDD_NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538
Jeff Johnsonba388342017-10-02 13:31:01 -07003539 chan = ieee80211_get_channel(adapter->wdev.wiphy, freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540
3541 if (chan)
Jeff Johnsonba388342017-10-02 13:31:01 -07003542 cfg80211_ibss_joined(adapter->dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 bss->bssid, chan,
3544 GFP_KERNEL);
3545 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003546 hdd_warn("%s: chanId: %d, can't find channel",
Jeff Johnsonba388342017-10-02 13:31:01 -07003547 adapter->dev->name,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003548 (int)roam_info->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003550 cfg80211_ibss_joined(adapter->dev, bss->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 GFP_KERNEL);
3552#endif
3553 cfg80211_put_bss(
Jeff Johnson8095a312017-09-03 09:13:24 -07003554 hdd_ctx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555 bss);
3556 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003557 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003558 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003559 adapter->device_mode, adapter->session_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07003560 hdd_green_ap_start_state_mc(hdd_ctx,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303561 adapter->device_mode, true);
Krunal Soni2c68f232015-10-26 20:52:51 -07003562 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3563 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003564 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003565 adapter->session_id);
Krunal Soni2c68f232015-10-26 20:52:51 -07003566 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 break;
3568 }
3569
3570 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3571 {
Jeff Johnsonba388342017-10-02 13:31:01 -07003572 hdd_err("%s: unable to create IBSS", adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 break;
3574 }
3575
3576 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003577 hdd_err("%s: unexpected result %d",
Jeff Johnsonba388342017-10-02 13:31:01 -07003578 adapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 break;
3580 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581}
3582
3583/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003584 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3585 * @sta_ctx: pointer to hdd station context
3586 * @sta_id: station ID
3587 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 *
3589 * This information is passed to iwconfig later. The peer that joined
3590 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003591
3592 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003594bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003595 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003597 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003599 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303600 if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003601 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003602 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003603 sta_ctx->conn_info.staId[idx] = sta_id;
3604 qdf_copy_macaddr(
3605 &sta_ctx->conn_info.peerMacAddress[idx],
3606 peer_mac_addr);
3607 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 }
3609 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003610 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611}
3612
3613/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003614 * hdd_delete_peer() - removes peer from hdd station context peer table
3615 * @sta_ctx: pointer to hdd station context
3616 * @sta_id: station ID
3617 *
3618 * Return: None
3619 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003620void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id)
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003621{
3622 int i;
3623
3624 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3625 if (sta_id == sta_ctx->conn_info.staId[i]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303626 sta_ctx->conn_info.staId[i] = HDD_WLAN_INVALID_STA_ID;
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003627 return;
3628 }
3629 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003630}
3631
3632/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
Jeff Johnsonba388342017-10-02 13:31:01 -07003634 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635 * @staId: station id
3636 *
3637 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003638 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 * false otherwise.
3640 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003641static bool roam_remove_ibss_station(struct hdd_adapter *adapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642{
3643 bool fSuccess = false;
3644 int idx = 0;
3645 uint8_t valid_idx = 0;
3646 uint8_t del_idx = 0;
3647 uint8_t empty_slots = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003648 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649
Naveen Rawatc45d1622016-07-05 12:20:09 -07003650 for (idx = 0; idx < MAX_PEERS; idx++) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003651 if (staId == sta_ctx->conn_info.staId[idx]) {
3652 sta_ctx->conn_info.staId[idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303653 HDD_WLAN_INVALID_STA_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654
Jeff Johnsond377dce2017-10-04 10:32:42 -07003655 qdf_zero_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 peerMacAddress[idx]);
3657
3658 fSuccess = true;
3659
3660 /*
3661 * Note the deleted Index, if its 0 we need special
3662 * handling.
3663 */
3664 del_idx = idx;
3665
3666 empty_slots++;
3667 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003668 if (sta_ctx->conn_info.staId[idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003669 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 valid_idx = idx;
3671 } else {
3672 /* Found an empty slot */
3673 empty_slots++;
3674 }
3675 }
3676 }
3677
Naveen Rawatc45d1622016-07-05 12:20:09 -07003678 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679 /* Last peer departed, set the IBSS state appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07003680 hdd_conn_set_connection_state(adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003681 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003682 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683 }
3684 /* Find next active staId, to have a valid sta trigger for TL. */
3685 if (fSuccess == true) {
3686 if (del_idx == 0) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003687 if (sta_ctx->conn_info.staId[valid_idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003688 HDD_WLAN_INVALID_STA_ID) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003689 sta_ctx->conn_info.staId[0] =
3690 sta_ctx->conn_info.staId[valid_idx];
3691 qdf_copy_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692 peerMacAddress[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -07003693 &sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694 peerMacAddress[valid_idx]);
3695
Jeff Johnsond377dce2017-10-04 10:32:42 -07003696 sta_ctx->conn_info.staId[valid_idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303697 HDD_WLAN_INVALID_STA_ID;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003698 qdf_zero_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 peerMacAddress[valid_idx]);
3700 }
3701 }
3702 }
3703 return fSuccess;
3704}
3705
3706/**
3707 * roam_ibss_connect_handler() - IBSS connection handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003708 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003709 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 *
3711 * We update the status of the IBSS to connected in this function.
3712 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303713 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003715static QDF_STATUS roam_ibss_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003716 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717{
3718 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 /*
3720 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3721 * a partner stations).
3722 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003723 hdd_conn_set_connection_state(adapter, eConnectionState_IbssConnected);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724
3725 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003726 hdd_conn_save_connect_info(adapter, roam_info, eCSR_BSS_TYPE_IBSS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727
3728 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003729 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 /* add bss_id to cfg80211 data base */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003731 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003733 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003734 adapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303735 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736 }
3737 cfg80211_put_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07003738 WLAN_HDD_GET_CTX(adapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 bss);
3740
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303741 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742}
3743
3744/**
3745 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003746 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003747 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 * @roamId: roam id
3749 * @roamStatus: roam status
3750 * @roamResult: roam result
3751 *
3752 * This function indicates the Mic failure to the supplicant
3753 *
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003754 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755 */
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003756static void
Jeff Johnsonba388342017-10-02 13:31:01 -07003757hdd_roam_mic_error_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003758 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759{
Jeff Johnsond377dce2017-10-04 10:32:42 -07003760 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003761 tSirMicFailureInfo *mic_failure_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003763 if (eConnectionState_Associated != sta_ctx->conn_info.connState)
3764 return;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003765
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003766 mic_failure_info = roam_info->u.pMICFailureInfo;
3767 cfg80211_michael_mic_failure(adapter->dev,
3768 mic_failure_info->taMacAddr,
3769 mic_failure_info->multicast ?
3770 NL80211_KEYTYPE_GROUP :
3771 NL80211_KEYTYPE_PAIRWISE,
3772 mic_failure_info->keyId,
3773 mic_failure_info->TSC,
3774 GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775}
3776
3777/**
3778 * roam_roam_connect_status_update_handler() - IBSS connect status update
Jeff Johnsonba388342017-10-02 13:31:01 -07003779 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003780 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 * @roamId: roam id
3782 * @roamStatus: roam status
3783 * @roamResult: roam result
3784 *
3785 * The Ibss connection status is updated regularly here in this function.
3786 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303787 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789static QDF_STATUS
Jeff Johnsonba388342017-10-02 13:31:01 -07003790roam_roam_connect_status_update_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003791 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 uint32_t roamId,
3793 eRoamCmdStatus roamStatus,
3794 eCsrRoamResult roamResult)
3795{
Jeff Johnsonba388342017-10-02 13:31:01 -07003796 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003797 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303798
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 switch (roamResult) {
3800 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3801 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003802 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003803 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003804 struct station_info *stainfo;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003805 eCsrEncryptionType encr_type = sta_ctx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303807 hdd_debug("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303808 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3809 MAC_ADDRESS_STR " and stationID= %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003810 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
Jeff Johnsond377dce2017-10-04 10:32:42 -07003811 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003812 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003814 if (!hdd_save_peer
Jeff Johnsonba388342017-10-02 13:31:01 -07003815 (WLAN_HDD_GET_STATION_CTX_PTR(adapter),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003816 roam_info->staId,
3817 &roam_info->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003818 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 break;
3820 }
3821
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003822 if (roam_info->staId < HDD_MAX_ADAPTERS)
3823 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
3824 else
3825 hdd_debug("invalid sta id %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003827 if (hdd_is_key_install_required_for_ibss(encr_type))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003828 roam_info->fAuthRequired = true;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 /* Register the Station with TL for the new peer. */
Jeff Johnsonba388342017-10-02 13:31:01 -07003831 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003832 roam_info,
3833 roam_info->staId,
3834 &roam_info->peerMac,
3835 roam_info->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303836 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003837 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303838 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003839 }
Jeff Johnsond377dce2017-10-04 10:32:42 -07003840 sta_ctx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003841 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3842 if (stainfo == NULL) {
3843 hdd_err("memory allocation for station_info failed");
3844 return QDF_STATUS_E_NOMEM;
3845 }
3846 stainfo->filled = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003847 stainfo->generation = sta_ctx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848
Jeff Johnsonba388342017-10-02 13:31:01 -07003849 cfg80211_new_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003850 (const u8 *)roam_info->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003851 stainfo, GFP_KERNEL);
3852 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003854 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003855 sta_ctx->ibss_enc_key.keyDirection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 eSIR_TX_RX;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003857 qdf_copy_macaddr(&sta_ctx->ibss_enc_key.peerMac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003858 &roam_info->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303860 hdd_debug("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003861 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303863 qdf_status =
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003864 sme_roam_set_key(hdd_ctx->mac_handle,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003865 adapter->session_id,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003866 &sta_ctx->ibss_enc_key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 &roamId);
3868
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303869 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003870 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003871 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303872 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 }
3874 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303875 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003876 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3878 WLAN_CONTROL_PATH);
3879 break;
3880 }
3881
3882 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3883 {
3884
Jeff Johnsonfd060852017-10-04 10:50:51 -07003885 roam_ibss_connect_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886
3887 break;
3888 }
3889 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3890 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003891 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003892 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003893
Jeff Johnsonfd060852017-10-04 10:50:51 -07003894 if (!roam_remove_ibss_station(adapter, roam_info->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003895 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303897 hdd_debug("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303898 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3899 MAC_ADDRESS_STR " and stationID= %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003900 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
Jeff Johnsond377dce2017-10-04 10:32:42 -07003901 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003902 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903
Jeff Johnsonfd060852017-10-04 10:50:51 -07003904 hdd_roam_deregister_sta(adapter, roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003906 if (roam_info->staId < HDD_MAX_ADAPTERS)
3907 hdd_ctx->sta_to_adapter[roam_info->staId] = NULL;
3908 else
3909 hdd_debug("invalid sta id %d", roam_info->staId);
3910
Jeff Johnsond377dce2017-10-04 10:32:42 -07003911 sta_ctx->ibss_sta_generation++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912
Jeff Johnsonba388342017-10-02 13:31:01 -07003913 cfg80211_del_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003914 (const u8 *)&roam_info->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 GFP_KERNEL);
3916 break;
3917 }
3918 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3919 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003920 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921 /* Stop only when we are inactive */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303922 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003923 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303924 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07003926 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 eConnectionState_NotConnected);
3928
3929 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003930 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 break;
3932 }
3933 default:
3934 break;
3935
3936 }
3937
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303938 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939}
3940
3941#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonba388342017-10-02 13:31:01 -07003942QDF_STATUS hdd_roam_register_tdlssta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943 const uint8_t *peerMac, uint16_t staId,
Jeff Johnsona8ce1272018-03-01 14:39:10 -08003944 uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303946 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003948 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003949 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3950 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003951
3952 /*
3953 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3954 * be peer MAC, here we are working on direct Link
3955 */
3956 staDesc.sta_id = staId;
3957
3958 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303959 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003960
Dhanashri Atre50141c52016-04-07 13:15:29 -07003961 /* Register the vdev transmit and receive functions */
3962 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3963 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003964 cdp_vdev_register(soc,
Sravan Kumar Kairam43f191b2018-05-04 17:00:39 +05303965 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3966 (struct cdp_pdev *)pdev, adapter->session_id),
3967 adapter, (struct cdp_ctrl_objmgr_vdev *)adapter->hdd_vdev,
3968 &txrx_ops);
Jeff Johnsonba388342017-10-02 13:31:01 -07003969 adapter->tx_fn = txrx_ops.tx.tx;
Poddar, Siddarth31797fa2018-01-22 17:24:15 +05303970 txrx_ops.rx.stats_rx = hdd_tx_rx_collect_connectivity_stats_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971
3972 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003973 qdf_status = cdp_peer_register(soc,
3974 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303975 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003976 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303977 qdf_status, qdf_status);
3978 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 }
3980
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303981 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982}
3983
3984/**
3985 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
Jeff Johnsonba388342017-10-02 13:31:01 -07003986 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 * @staId: station identifier
3988 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303989 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 */
Jeff Johnson53367842017-10-03 11:10:34 -07003991QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
3992 uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303994 QDF_STATUS qdf_status;
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07003995
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003996 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003997 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3998 staId);
Kabilan Kannanb4e01372018-01-15 13:33:10 -08003999
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304000 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001}
4002
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004003#else
4004
Jeff Johnsonba388342017-10-02 13:31:01 -07004005inline QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004006 uint8_t staId)
4007{
4008 return QDF_STATUS_SUCCESS;
4009}
4010
4011static inline QDF_STATUS
Jeff Johnsonba388342017-10-02 13:31:01 -07004012hdd_roam_tdls_status_update_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004013 struct csr_roam_info *roam_info,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004014 uint32_t roamId,
4015 eRoamCmdStatus roamStatus,
4016 eCsrRoamResult roamResult)
4017{
4018 return QDF_STATUS_SUCCESS;
4019}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020#endif
4021
4022#ifdef WLAN_FEATURE_11W
4023/**
4024 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
Jeff Johnsonba388342017-10-02 13:31:01 -07004025 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 * @nFrameLength: Length of the unprotected frame being passed
4027 * @pbFrames: Pointer to the frame buffer
4028 * @frameType: 802.11 frame type
4029 *
4030 * This function forwards the unprotected management frame to the supplicant.
4031 *
4032 * Return: nothing
4033 */
4034static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07004035hdd_indicate_unprot_mgmt_frame(struct hdd_adapter *adapter,
4036 uint32_t nFrameLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 uint8_t *pbFrames, uint8_t frameType)
4038{
4039 uint8_t type = 0;
4040 uint8_t subType = 0;
4041
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004042 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004043 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044
4045 /* Sanity Checks */
Jeff Johnsonba388342017-10-02 13:31:01 -07004046 if (NULL == adapter) {
4047 hdd_err("adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 return;
4049 }
4050
Jeff Johnsonba388342017-10-02 13:31:01 -07004051 if (NULL == adapter->dev) {
4052 hdd_err("adapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053 return;
4054 }
4055
Jeff Johnsonba388342017-10-02 13:31:01 -07004056 if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
4057 hdd_err("adapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 return;
4059 }
4060
4061 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004062 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063 return;
4064 }
4065
4066 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004067 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068 return;
4069 }
4070
4071 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4072 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4073
Jeff Johnsonba388342017-10-02 13:31:01 -07004074 /* Get adapter from Destination mac address of the frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4076#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
Jeff Johnsonba388342017-10-02 13:31:01 -07004077 cfg80211_rx_unprot_mlme_mgmt(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 nFrameLength);
4079#else
Jeff Johnsonba388342017-10-02 13:31:01 -07004080 cfg80211_send_unprot_disassoc(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 nFrameLength);
4082#endif
Jeff Johnsondc179f42017-10-21 11:27:26 -07004083 adapter->hdd_stats.hdd_pmf_stats.num_unprot_disassoc_rx++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 } else if (type == SIR_MAC_MGMT_FRAME &&
4085 subType == SIR_MAC_MGMT_DEAUTH) {
4086#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
Jeff Johnsonba388342017-10-02 13:31:01 -07004087 cfg80211_rx_unprot_mlme_mgmt(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 nFrameLength);
4089#else
Jeff Johnsonba388342017-10-02 13:31:01 -07004090 cfg80211_send_unprot_deauth(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 nFrameLength);
4092#endif
Jeff Johnsondc179f42017-10-21 11:27:26 -07004093 adapter->hdd_stats.hdd_pmf_stats.num_unprot_deauth_rx++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004095 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004096 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 return;
4098 }
4099}
4100#endif
4101
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004102#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103/**
4104 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
Jeff Johnsonba388342017-10-02 13:31:01 -07004105 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 * @tid: traffic identifier
4107 * @state: state
4108 * @measInterval: measurement interval
4109 *
4110 * This function sends traffic stream metrics IE information to
4111 * the supplicant via wireless event.
4112 *
4113 * Return: none
4114 */
4115static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004116hdd_indicate_tsm_ie(struct hdd_adapter *adapter, uint8_t tid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 uint8_t state, uint16_t measInterval)
4118{
4119 union iwreq_data wrqu;
4120 char buf[IW_CUSTOM_MAX + 1];
4121 int nBytes = 0;
4122
Jeff Johnsonba388342017-10-02 13:31:01 -07004123 if (NULL == adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 return;
4125
4126 /* create the event */
4127 memset(&wrqu, '\0', sizeof(wrqu));
4128 memset(buf, '\0', sizeof(buf));
4129
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004130 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004131 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132
4133 nBytes =
4134 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4135 measInterval);
4136
4137 wrqu.data.pointer = buf;
4138 wrqu.data.length = nBytes;
4139 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004140 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141}
4142
4143/**
4144 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004145 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004146 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 *
4148 * This function sends cckm preauth indication to the supplicant
4149 * via wireless custom event.
4150 *
4151 * Return: none
4152 */
4153static void
Jeff Johnson172237b2017-11-07 15:32:59 -08004154hdd_indicate_cckm_pre_auth(struct hdd_adapter *adapter,
4155 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156{
4157 union iwreq_data wrqu;
4158 char buf[IW_CUSTOM_MAX + 1];
4159 char *pos = buf;
4160 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4161
Jeff Johnsonfd060852017-10-04 10:50:51 -07004162 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 return;
4164
4165 /* create the event */
4166 memset(&wrqu, '\0', sizeof(wrqu));
4167 memset(buf, '\0', sizeof(buf));
4168
4169 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004170 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004171 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
4172 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173
4174 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4175 pos += nBytes;
4176 freeBytes -= nBytes;
4177
Jeff Johnsonfd060852017-10-04 10:50:51 -07004178 qdf_mem_copy(pos, roam_info->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304179 pos += QDF_MAC_ADDR_SIZE;
4180 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181
4182 nBytes = snprintf(pos, freeBytes, " %u:%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004183 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004184 freeBytes -= nBytes;
4185
4186 wrqu.data.pointer = buf;
4187 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4188
4189 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004190 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191}
4192
4193/**
4194 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004195 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004196 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 *
4198 * Return: none
4199 */
4200static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004201hdd_indicate_ese_adj_ap_rep_ind(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004202 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203{
4204 union iwreq_data wrqu;
4205 char buf[IW_CUSTOM_MAX + 1];
4206 int nBytes = 0;
4207
Jeff Johnsonfd060852017-10-04 10:50:51 -07004208 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 return;
4210
4211 /* create the event */
4212 memset(&wrqu, '\0', sizeof(wrqu));
4213 memset(buf, '\0', sizeof(buf));
4214
Jeff Johnsonfd060852017-10-04 10:50:51 -07004215 hdd_debug("CCXADJAPREP=%u", roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216
4217 nBytes =
4218 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004219 roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220
4221 wrqu.data.pointer = buf;
4222 wrqu.data.length = nBytes;
4223
4224 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004225 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226}
4227
4228/**
4229 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
Jeff Johnsonba388342017-10-02 13:31:01 -07004230 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 * @measurementToken: measurement token
4232 * @flag: flag
4233 * @numBss: number of bss
4234 *
4235 * If the measurement is none and no scan results found,
4236 * indicate the supplicant about measurement done.
4237 *
4238 * Return: none
4239 */
4240void
Jeff Johnsonba388342017-10-02 13:31:01 -07004241hdd_indicate_ese_bcn_report_no_results(const struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242 const uint16_t measurementToken,
4243 const bool flag, const uint8_t numBss)
4244{
4245 union iwreq_data wrqu;
4246 char buf[IW_CUSTOM_MAX];
4247 char *pos = buf;
4248 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4249
4250 memset(&wrqu, '\0', sizeof(wrqu));
4251 memset(buf, '\0', sizeof(buf));
4252
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004253 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004254 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255
4256 nBytes =
4257 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4258 flag, numBss);
4259
4260 wrqu.data.pointer = buf;
4261 wrqu.data.length = nBytes;
4262 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004263 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264}
4265
4266/**
4267 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004268 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004269 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 *
4271 * If the measurement is none and no scan results found,
4272 * indicate the supplicant about measurement done.
4273 *
4274 * Return: none
4275 */
4276static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004277hdd_indicate_ese_bcn_report_ind(const struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004278 const struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279{
4280 union iwreq_data wrqu;
4281 char buf[IW_CUSTOM_MAX];
4282 char *pos = buf;
4283 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4284 uint8_t i = 0, len = 0;
4285 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4286 uint8_t lastSent = 0, sendBss = 0;
4287 int bcnRepFieldSize =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004288 sizeof(roam_info->pEseBcnReportRsp->bcnRepBssInfo[0].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 bcnReportFields);
4290 uint8_t ieLenByte = 1;
4291 /*
4292 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4293 */
4294#define ESEBCNREPHEADER_LEN (18)
4295
Jeff Johnsonfd060852017-10-04 10:50:51 -07004296 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297 return;
4298
4299 /*
4300 * Custom event can pass maximum of 256 bytes of data,
4301 * based on the IE len we need to identify how many BSS info can
4302 * be filled in to custom event data.
4303 */
4304 /*
4305 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4306 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4307 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4308 */
4309
Jeff Johnsonfd060852017-10-04 10:50:51 -07004310 if ((roam_info->pEseBcnReportRsp->flag >> 1)
4311 && (!roam_info->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004312 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004314 * indicate the supplicant about measurement done
4315 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 hdd_indicate_ese_bcn_report_no_results(
Jeff Johnsonba388342017-10-02 13:31:01 -07004317 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004318 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004320 roam_info->pEseBcnReportRsp->flag,
4321 roam_info->pEseBcnReportRsp->numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004323 while (lastSent < roam_info->pEseBcnReportRsp->numBss) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324 memset(&wrqu, '\0', sizeof(wrqu));
4325 memset(buf, '\0', sizeof(buf));
4326 tot_bcn_ieLen = 0;
4327 sendBss = 0;
4328 pos = buf;
4329 freeBytes = IW_CUSTOM_MAX;
4330
4331 for (i = lastSent;
Jeff Johnsonfd060852017-10-04 10:50:51 -07004332 i < roam_info->pEseBcnReportRsp->numBss; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 len =
4334 bcnRepFieldSize + ieLenByte +
Jeff Johnsonfd060852017-10-04 10:50:51 -07004335 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 bcnRepBssInfo[i].ieLen;
4337 if ((len + tot_bcn_ieLen) >
4338 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4339 break;
4340 }
4341 tot_bcn_ieLen += len;
4342 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004343 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004344 i, bcnRepFieldSize, 1,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004345 roam_info->pEseBcnReportRsp->
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004346 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 }
4348
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004349 hdd_debug("Sending %d BSS Info", sendBss);
4350 hdd_debug("CCXBCNREP=%d %d %d %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004351 roam_info->pEseBcnReportRsp->measurementToken,
4352 roam_info->pEseBcnReportRsp->flag, sendBss,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004353 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354
4355 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004356 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004357 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004358 roam_info->pEseBcnReportRsp->flag,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 sendBss);
4360 pos += nBytes;
4361 freeBytes -= nBytes;
4362
4363 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304364 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 sizeof(tot_bcn_ieLen));
4366 pos += sizeof(tot_bcn_ieLen);
4367 freeBytes -= sizeof(tot_bcn_ieLen);
4368
4369 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004370 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4372 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4373 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004374 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 bcnRepBssInfo[i +
4376 lastSent].bcnReportFields.
4377 ChanNum,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004378 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 bcnRepBssInfo[i +
4380 lastSent].bcnReportFields.
4381 Spare,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004382 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383 bcnRepBssInfo[i +
4384 lastSent].bcnReportFields.
4385 MeasDuration,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004386 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 bcnRepBssInfo[i +
4388 lastSent].bcnReportFields.
4389 PhyType,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004390 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391 bcnRepBssInfo[i +
4392 lastSent].bcnReportFields.
4393 RecvSigPower,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004394 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 bcnRepBssInfo[i +
4396 lastSent].bcnReportFields.
4397 ParentTsf,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004398 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 bcnRepBssInfo[i +
4400 lastSent].bcnReportFields.
4401 TargetTsf[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004402 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 bcnRepBssInfo[i +
4404 lastSent].bcnReportFields.
4405 TargetTsf[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004406 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407 bcnRepBssInfo[i +
4408 lastSent].bcnReportFields.
4409 BcnInterval,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004410 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 bcnRepBssInfo[i +
4412 lastSent].bcnReportFields.
4413 CapabilityInfo,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004414 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 bcnRepBssInfo[i +
4416 lastSent].bcnReportFields.
4417 Bssid[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004418 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 bcnRepBssInfo[i +
4420 lastSent].bcnReportFields.
4421 Bssid[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004422 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 bcnRepBssInfo[i +
4424 lastSent].bcnReportFields.
4425 Bssid[2],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004426 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004427 bcnRepBssInfo[i +
4428 lastSent].bcnReportFields.
4429 Bssid[3],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004430 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 bcnRepBssInfo[i +
4432 lastSent].bcnReportFields.
4433 Bssid[4],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004434 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 bcnRepBssInfo[i +
4436 lastSent].bcnReportFields.
4437 Bssid[5]);
4438
4439 /* bcn report fields are copied */
4440 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004441 sizeof(roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 bcnRepBssInfo[i +
4443 lastSent].
4444 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304445 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004446 (char *)&roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 pEseBcnReportRsp->bcnRepBssInfo[i +
4448 lastSent].
4449 bcnReportFields, len);
4450 pos += len;
4451 freeBytes -= len;
4452
4453 /* Add 1 byte of ie len */
4454 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004455 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304457 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 pos += sizeof(len);
4459 freeBytes -= sizeof(len);
4460
4461 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304462 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004463 (char *)roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 pEseBcnReportRsp->bcnRepBssInfo[i +
4465 lastSent].
4466 pBuf, len);
4467 pos += len;
4468 freeBytes -= len;
4469 }
4470
4471 wrqu.data.pointer = buf;
4472 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4473
4474 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004475 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476 buf);
4477 lastSent += sendBss;
4478 }
4479 }
4480}
4481
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004482#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483
4484/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304485 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
Jeff Johnsond377dce2017-10-04 10:32:42 -07004486 * @sta_ctx: Station Context
Komal Seelam98760ba2015-12-15 11:05:18 +05304487 *
4488 * API to check if the connection authentication type is 8021x_sha256.
4489 *
4490 * Return: bool
4491 */
4492#ifdef WLAN_FEATURE_11W
Jeff Johnson435e1b82017-10-07 14:13:10 -07004493static inline bool
4494hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304495{
4496 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004497 sta_ctx->conn_info.authType;
Komal Seelam98760ba2015-12-15 11:05:18 +05304498}
4499#else
Jeff Johnson435e1b82017-10-07 14:13:10 -07004500static inline bool
4501hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304502{
4503 return false;
4504}
4505#endif
4506
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304507/*
4508 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4509 * @adapter: Pointer to adapter context
4510 * @roam_info: Pointer to roam info
4511 *
4512 * Return: None
4513 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004514static void hdd_roam_channel_switch_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004515 struct csr_roam_info *roam_info)
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304516{
4517 struct hdd_chan_change_params chan_change;
4518 struct cfg80211_bss *bss;
4519 struct net_device *dev = adapter->dev;
4520 struct wireless_dev *wdev = dev->ieee80211_ptr;
4521 struct wiphy *wiphy = wdev->wiphy;
4522 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -07004523 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05304524 mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304525
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004526 hdd_debug("channel switch for session:%d to channel:%d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004527 adapter->session_id, roam_info->chan_info.chan_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304528
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05304529 /* Enable Roaming on STA interface which was disabled before CSA */
4530 if (adapter->device_mode == QDF_STA_MODE)
4531 sme_start_roaming(mac_handle, adapter->session_id,
4532 REASON_DRIVER_ENABLED);
4533
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304534 chan_change.chan = roam_info->chan_info.chan_id;
4535 chan_change.chan_params.ch_width =
4536 roam_info->chan_info.ch_width;
4537 chan_change.chan_params.sec_ch_offset =
4538 roam_info->chan_info.sec_ch_offset;
4539 chan_change.chan_params.center_freq_seg0 =
4540 roam_info->chan_info.band_center_freq1;
4541 chan_change.chan_params.center_freq_seg1 =
4542 roam_info->chan_info.band_center_freq2;
4543
4544 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4545 if (NULL == bss)
4546 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4547 else
4548 cfg80211_put_bss(wiphy, bss);
4549
bings58ce8622017-07-10 15:55:36 +08004550 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4551 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304552 if (QDF_IS_STATUS_ERROR(status))
4553 hdd_err("channel change notification failed");
4554
Ganesh Kondabattini41f34782017-09-14 21:14:29 +05304555 hdd_debug("check for SAP restart");
4556 policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->hdd_psoc);
4557
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004558 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004559 adapter->session_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304560 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004561 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304562}
4563
Komal Seelam98760ba2015-12-15 11:05:18 +05304564/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 * hdd_sme_roam_callback() - hdd sme roam callback
4566 * @pContext: pointer to adapter context
Jeff Johnsonfd060852017-10-04 10:50:51 -07004567 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 * @roamId: roam id
4569 * @roamStatus: roam status
4570 * @roamResult: roam result
4571 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304572 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304574QDF_STATUS
Jeff Johnson172237b2017-11-07 15:32:59 -08004575hdd_sme_roam_callback(void *pContext, struct csr_roam_info *roam_info,
4576 uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4578{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304579 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnsonba388342017-10-02 13:31:01 -07004580 struct hdd_adapter *adapter = (struct hdd_adapter *) pContext;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004581 struct hdd_station_ctx *sta_ctx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304582 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304583 struct cfg80211_bss *bss_status;
Jeff Johnson49432062017-08-28 12:08:45 -07004584 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585
Abhishek Singhf723e3d2018-02-20 18:02:37 +05304586 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Abhinav Kumar5670d362018-01-16 17:31:54 +05304587 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588
4589 /* Sanity check */
Jeff Johnsonba388342017-10-02 13:31:01 -07004590 if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004591 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304592 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 }
4594
Jeff Johnsond377dce2017-10-04 10:32:42 -07004595 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonba388342017-10-02 13:31:01 -07004596 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597
Abhishek Singhf723e3d2018-02-20 18:02:37 +05304598 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004599 adapter->session_id, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 switch (roamStatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 /*
4603 * We did pre-auth,then we attempted a 11r or ese reassoc.
4604 * reassoc failed due to failure, timeout, reject from ap
4605 * in any case tell the OS, our carrier is off and mark
4606 * interface down.
4607 */
4608 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004609 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004610 roamStatus, roamResult, adapter->session_id);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304611 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004612 hdd_dis_connect_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 roamStatus, roamResult);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004614 sta_ctx->ft_carrier_on = false;
Jeff Johnson690fe952017-10-25 11:48:39 -07004615 sta_ctx->hdd_reassoc_scenario = false;
4616 hdd_debug("hdd_reassoc_scenario set to: %d, ReAssoc Failed, session: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004617 sta_ctx->hdd_reassoc_scenario, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 break;
4619
4620 case eCSR_ROAM_FT_START:
4621 /*
4622 * When we roam for ESE and 11r, we dont want the OS to be
4623 * informed that the link is down. So mark the link ready for
4624 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4625 * be received. Where in we will not mark the link down
4626 * Also we want to stop tx at this point when we will be
4627 * doing disassoc at this time. This saves 30-60 msec
4628 * after reassoc.
4629 */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304630 hdd_debug("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004631 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004632 hdd_napi_serialize(1);
Jeff Johnsonba388342017-10-02 13:31:01 -07004633 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304634 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004635 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07004636 status = hdd_roam_deregister_sta(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004637 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304638 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304639 qdf_ret_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004640 sta_ctx->ft_carrier_on = true;
Jeff Johnson690fe952017-10-25 11:48:39 -07004641 sta_ctx->hdd_reassoc_scenario = true;
4642 hdd_debug("hdd_reassoc_scenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004643 sta_ctx->hdd_reassoc_scenario, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004645 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004646 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004647 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004648 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304649 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
Jeff Johnsonba388342017-10-02 13:31:01 -07004650 adapter->roam_ho_fail = true;
Abhishek Singh533c9da2017-05-04 10:23:34 +05304651 else
Jeff Johnsonba388342017-10-02 13:31:01 -07004652 adapter->roam_ho_fail = false;
4653 complete(&adapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004654 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 /* notify apps that we can't pass traffic anymore */
Dustin Browna7bb6ae2018-08-16 16:51:50 -07004657 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004658 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304659 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 WLAN_CONTROL_PATH);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004661 if (sta_ctx->ft_carrier_on == false) {
Jeff Johnsonba388342017-10-02 13:31:01 -07004662 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 WLAN_NETIF_CARRIER_OFF,
4664 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 break;
4667 case eCSR_ROAM_LOSTLINK:
4668 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004669 hdd_debug("Roaming started due to connection lost");
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304670 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004671 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304672 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673 WLAN_CONTROL_PATH);
4674 break;
4675 }
4676 case eCSR_ROAM_DISASSOCIATED:
4677 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004678 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304679 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004680 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304681 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004682 adapter->roam_ho_fail = false;
4683 complete(&adapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004685 /* Call to clear any MC Addr List filter applied after
4686 * successful connection.
4687 */
Jeff Johnsonba388342017-10-02 13:31:01 -07004688 hdd_disable_and_flush_mc_addr_list(adapter,
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304689 pmo_peer_disconnect);
4690 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004691 hdd_dis_connect_handler(adapter, roam_info, roamId,
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304692 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 }
4694 break;
4695 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004696 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304697 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004698 hdd_dis_connect_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 roamStatus, roamResult);
4700 break;
4701 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004702 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 /*
4704 * To Do - address probable memory leak with WEP encryption upon
4705 * successful association.
4706 */
4707 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4708 /* Clear saved connection information in HDD */
4709 hdd_conn_remove_connect_info(
Jeff Johnsonba388342017-10-02 13:31:01 -07004710 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304712 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004713 hdd_association_completion_handler(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 roamId, roamStatus,
4715 roamResult);
4716#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07004717 if (roam_info)
4718 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719#endif
4720 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004721 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004722 hdd_debug("****eCSR_ROAM_CANCELLED****");
Jeff Johnson48c05c72018-04-29 19:47:12 -07004723 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 case eCSR_ROAM_ASSOCIATION_FAILURE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004725 qdf_ret_status = hdd_association_completion_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004726 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 roamId,
4728 roamStatus,
4729 roamResult);
4730 break;
4731 case eCSR_ROAM_IBSS_IND:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004732 hdd_roam_ibss_indication_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733 roamStatus, roamResult);
4734 break;
4735
4736 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304737 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07004738 roam_roam_connect_status_update_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004739 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004740 roamId,
4741 roamStatus,
4742 roamResult);
4743 break;
4744
4745 case eCSR_ROAM_MIC_ERROR_IND:
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07004746 hdd_roam_mic_error_indication_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 break;
4748
4749 case eCSR_ROAM_SET_KEY_COMPLETE:
4750 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304751 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004752 hdd_roam_set_key_complete_handler(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 roamId, roamStatus,
4754 roamResult);
4755 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Jeff Johnson690fe952017-10-25 11:48:39 -07004756 sta_ctx->hdd_reassoc_scenario = false;
4757 hdd_debug("hdd_reassoc_scenario set to: %d, set key complete, session: %d",
4758 sta_ctx->hdd_reassoc_scenario,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004759 adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 }
4761 }
4762#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07004763 if (roam_info != NULL)
4764 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004765#endif
4766 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004767
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 case eCSR_ROAM_FT_RESPONSE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004769 hdd_send_ft_event(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772 case eCSR_ROAM_PMK_NOTIFY:
Jeff Johnsond377dce2017-10-04 10:32:42 -07004773 if (eCSR_AUTH_TYPE_RSN == sta_ctx->conn_info.authType
4774 || hdd_is_8021x_sha256_auth_type(sta_ctx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304776 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 wlan_hdd_cfg80211_pmksa_candidate_notify(
Jeff Johnsonfd060852017-10-04 10:50:51 -07004778 adapter, roam_info, 1, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 }
4780 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781
4782#ifdef FEATURE_WLAN_LFR_METRICS
4783 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4784 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304785 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004786 wlan_hdd_cfg80211_roam_metrics_preauth(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004787 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304788 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 }
4790 break;
4791 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4792 /*
4793 * This event will notify pre-auth completion in case of success
4794 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304795 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004796 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004797 roam_info, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304798 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004799 }
4800 break;
4801 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4802 /*
4803 * This event will notify pre-auth completion incase of failure.
4804 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304805 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004806 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004807 roam_info, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304808 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004809 }
4810 break;
4811 case eCSR_ROAM_HANDOVER_SUCCESS:
4812 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004813 * It will be only invoked on success
4814 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304815 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004816 wlan_hdd_cfg80211_roam_metrics_handover(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004817 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304818 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819 }
4820 break;
4821#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822#ifdef WLAN_FEATURE_11W
4823 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
gaurank kathpaliaea6b5e62018-07-05 20:41:28 +05304824 if (roam_info)
4825 hdd_indicate_unprot_mgmt_frame(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004826 roam_info->nFrameLength,
4827 roam_info->pbFrames,
4828 roam_info->frameType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 break;
4830#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004831#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 case eCSR_ROAM_TSM_IE_IND:
gaurank kathpaliaea6b5e62018-07-05 20:41:28 +05304833 if (roam_info)
4834 hdd_indicate_tsm_ie(adapter, roam_info->tsmIe.tsid,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004835 roam_info->tsmIe.state,
4836 roam_info->tsmIe.msmt_interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837 break;
4838
4839 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4840 {
4841 if (eCSR_AUTH_TYPE_CCKM_WPA ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004842 sta_ctx->conn_info.authType
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843 || eCSR_AUTH_TYPE_CCKM_RSN ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004844 sta_ctx->conn_info.authType) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004845 hdd_indicate_cckm_pre_auth(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 }
4847 break;
4848 }
4849
4850 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4851 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004852 hdd_indicate_ese_adj_ap_rep_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 break;
4854 }
4855
4856 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4857 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004858 hdd_indicate_ese_bcn_report_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 break;
4860 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004861#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304862 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004863 hdd_roam_channel_switch_handler(adapter, roam_info);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304864 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304865
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304866 case eCSR_ROAM_UPDATE_SCAN_RESULT:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004867 if ((NULL != roam_info) && (NULL != roam_info->pBssDesc)) {
Abhishek Singhf05b0cb62018-02-20 18:06:13 +05304868 bss_status = wlan_hdd_inform_bss_frame(adapter,
4869 roam_info->pBssDesc);
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304870 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004871 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304872 else
4873 cfg80211_put_bss(
4874#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
Jeff Johnsonba388342017-10-02 13:31:01 -07004875 (WLAN_HDD_GET_CTX(adapter))->wiphy,
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304876#endif
4877 bss_status);
4878 }
4879 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004880 case eCSR_ROAM_NDP_STATUS_UPDATE:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004881 hdd_ndp_event_handler(adapter, roam_info, roamId, roamStatus,
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004882 roamResult);
4883 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004884 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004885 hdd_debug("Process ROAM_START from firmware");
Jeff Johnsonba388342017-10-02 13:31:01 -07004886 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304887 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004888 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004889 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08004890 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004891 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004892 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004893 break;
4894 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004895 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004896 hdd_napi_serialize(0);
Jeff Johnsonba388342017-10-02 13:31:01 -07004897 wlan_hdd_netif_queue_control(adapter,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004898 WLAN_WAKE_ALL_NETIF_QUEUE,
4899 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08004900 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004901 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004902 adapter->roam_ho_fail = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004903 sta_ctx->ft_carrier_on = false;
Jeff Johnsonba388342017-10-02 13:31:01 -07004904 complete(&adapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004905 break;
4906
Padma, Santhosh Kumareb90a552018-01-16 19:41:58 +05304907 case eCSR_ROAM_SAE_COMPUTE:
4908 if (roam_info)
4909 wlan_hdd_sae_callback(adapter, roam_info);
4910 break;
4911
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 default:
4913 break;
4914 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304915 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916}
4917
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304918#ifdef WLAN_FEATURE_FILS_SK
4919/**
4920 * hdd_translate_fils_rsn_to_csr_auth() - Translate FILS RSN to CSR auth type
4921 * @auth_suite: auth suite
4922 * @auth_type: pointer to eCsrAuthType
4923 *
4924 * Return: None
4925 */
4926static void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
4927 eCsrAuthType *auth_type)
4928{
4929 if (!memcmp(auth_suite, ccp_rsn_oui_0e, 4))
4930 *auth_type = eCSR_AUTH_TYPE_FILS_SHA256;
4931 else if (!memcmp(auth_suite, ccp_rsn_oui_0f, 4))
4932 *auth_type = eCSR_AUTH_TYPE_FILS_SHA384;
4933 else if (!memcmp(auth_suite, ccp_rsn_oui_10, 4))
4934 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA256;
4935 else if (!memcmp(auth_suite, ccp_rsn_oui_11, 4))
4936 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA384;
4937}
4938#else
4939static inline void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
4940 eCsrAuthType *auth_type)
4941{
4942}
4943#endif
4944
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05304945#ifdef WLAN_FEATURE_SAE
4946/**
4947 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
4948 * @auth_suite: auth suite
4949 * @auth_type: pointer to eCsrAuthType
4950 *
4951 * Return: None
4952 */
4953static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4954 eCsrAuthType *auth_type)
4955{
4956 if (qdf_mem_cmp(auth_suite, ccp_rsn_oui_80, 4) == 0)
4957 *auth_type = eCSR_AUTH_TYPE_SAE;
4958}
4959#else
4960static inline void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4961 eCsrAuthType *auth_type)
4962{
4963}
4964#endif
4965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966/**
4967 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4968 * @auth_suite: auth suite
4969 *
4970 * Return: eCsrAuthType enumeration
4971 */
4972eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4973{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304974 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 /* is the auth type supported? */
4976 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4977 auth_type = eCSR_AUTH_TYPE_RSN;
4978 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
4979 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004980 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 /* Check for 11r FT Authentication with PSK */
4982 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
4983 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
4984 /* Check for 11R FT Authentication with 802.1X */
4985 auth_type = eCSR_AUTH_TYPE_FT_RSN;
4986 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987#ifdef FEATURE_WLAN_ESE
4988 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
4989 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4990 } else
4991#endif /* FEATURE_WLAN_ESE */
4992#ifdef WLAN_FEATURE_11W
4993 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
4994 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4995 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
4996 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05304997 } else if (memcmp(auth_suite, ccp_rsn_oui_18, 4) == 0) {
4998 auth_type = eCSR_AUTH_TYPE_OWE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004999 } else
5000#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +05305001 if (memcmp(auth_suite, ccp_rsn_oui_12, 4) == 0) {
5002 auth_type = eCSR_AUTH_TYPE_DPP_RSN;
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305003 } else if (memcmp(auth_suite, ccp_rsn_oui_0b, 4) == 0) {
5004 /* Check for Suite B EAP 256 */
5005 auth_type = eCSR_AUTH_TYPE_SUITEB_EAP_SHA256;
5006 } else if (memcmp(auth_suite, ccp_rsn_oui_0c, 4) == 0) {
5007 /* Check for Suite B EAP 384 */
5008 auth_type = eCSR_AUTH_TYPE_SUITEB_EAP_SHA384;
Jeff Johnson109e79d2018-02-27 15:10:04 -08005009 } else {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305010 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305011 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012 }
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305013 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 return auth_type;
5015}
5016
5017/**
5018 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5019 * @auth_suite: auth suite
5020 *
5021 * Return: eCsrAuthType enumeration
5022 */
5023eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5024{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305025 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005026 /* is the auth type supported? */
5027 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5028 auth_type = eCSR_AUTH_TYPE_WPA;
5029 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5030 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5031 } else
5032#ifdef FEATURE_WLAN_ESE
5033 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5034 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5035 } else
5036#endif /* FEATURE_WLAN_ESE */
5037 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305038 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005040 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005041 return auth_type;
5042}
5043
5044/**
5045 * hdd_translate_rsn_to_csr_encryption_type() -
5046 * Translate RSN to CSR encryption type
5047 * @cipher_suite: cipher suite
5048 *
5049 * Return: eCsrEncryptionType enumeration
5050 */
5051eCsrEncryptionType
5052hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5053{
5054 eCsrEncryptionType cipher_type;
5055
5056 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5057 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Mukul Sharma05504ac2017-06-08 12:35:53 +05305058 else if (memcmp(cipher_suite, ccp_rsn_oui09, 4) == 0)
5059 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP;
5060 else if (memcmp(cipher_suite, ccp_rsn_oui0a, 4) == 0)
5061 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP_256;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005062 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5063 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5064 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5065 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5066 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5067 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5068 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5069 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5070 else
5071 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5072
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005073 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 return cipher_type;
5075}
5076
5077/**
5078 * hdd_translate_wpa_to_csr_encryption_type() -
5079 * Translate WPA to CSR encryption type
5080 * @cipher_suite: cipher suite
5081 *
5082 * Return: eCsrEncryptionType enumeration
5083 */
5084eCsrEncryptionType
5085hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5086{
5087 eCsrEncryptionType cipher_type;
5088
5089 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5090 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5091 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5092 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5093 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5094 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5095 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5096 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5097 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5098 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5099 else
5100 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5101
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005102 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103 return cipher_type;
5104}
5105
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305106#ifdef WLAN_FEATURE_FILS_SK
gaurank kathpalia82a1b2b2018-07-10 16:49:10 +05305107bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305108{
Jeff Johnson844eec72018-03-13 11:48:18 -07005109 struct csr_roam_profile *roam_profile;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305110
Jeff Johnson844eec72018-03-13 11:48:18 -07005111 roam_profile = hdd_roam_profile(adapter);
5112 if (roam_profile->fils_con_info)
5113 return roam_profile->fils_con_info->is_fils_connection;
Min Liuab6ed4f2018-01-09 13:13:57 +08005114
5115 return false;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305116}
5117#else
gaurank kathpalia82a1b2b2018-07-10 16:49:10 +05305118bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305119{
5120 return false;
5121}
5122#endif
5123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005124/**
5125 * hdd_process_genie() - process gen ie
Jeff Johnsonba388342017-10-02 13:31:01 -07005126 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 * @bssid: pointer to mac address
5128 * @pEncryptType: pointer to encryption type
5129 * @mcEncryptType: pointer to multicast encryption type
5130 * @pAuthType: pointer to auth type
5131 *
5132 * Return: 0 on success, error number otherwise
5133 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005134static int32_t hdd_process_genie(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005135 u8 *bssid,
5136 eCsrEncryptionType *pEncryptType,
5137 eCsrEncryptionType *mcEncryptType,
5138 eCsrAuthType *pAuthType,
5139#ifdef WLAN_FEATURE_11W
5140 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5141#endif
5142 uint16_t gen_ie_len, uint8_t *gen_ie)
5143{
Jeff Johnsonf7187f22018-06-13 22:02:19 -07005144 mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter);
Abhishek Singh3f13a812018-01-16 14:24:44 +05305145 tDot11fIERSN dot11RSNIE = {0};
5146 tDot11fIEWPA dot11WPAIE = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 uint8_t *pRsnIe;
5148 uint16_t RSNIeLen;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305149 uint32_t parse_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150
5151 /*
5152 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5153 * setting present flag to 0.
5154 */
5155 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5156 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5157
5158 /* Type check */
5159 if (gen_ie[0] == DOT11F_EID_RSN) {
5160 /* Validity checks */
5161 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5162 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005163 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005164 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 return -EINVAL;
5166 }
5167 /* Skip past the EID byte and length byte */
5168 pRsnIe = gen_ie + 2;
5169 RSNIeLen = gen_ie_len - 2;
5170 /* Unpack the RSN IE */
Jeff Johnsonf7187f22018-06-13 22:02:19 -07005171 parse_status = sme_unpack_rsn_ie(mac_handle, pRsnIe, RSNIeLen,
5172 &dot11RSNIE, false);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305173 if (!DOT11F_SUCCEEDED(parse_status)) {
5174 hdd_err("Invalid RSN IE: parse status %d",
5175 parse_status);
5176 return -EINVAL;
5177 }
Abhishek Singh3f13a812018-01-16 14:24:44 +05305178 hdd_debug("gp_cipher_suite_present: %d",
5179 dot11RSNIE.gp_cipher_suite_present);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005180 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005181 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005182 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005183 hdd_debug("authentication suite count: %d",
Abhishek Singh3f13a812018-01-16 14:24:44 +05305184 dot11RSNIE.akm_suite_cnt);
5185 /* dot11RSNIE.akm_suite_cnt */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005186 /* Just translate the FIRST one */
5187 *pAuthType =
5188 hdd_translate_rsn_to_csr_auth_type(
Abhishek Singh3f13a812018-01-16 14:24:44 +05305189 dot11RSNIE.akm_suite[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190 /* dot11RSNIE.pwise_cipher_suite_count */
5191 *pEncryptType =
5192 hdd_translate_rsn_to_csr_encryption_type(
5193 dot11RSNIE.pwise_cipher_suites[0]);
5194 /* dot11RSNIE.gp_cipher_suite_count */
5195 *mcEncryptType =
5196 hdd_translate_rsn_to_csr_encryption_type(
5197 dot11RSNIE.gp_cipher_suite);
5198#ifdef WLAN_FEATURE_11W
5199 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
Srinivas Girigowda6519b932017-08-03 14:10:57 -07005200 *pMfpCapable = csr_is_mfpc_capable(&dot11RSNIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5203 /* Validity checks */
5204 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5205 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005206 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005207 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 return -EINVAL;
5209 }
5210 /* Skip past the EID and length byte - and four byte WiFi OUI */
5211 pRsnIe = gen_ie + 2 + 4;
5212 RSNIeLen = gen_ie_len - (2 + 4);
5213 /* Unpack the WPA IE */
Jeff Johnsonf7187f22018-06-13 22:02:19 -07005214 parse_status = dot11f_unpack_ie_wpa((tpAniSirGlobal)mac_handle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305215 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305216 if (!DOT11F_SUCCEEDED(parse_status)) {
5217 hdd_err("Invalid WPA IE: parse status %d",
5218 parse_status);
5219 return -EINVAL;
5220 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005222 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005223 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005224 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005225 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 /* dot11WPAIE.auth_suite_count */
5227 /* Just translate the FIRST one */
5228 *pAuthType =
5229 hdd_translate_wpa_to_csr_auth_type(
5230 dot11WPAIE.auth_suites[0]);
5231 /* dot11WPAIE.unicast_cipher_count */
5232 *pEncryptType =
5233 hdd_translate_wpa_to_csr_encryption_type(
5234 dot11WPAIE.unicast_ciphers[0]);
5235 /* dot11WPAIE.unicast_cipher_count */
5236 *mcEncryptType =
5237 hdd_translate_wpa_to_csr_encryption_type(
5238 dot11WPAIE.multicast_cipher);
5239 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005240 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241 return -EINVAL;
5242 }
5243 return 0;
5244}
5245
5246/**
Abhishek Singh6454ad32017-12-20 10:42:21 +05305247 * hdd_set_def_rsne_override() - set default encryption type and auth type
5248 * in profile.
5249 * @roam_profile: pointer to adapter
5250 * @auth_type: pointer to auth type
5251 *
5252 * Set default value of encryption type and auth type in profile to
5253 * search the AP using filter, as in force_rsne_override the RSNIE can be
5254 * currupt and we might not get the proper encryption type and auth type
5255 * while parsing the RSNIE.
5256 *
5257 * Return: void
5258 */
5259static void hdd_set_def_rsne_override(
Jeff Johnson61b5e982018-03-15 11:33:31 -07005260 struct csr_roam_profile *roam_profile, eCsrAuthType *auth_type)
Abhishek Singh6454ad32017-12-20 10:42:21 +05305261{
5262
5263 hdd_debug("Set def values in roam profile");
5264 roam_profile->MFPCapable = roam_profile->MFPEnabled;
5265 roam_profile->EncryptionType.numEntries = 2;
5266 roam_profile->mcEncryptionType.numEntries = 2;
5267 /* Use the cipher type in the RSN IE */
5268 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
5269 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
5270 roam_profile->mcEncryptionType.encryptionType[0] =
5271 eCSR_ENCRYPT_TYPE_AES;
5272 roam_profile->mcEncryptionType.encryptionType[1] =
5273 eCSR_ENCRYPT_TYPE_TKIP;
5274 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
5275}
5276
5277/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 * hdd_set_genie_to_csr() - set genie to csr
Jeff Johnsonba388342017-10-02 13:31:01 -07005279 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 * @RSNAuthType: pointer to auth type
5281 *
5282 * Return: 0 on success, error number otherwise
5283 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005284int hdd_set_genie_to_csr(struct hdd_adapter *adapter,
Jeff Johnson2a722002017-09-30 20:02:35 -07005285 eCsrAuthType *RSNAuthType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286{
Jeff Johnson844eec72018-03-13 11:48:18 -07005287 struct csr_roam_profile *roam_profile;
5288 uint8_t *security_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289 uint32_t status = 0;
5290 eCsrEncryptionType RSNEncryptType;
5291 eCsrEncryptionType mcRSNEncryptType;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305292 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293#ifdef WLAN_FEATURE_11W
5294 uint8_t RSNMfpRequired = 0;
5295 uint8_t RSNMfpCapable = 0;
5296#endif
5297 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
Jeff Johnson844eec72018-03-13 11:48:18 -07005298
5299 roam_profile = hdd_roam_profile(adapter);
5300 security_ie = hdd_security_ie(adapter);
5301
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302 /* MAC address of assoc peer */
5303 /* But, this routine is only called when we are NOT associated. */
Jeff Johnson844eec72018-03-13 11:48:18 -07005304 qdf_mem_copy(bssid, roam_profile->BSSIDs.bssid, sizeof(bssid));
5305 if (security_ie[0] == DOT11F_EID_RSN ||
5306 security_ie[0] == DOT11F_EID_WPA) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 /* continue */
5308 } else {
5309 return 0;
5310 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 /* The actual processing may eventually be more extensive than this. */
5313 /* Right now, just consume any PMKIDs that are sent in by the app. */
Jeff Johnsonba388342017-10-02 13:31:01 -07005314 status = hdd_process_genie(adapter, bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 &RSNEncryptType,
5316 &mcRSNEncryptType, RSNAuthType,
5317#ifdef WLAN_FEATURE_11W
5318 &RSNMfpRequired, &RSNMfpCapable,
5319#endif
Jeff Johnson844eec72018-03-13 11:48:18 -07005320 security_ie[1] + 2,
5321 security_ie);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 if (status == 0) {
5324 /*
5325 * Now copy over all the security attributes
5326 * you have parsed out.
5327 */
Jeff Johnson844eec72018-03-13 11:48:18 -07005328 roam_profile->EncryptionType.numEntries = 1;
5329 roam_profile->mcEncryptionType.numEntries = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330
Jeff Johnson435e1b82017-10-07 14:13:10 -07005331 /* Use the cipher type in the RSN IE */
Jeff Johnson844eec72018-03-13 11:48:18 -07005332 roam_profile->EncryptionType.encryptionType[0] =
Jeff Johnson435e1b82017-10-07 14:13:10 -07005333 RSNEncryptType;
Jeff Johnson844eec72018-03-13 11:48:18 -07005334 roam_profile->mcEncryptionType.encryptionType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335 mcRSNEncryptType;
5336
Jeff Johnsonba388342017-10-02 13:31:01 -07005337 if ((QDF_IBSS_MODE == adapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05305339 (eCSR_ENCRYPT_TYPE_AES_GCMP == mcRSNEncryptType) ||
5340 (eCSR_ENCRYPT_TYPE_AES_GCMP_256 == mcRSNEncryptType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5342 /*
5343 * For wpa none supplicant sends the WPA IE with unicast
5344 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5345 * multicast cipher as either AES/TKIP based on group
5346 * cipher configuration mentioned in the
5347 * wpa_supplicant.conf.
5348 */
5349
5350 /* Set the unicast cipher same as multicast cipher */
Jeff Johnson844eec72018-03-13 11:48:18 -07005351 roam_profile->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 = mcRSNEncryptType;
5353 }
5354#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005355 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005356 RSNMfpRequired, RSNMfpCapable);
Jeff Johnson844eec72018-03-13 11:48:18 -07005357 roam_profile->MFPRequired = RSNMfpRequired;
5358 roam_profile->MFPCapable = RSNMfpCapable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005359#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005360 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005361 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005362 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305363
5364 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5365 if (hdd_ctx->force_rsne_override &&
Jeff Johnson844eec72018-03-13 11:48:18 -07005366 (security_ie[0] == DOT11F_EID_RSN)) {
Abhishek Singh6454ad32017-12-20 10:42:21 +05305367 hdd_warn("Test mode enabled set def Auth and enc type. RSN IE passed in connect req: ");
5368 qdf_trace_hex_dump(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
Jeff Johnson844eec72018-03-13 11:48:18 -07005369 roam_profile->pRSNReqIE,
5370 roam_profile->nRSNReqIELength);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305371
Jeff Johnson844eec72018-03-13 11:48:18 -07005372 roam_profile->force_rsne_override = true;
Abhishek Singh63781032018-02-23 14:59:22 +05305373
Jeff Johnson844eec72018-03-13 11:48:18 -07005374 hdd_debug("MFPEnabled %d", roam_profile->MFPEnabled);
Abhishek Singh63781032018-02-23 14:59:22 +05305375 /*
Jeff Johnson33142e62018-05-06 17:58:36 -07005376 * Reset MFPEnabled if testmode RSNE passed doesn't have MFPR
Abhishek Singh63781032018-02-23 14:59:22 +05305377 * or MFPC bit set
5378 */
Jeff Johnson844eec72018-03-13 11:48:18 -07005379 if (roam_profile->MFPEnabled &&
5380 !(roam_profile->MFPRequired ||
5381 roam_profile->MFPCapable)) {
Abhishek Singh63781032018-02-23 14:59:22 +05305382 hdd_debug("Reset MFPEnabled");
Jeff Johnson844eec72018-03-13 11:48:18 -07005383 roam_profile->MFPEnabled = 0;
Abhishek Singh63781032018-02-23 14:59:22 +05305384 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305385 /* If parsing failed set the def value for the roam profile */
5386 if (status)
Jeff Johnson844eec72018-03-13 11:48:18 -07005387 hdd_set_def_rsne_override(roam_profile, RSNAuthType);
Abhishek Singh3f13a812018-01-16 14:24:44 +05305388 return 0;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305389 }
Abhishek Singh3f13a812018-01-16 14:24:44 +05305390 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391}
5392
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305393#ifdef WLAN_FEATURE_FILS_SK
5394/**
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305395 * hdd_check_fils_rsn_n_set_auth_type() - This API checks whether a give
5396 * auth type is fils if yes, sets it in profile.
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305397 * @rsn_auth_type: auth type
5398 *
5399 * Return: true if FILS auth else false
5400 */
Jeff Johnson61b5e982018-03-15 11:33:31 -07005401static
5402bool hdd_check_fils_rsn_n_set_auth_type(struct csr_roam_profile *roam_profile,
5403 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305404{
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305405 bool is_fils_rsn = false;
5406
5407 if (!roam_profile->fils_con_info)
5408 return false;
5409
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305410 if ((rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA256) ||
5411 (rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA384) ||
5412 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA256) ||
5413 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA384))
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305414 is_fils_rsn = true;
5415 if (is_fils_rsn)
5416 roam_profile->fils_con_info->akm_type = rsn_auth_type;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305417
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305418 return is_fils_rsn;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305419}
5420#else
Jeff Johnson61b5e982018-03-15 11:33:31 -07005421static
5422bool hdd_check_fils_rsn_n_set_auth_type(struct csr_roam_profile *roam_profile,
5423 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305424{
5425 return false;
5426}
5427#endif
5428
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429/**
5430 * hdd_set_csr_auth_type() - set csr auth type
Jeff Johnsonba388342017-10-02 13:31:01 -07005431 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432 * @RSNAuthType: auth type
5433 *
5434 * Return: 0 on success, error number otherwise
5435 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005436int hdd_set_csr_auth_type(struct hdd_adapter *adapter,
Jeff Johnson2a722002017-09-30 20:02:35 -07005437 eCsrAuthType RSNAuthType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438{
Jeff Johnson844eec72018-03-13 11:48:18 -07005439 struct csr_roam_profile *roam_profile;
Jeff Johnsond377dce2017-10-04 10:32:42 -07005440 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07005441 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson37ecea42018-03-18 17:54:40 -07005442 enum hdd_auth_key_mgmt key_mgmt = sta_ctx->auth_key_mgmt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443
Jeff Johnson844eec72018-03-13 11:48:18 -07005444 roam_profile = hdd_roam_profile(adapter);
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005445 roam_profile->AuthType.numEntries = 1;
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305446 hdd_debug("authType = %d RSNAuthType %d wpa_versions %d",
5447 sta_ctx->conn_info.authType, RSNAuthType,
5448 sta_ctx->wpa_versions);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005449
Jeff Johnsond377dce2017-10-04 10:32:42 -07005450 switch (sta_ctx->conn_info.authType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5452#ifdef FEATURE_WLAN_ESE
5453 case eCSR_AUTH_TYPE_CCKM_WPA:
5454 case eCSR_AUTH_TYPE_CCKM_RSN:
5455#endif
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005456 if (!sta_ctx->wpa_versions) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005458 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005459 eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005460 } else if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461
5462#ifdef FEATURE_WLAN_ESE
5463 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005464 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5465 == HDD_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005466 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005467 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468 eCSR_AUTH_TYPE_CCKM_WPA;
5469 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005470 hdd_debug("Last chance to set authType to CCKM WPA.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005471 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472 eCSR_AUTH_TYPE_CCKM_WPA;
5473 } else
5474#endif
Jeff Johnson37ecea42018-03-18 17:54:40 -07005475 if ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5476 == HDD_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005477 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 eCSR_AUTH_TYPE_WPA;
5479 } else
Jeff Johnson37ecea42018-03-18 17:54:40 -07005480 if ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5481 == HDD_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005482 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 eCSR_AUTH_TYPE_WPA_PSK;
5484 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005485 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 eCSR_AUTH_TYPE_WPA_NONE;
5487 }
5488 }
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005489 if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_2) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490#ifdef FEATURE_WLAN_ESE
5491 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005492 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5493 == HDD_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005494 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005495 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496 eCSR_AUTH_TYPE_CCKM_RSN;
5497 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005498 hdd_debug("Last chance to set authType to CCKM RSN.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005499 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500 eCSR_AUTH_TYPE_CCKM_RSN;
5501 } else
5502#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +05305503 if (RSNAuthType == eCSR_AUTH_TYPE_DPP_RSN) {
5504 roam_profile->AuthType.authType[0] =
5505 eCSR_AUTH_TYPE_DPP_RSN;
5506 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005507 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5508 == HDD_AUTH_KEY_MGMT_802_1X)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005509 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005510 eCSR_AUTH_TYPE_FT_RSN;
5511 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5512 &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005513 ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5514 == HDD_AUTH_KEY_MGMT_PSK)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005515 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 eCSR_AUTH_TYPE_FT_RSN_PSK;
5517 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518
5519#ifdef WLAN_FEATURE_11W
5520 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005521 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5523 } else if (RSNAuthType ==
5524 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005525 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5527 } else
5528#endif
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005529 if (hdd_check_fils_rsn_n_set_auth_type(roam_profile,
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305530 RSNAuthType)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005531 roam_profile->AuthType.authType[0] =
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305532 RSNAuthType;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05305533 hdd_debug("updated profile authtype as %d",
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305534 RSNAuthType);
5535
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305536 } else if ((RSNAuthType == eCSR_AUTH_TYPE_OWE) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005537 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5538 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305539 /* OWE case */
5540 roam_profile->AuthType.authType[0] =
5541 eCSR_AUTH_TYPE_OWE;
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305542 } else if ((RSNAuthType ==
5543 eCSR_AUTH_TYPE_SUITEB_EAP_SHA256) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005544 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5545 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305546 /* Suite B EAP SHA 256 */
5547 roam_profile->AuthType.authType[0] =
5548 eCSR_AUTH_TYPE_SUITEB_EAP_SHA256;
5549 } else if ((RSNAuthType ==
5550 eCSR_AUTH_TYPE_SUITEB_EAP_SHA384) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005551 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5552 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305553 /* Suite B EAP SHA 384 */
5554 roam_profile->AuthType.authType[0] =
5555 eCSR_AUTH_TYPE_SUITEB_EAP_SHA384;
Jeff Johnson37ecea42018-03-18 17:54:40 -07005556 } else if ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5557 == HDD_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005558 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 eCSR_AUTH_TYPE_RSN;
5560 } else
Jeff Johnson37ecea42018-03-18 17:54:40 -07005561 if ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5562 == HDD_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005563 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564 eCSR_AUTH_TYPE_RSN_PSK;
5565 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005566 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567 eCSR_AUTH_TYPE_UNKNOWN;
5568 }
5569 }
5570 break;
5571
5572 case eCSR_AUTH_TYPE_SHARED_KEY:
5573
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005574 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305576
5577 case eCSR_AUTH_TYPE_SAE:
5578 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5579 break;
5580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005581 default:
5582
5583#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005584 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585#endif /* FEATURE_WLAN_ESE */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005586 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 break;
5588 }
5589
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005590 hdd_debug("Set roam Authtype to %d",
Jeff Johnson844eec72018-03-13 11:48:18 -07005591 roam_profile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593 return 0;
5594}
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005595
5596#ifdef WLAN_FEATURE_FILS_SK
5597static void hdd_initialize_fils_info(struct hdd_adapter *adapter)
5598{
5599 struct csr_roam_profile *roam_profile;
5600
5601 roam_profile = hdd_roam_profile(adapter);
5602 roam_profile->fils_con_info = NULL;
5603 roam_profile->hlp_ie = NULL;
5604 roam_profile->hlp_ie_len = 0;
5605}
5606#else
5607static void hdd_initialize_fils_info(struct hdd_adapter *adapter)
5608{ }
5609#endif
5610
5611void hdd_roam_profile_init(struct hdd_adapter *adapter)
5612{
5613 struct csr_roam_profile *roam_profile;
5614 uint8_t *security_ie;
5615 tSirAddie *assoc_additional_ie;
5616 struct hdd_station_ctx *sta_ctx;
5617
5618 hdd_enter();
5619
5620 roam_profile = hdd_roam_profile(adapter);
5621 qdf_mem_zero(roam_profile, sizeof(*roam_profile));
5622
5623 security_ie = hdd_security_ie(adapter);
5624 qdf_mem_zero(security_ie, MAX_WPA_RSN_IE_LEN);
5625
5626 assoc_additional_ie = hdd_assoc_additional_ie(adapter);
5627 qdf_mem_zero(assoc_additional_ie, sizeof(*assoc_additional_ie));
5628
5629 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
5630
5631 /* Configure the roaming profile links to SSID and bssid. */
5632 roam_profile->SSIDs.numOfSSIDs = 0;
5633 roam_profile->SSIDs.SSIDList = &sta_ctx->conn_info.SSID;
5634
5635 roam_profile->BSSIDs.numOfBSSIDs = 0;
5636 roam_profile->BSSIDs.bssid = &sta_ctx->conn_info.bssId;
5637
5638 /* Set the numOfChannels to zero to scan all the channels */
5639 roam_profile->ChannelInfo.numOfChannels = 0;
5640 roam_profile->ChannelInfo.ChannelList = NULL;
5641
5642 roam_profile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
5643
5644 roam_profile->phyMode = eCSR_DOT11_MODE_AUTO;
5645 sta_ctx->wpa_versions = 0;
5646
5647 /* Set the default scan mode */
5648 adapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
5649
5650 hdd_clear_roam_profile_ie(adapter);
5651
5652 hdd_initialize_fils_info(adapter);
5653
5654 hdd_exit();
5655}