blob: 6be2042339686d1dea2e6d7c2196215ed40edae8 [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 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_assoc.c
30 *
31 * WLAN Host Device Driver implementation
32 *
33 */
34
35#include "wlan_hdd_includes.h"
36#include <ani_global.h>
37#include "dot11f.h"
38#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053039#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include <linux/ieee80211.h>
41#include <linux/wireless.h>
42#include <linux/etherdevice.h>
43#include <net/cfg80211.h>
44#include "wlan_hdd_cfg80211.h"
45#include "csr_inside_api.h"
46#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_api.h"
49#include "wlan_hdd_hostapd.h"
50#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070051#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070052#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <cds_sched.h>
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -080054#include "wlan_policy_mgr_api.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053055#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070057#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070058#include <cdp_txrx_cmn.h>
59#include <cdp_txrx_flow_ctrl_legacy.h>
60#include <cdp_txrx_peer_ops.h>
61#include <cdp_txrx_misc.h>
Kabilan Kannan256e3182017-05-02 16:02:37 -070062#include <cdp_txrx_ctrl.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053063#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080064#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080065#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053066#include "wlan_pmo_ucfg_api.h"
Yu Wang000dc2f2017-05-26 17:38:48 +080067#include "wlan_hdd_tsf.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070068#include "wlan_utility.h"
Wu Gaoc02785d2017-09-07 18:17:13 +080069#include "wlan_p2p_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070
71/* These are needed to recognize WPA and RSN suite types */
72#define HDD_WPA_OUI_SIZE 4
73#define HDD_RSN_OUI_SIZE 4
74uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
75uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
76uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
77uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
78uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
79uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
80
81#ifdef FEATURE_WLAN_ESE
82/* CCKM */
83uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
84/* CCKM */
85uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
86#endif /* FEATURE_WLAN_ESE */
87
88/* group cipher */
89uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
90
91/* WEP-40 or RSN */
92uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
93
94/* TKIP or RSN-PSK */
95uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
96
97/* Reserved */
98uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
99
100/* AES-CCMP */
101uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
102
103/* WEP-104 */
104uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
105
106#ifdef WLAN_FEATURE_11W
107/* RSN-PSK-SHA256 */
108uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
109
110/* RSN-8021X-SHA256 */
111uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
112#endif
113
Mukul Sharma05504ac2017-06-08 12:35:53 +0530114/* AES-GCMP-128 */
115uint8_t ccp_rsn_oui09[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x08 };
116
117/* AES-GCMP-256 */
118uint8_t ccp_rsn_oui0a[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x09 };
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +0530119#ifdef WLAN_FEATURE_FILS_SK
120uint8_t ccp_rsn_oui_0e[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0E};
121uint8_t ccp_rsn_oui_0f[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0F};
122uint8_t ccp_rsn_oui_10[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x10};
123uint8_t ccp_rsn_oui_11[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x11};
124#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +0530125uint8_t ccp_rsn_oui_12[HDD_RSN_OUI_SIZE] = {0x50, 0x6F, 0x9A, 0x02};
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +0530126uint8_t ccp_rsn_oui_0b[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0B};
127uint8_t ccp_rsn_oui_0c[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0C};
Mukul Sharma05504ac2017-06-08 12:35:53 +0530128
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +0530129/* OWE https://tools.ietf.org/html/rfc8110 */
130uint8_t ccp_rsn_oui_18[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x12};
131
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530132#ifdef WLAN_FEATURE_SAE
133uint8_t ccp_rsn_oui_80[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x08};
134uint8_t ccp_rsn_oui_90[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x09};
135#endif
136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137/* Offset where the EID-Len-IE, start. */
138#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
139#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800140
141#define BEACON_FRAME_IES_OFFSET 12
142#define HDD_PEER_AUTHORIZE_WAIT 10
143
144/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700145 * beacon_filter_table - table of IEs used for beacon filtering
146 */
147static const int beacon_filter_table[] = {
148 SIR_MAC_DS_PARAM_SET_EID,
149 SIR_MAC_ERP_INFO_EID,
150 SIR_MAC_EDCA_PARAM_SET_EID,
151 SIR_MAC_QOS_CAPABILITY_EID,
152 SIR_MAC_HT_INFO_EID,
153 SIR_MAC_VHT_OPMODE_EID,
154 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700155#ifdef WLAN_FEATURE_11AX_BSS_COLOR
156 /*
157 * EID: 221 vendor IE is being used temporarily by 11AX
158 * bss-color-change IE till it gets any fixed number. This
159 * vendor EID needs to be replaced with bss-color-change IE
160 * number.
161 */
162 SIR_MAC_EID_VENDOR,
163#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700164};
165
166/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 * hdd_conn_set_authenticated() - set authentication state
Jeff Johnsonba388342017-10-02 13:31:01 -0700168 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 * @authState: authentication state
170 *
171 * This function updates the global HDD station context
172 * authentication state.
173 *
174 * Return: none
175 */
176static void
Jeff Johnsonba388342017-10-02 13:31:01 -0700177hdd_conn_set_authenticated(struct hdd_adapter *adapter, uint8_t authState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700179 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180
181 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700182 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Jeff Johnsond377dce2017-10-04 10:32:42 -0700183 sta_ctx->conn_info.uIsAuthenticated, authState);
184 sta_ctx->conn_info.uIsAuthenticated = authState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185}
186
187/**
188 * hdd_conn_set_connection_state() - set connection state
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700189 * @adapter: pointer to the adapter
190 * @conn_state: connection state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191 *
192 * This function updates the global HDD station context connection state.
193 *
194 * Return: none
195 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700196void hdd_conn_set_connection_state(struct hdd_adapter *adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700197 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700199 struct hdd_station_ctx *hdd_sta_ctx =
200 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201
202 /* save the new connection state */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700203 hdd_debug("%pS Changed conn state from old:%d to new:%d for dev %s",
204 (void *)_RET_IP_, hdd_sta_ctx->conn_info.connState,
205 conn_state, adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800206
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700207 hdd_tsf_notify_wlan_state_change(adapter,
208 hdd_sta_ctx->conn_info.connState,
209 conn_state);
210 hdd_sta_ctx->conn_info.connState = conn_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211}
212
213/**
214 * hdd_conn_get_connection_state() - get connection state
Jeff Johnsonba388342017-10-02 13:31:01 -0700215 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216 * @pConnState: pointer to connection state
217 *
218 * This function updates the global HDD station context connection state.
219 *
220 * Return: true if (Infra Associated or IBSS Connected)
221 * and sets output parameter pConnState;
222 * false otherwise
223 */
Jeff Johnson435e1b82017-10-07 14:13:10 -0700224static inline bool
225hdd_conn_get_connection_state(struct hdd_station_ctx *sta_ctx,
226 eConnectionState *pConnState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227{
228 bool fConnected = false;
229 eConnectionState connState;
230
231 /* get the connection state. */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700232 connState = sta_ctx->conn_info.connState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233
234 if (eConnectionState_Associated == connState ||
235 eConnectionState_IbssConnected == connState ||
236 eConnectionState_IbssDisconnected == connState) {
237 fConnected = true;
238 }
239
240 if (pConnState)
241 *pConnState = connState;
242
243 return fConnected;
244}
245
246/**
247 * hdd_is_connecting() - Function to check connection progress
248 * @hdd_sta_ctx: pointer to global HDD Station context
249 *
250 * Return: true if connecting, false otherwise
251 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700252bool hdd_is_connecting(struct hdd_station_ctx *hdd_sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253{
254 return hdd_sta_ctx->conn_info.connState ==
255 eConnectionState_Connecting;
256}
257
258/**
259 * hdd_conn_is_connected() - Function to check connection status
Jeff Johnsond377dce2017-10-04 10:32:42 -0700260 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261 *
262 * Return: false if any errors encountered, true otherwise
263 */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700264bool hdd_conn_is_connected(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700266 return hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267}
268
269/**
270 * hdd_conn_get_connected_band() - get current connection radio band
Jeff Johnsond377dce2017-10-04 10:32:42 -0700271 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 *
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800273 * Return: BAND_2G or BAND_5G based on current AP connection
274 * BAND_ALL if not connected
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700276enum band_info hdd_conn_get_connected_band(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277{
278 uint8_t staChannel = 0;
279
Jeff Johnsond377dce2017-10-04 10:32:42 -0700280 if (eConnectionState_Associated == sta_ctx->conn_info.connState)
281 staChannel = sta_ctx->conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282
283 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700284 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700286 return BAND_5G;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800287 else /* If station is not connected return as BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700288 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289}
290
291/**
292 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
Jeff Johnsond377dce2017-10-04 10:32:42 -0700293 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 * @pConnectedCipherAlgo: pointer to connected cipher algo
295 *
296 * Return: false if any errors encountered, true otherwise
297 */
298static inline bool
Jeff Johnsond377dce2017-10-04 10:32:42 -0700299hdd_conn_get_connected_cipher_algo(struct hdd_station_ctx *sta_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 eCsrEncryptionType *pConnectedCipherAlgo)
301{
302 bool fConnected = false;
303
Jeff Johnsond377dce2017-10-04 10:32:42 -0700304 fConnected = hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305
306 if (pConnectedCipherAlgo)
Jeff Johnsond377dce2017-10-04 10:32:42 -0700307 *pConnectedCipherAlgo = sta_ctx->conn_info.ucEncryptionType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308
309 return fConnected;
310}
311
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530312struct hdd_adapter *hdd_get_sta_connection_in_progress(
313 struct hdd_context *hdd_ctx)
314{
315 struct hdd_adapter *adapter = NULL;
316 struct hdd_station_ctx *hdd_sta_ctx;
317
318 if (!hdd_ctx) {
319 hdd_err("HDD context is NULL");
320 return NULL;
321 }
322
323 hdd_for_each_adapter(hdd_ctx, adapter) {
324 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
325 if ((QDF_STA_MODE == adapter->device_mode) ||
326 (QDF_P2P_CLIENT_MODE == adapter->device_mode) ||
327 (QDF_P2P_DEVICE_MODE == adapter->device_mode)) {
328 if (eConnectionState_Connecting ==
329 hdd_sta_ctx->conn_info.connState) {
330 hdd_debug("session_id %d: Connection is in progress",
331 adapter->session_id);
332 return adapter;
333 } else if ((eConnectionState_Associated ==
334 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0a569292018-02-14 15:34:47 +0530335 sme_is_sta_key_exchange_in_progress(
336 hdd_ctx->hHal, adapter->session_id)) {
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530337 hdd_debug("session_id %d: Key exchange is in progress",
338 adapter->session_id);
339 return adapter;
340 }
341 }
342 }
343 return NULL;
344}
345
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700347 * hdd_remove_beacon_filter() - remove beacon filter
348 * @adapter: Pointer to the hdd adapter
349 *
350 * Return: 0 on success and errno on failure
351 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700352static int hdd_remove_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700353{
354 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700355 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700356
357 status = sme_remove_beacon_filter(hdd_ctx->hHal,
Jeff Johnson1b780e42017-10-31 14:11:45 -0700358 adapter->session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700359 if (!QDF_IS_STATUS_SUCCESS(status)) {
360 hdd_err("sme_remove_beacon_filter() failed");
361 return -EFAULT;
362 }
363
364 return 0;
365}
366
367/**
368 * hdd_add_beacon_filter() - add beacon filter
369 * @adapter: Pointer to the hdd adapter
370 *
371 * Return: 0 on success and errno on failure
372 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700373static int hdd_add_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700374{
375 int i;
376 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
377 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700378 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700379
380 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530381 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700382 (unsigned long int *)ie_map);
383
384 status = sme_add_beacon_filter(hdd_ctx->hHal,
Jeff Johnson1b780e42017-10-31 14:11:45 -0700385 adapter->session_id, ie_map);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700386 if (!QDF_IS_STATUS_SUCCESS(status)) {
387 hdd_err("sme_add_beacon_filter() failed");
388 return -EFAULT;
389 }
390 return 0;
391}
392
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530393void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
394 tDot11fIEHTCaps *roam_ht_cap)
395
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530396{
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530397 uint32_t i, temp_ht_cap;
398
399 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
400
401 if (roam_ht_cap->advCodingCap)
402 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
403 if (roam_ht_cap->supportedChannelWidthSet)
404 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
405 temp_ht_cap = roam_ht_cap->mimoPowerSave &
406 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
407 if (temp_ht_cap)
408 hdd_ht_cap->cap_info |=
409 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
410 if (roam_ht_cap->greenField)
411 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
412 if (roam_ht_cap->shortGI20MHz)
413 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
414 if (roam_ht_cap->shortGI40MHz)
415 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
416 if (roam_ht_cap->txSTBC)
417 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
418 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
419 IEEE80211_HT_CAP_RX_STBC_SHIFT);
420 if (temp_ht_cap)
421 hdd_ht_cap->cap_info |=
422 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
423 if (roam_ht_cap->delayedBA)
424 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
425 if (roam_ht_cap->maximalAMSDUsize)
426 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
427 if (roam_ht_cap->dsssCckMode40MHz)
428 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
429 if (roam_ht_cap->psmp)
430 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
431 if (roam_ht_cap->stbcControlFrame)
432 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
433 if (roam_ht_cap->lsigTXOPProtection)
434 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
435
436 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
437 if (roam_ht_cap->maxRxAMPDUFactor)
438 hdd_ht_cap->ampdu_params_info |=
439 IEEE80211_HT_AMPDU_PARM_FACTOR;
440 temp_ht_cap = roam_ht_cap->mpduDensity &
441 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
442 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
443 if (temp_ht_cap)
444 hdd_ht_cap->ampdu_params_info |=
445 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
446
447 /* 802.11n HT extended capabilities masks */
448 if (roam_ht_cap->pco)
449 hdd_ht_cap->extended_ht_cap_info |=
450 IEEE80211_HT_EXT_CAP_PCO;
451 temp_ht_cap = roam_ht_cap->transitionTime &
452 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
453 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
454 if (temp_ht_cap)
455 hdd_ht_cap->extended_ht_cap_info |=
456 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
457 temp_ht_cap = roam_ht_cap->mcsFeedback &
458 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
459 if (temp_ht_cap)
460 hdd_ht_cap->extended_ht_cap_info |=
461 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
462
463 /* tx_bf_cap_info capabilities */
464 if (roam_ht_cap->txBF)
465 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
466 if (roam_ht_cap->rxStaggeredSounding)
467 hdd_ht_cap->tx_BF_cap_info |=
468 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
469 if (roam_ht_cap->txStaggeredSounding)
470 hdd_ht_cap->tx_BF_cap_info |=
471 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
472 if (roam_ht_cap->rxZLF)
473 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
474 if (roam_ht_cap->txZLF)
475 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
476 if (roam_ht_cap->implicitTxBF)
477 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
478 temp_ht_cap = roam_ht_cap->calibration &
479 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
480 if (temp_ht_cap)
481 hdd_ht_cap->tx_BF_cap_info |=
482 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
483 if (roam_ht_cap->explicitCSITxBF)
484 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
485 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
486 hdd_ht_cap->tx_BF_cap_info |=
487 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
488 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
489 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
490 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
491 if (temp_ht_cap)
492 hdd_ht_cap->tx_BF_cap_info |=
493 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
494 temp_ht_cap =
495 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
496 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
497 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
498 if (temp_ht_cap)
499 hdd_ht_cap->tx_BF_cap_info |=
500 temp_ht_cap <<
501 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
502 temp_ht_cap =
503 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
504 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
505 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
506 if (temp_ht_cap)
507 hdd_ht_cap->tx_BF_cap_info |=
508 temp_ht_cap <<
509 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
510 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
511 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
512 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
513 if (temp_ht_cap)
514 hdd_ht_cap->tx_BF_cap_info |=
515 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
516 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
517 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
518 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
519 if (temp_ht_cap)
520 hdd_ht_cap->tx_BF_cap_info |=
521 temp_ht_cap <<
522 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
523 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
524 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
525 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
526 if (temp_ht_cap)
527 hdd_ht_cap->tx_BF_cap_info |=
528 temp_ht_cap <<
529 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
530
531 /* antenna selection */
532 if (roam_ht_cap->antennaSelection)
533 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
534 if (roam_ht_cap->explicitCSIFeedbackTx)
535 hdd_ht_cap->antenna_selection_info |=
536 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
537 if (roam_ht_cap->antennaIndicesFeedbackTx)
538 hdd_ht_cap->antenna_selection_info |=
539 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
540 if (roam_ht_cap->explicitCSIFeedback)
541 hdd_ht_cap->antenna_selection_info |=
542 ANTENNA_SEL_INFO_EXP_CSI_FB;
543 if (roam_ht_cap->antennaIndicesFeedback)
544 hdd_ht_cap->antenna_selection_info |=
545 ANTENNA_SEL_INFO_ANT_ID_FB;
546 if (roam_ht_cap->rxAS)
547 hdd_ht_cap->antenna_selection_info |=
548 ANTENNA_SEL_INFO_RX_AS;
549 if (roam_ht_cap->txSoundingPPDUs)
550 hdd_ht_cap->antenna_selection_info |=
551 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
552
553 /* mcs data rate */
554 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
555 hdd_ht_cap->mcs.rx_mask[i] =
556 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800557 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530558 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
559 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800560 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530561 roam_ht_cap->supportedMCSSet[12];
562}
563
564#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
565#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
566#define VHT_CAP_RXSTBC_MASK_SHIFT 8
567#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
568#define VHT_CAP_BEAMFORMEE_STS_MASK \
569 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
570#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
571#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
572 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
573#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
574#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
575 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
576#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
577
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530578void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
579 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530580{
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530581 uint32_t temp_vht_cap;
582
583 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
584
585 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
586 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
587 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
588 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
589 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800590 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530591 if (roam_vht_cap->supportedChannelWidthSet &
592 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
593 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
594 hdd_vht_cap->vht_cap_info |=
595 temp_vht_cap <<
596 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
597 if (roam_vht_cap->supportedChannelWidthSet &
598 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
599 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
600 hdd_vht_cap->vht_cap_info |=
601 temp_vht_cap <<
602 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800603 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530604 if (roam_vht_cap->ldpcCodingCap)
605 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
606 if (roam_vht_cap->shortGI80MHz)
607 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
608 if (roam_vht_cap->shortGI160and80plus80MHz)
609 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
610 if (roam_vht_cap->txSTBC)
611 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
612 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
613 VHT_CAP_RXSTBC_MASK_SHIFT);
614 if (temp_vht_cap)
615 hdd_vht_cap->vht_cap_info |=
616 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
617 if (roam_vht_cap->suBeamFormerCap)
618 hdd_vht_cap->vht_cap_info |=
619 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
620 if (roam_vht_cap->suBeamformeeCap)
621 hdd_vht_cap->vht_cap_info |=
622 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
623 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
624 (VHT_CAP_BEAMFORMEE_STS_MASK);
625 if (temp_vht_cap)
626 hdd_vht_cap->vht_cap_info |=
627 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
628 temp_vht_cap = roam_vht_cap->numSoundingDim &
629 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
630 if (temp_vht_cap)
631 hdd_vht_cap->vht_cap_info |=
632 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
633 if (roam_vht_cap->muBeamformerCap)
634 hdd_vht_cap->vht_cap_info |=
635 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
636 if (roam_vht_cap->muBeamformeeCap)
637 hdd_vht_cap->vht_cap_info |=
638 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
639 if (roam_vht_cap->vhtTXOPPS)
640 hdd_vht_cap->vht_cap_info |=
641 IEEE80211_VHT_CAP_VHT_TXOP_PS;
642 if (roam_vht_cap->htcVHTCap)
643 hdd_vht_cap->vht_cap_info |=
644 IEEE80211_VHT_CAP_HTC_VHT;
645 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
646 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
647 if (temp_vht_cap)
648 hdd_vht_cap->vht_cap_info |=
649 temp_vht_cap <<
650 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
651 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
652 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
653 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
654 if (temp_vht_cap)
655 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
656 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
657 if (roam_vht_cap->rxAntPattern)
658 hdd_vht_cap->vht_cap_info |=
659 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
660 if (roam_vht_cap->txAntPattern)
661 hdd_vht_cap->vht_cap_info |=
662 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
663 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
664 hdd_vht_cap->supp_mcs.rx_highest =
665 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
666 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
667 hdd_vht_cap->supp_mcs.tx_highest =
668 ((uint16_t)roam_vht_cap->txSupDataRate);
669}
670
671/* ht param */
672#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
673#define HT_PARAM_SERVICE_INT_GRAN 0xe0
674#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
675
676/* operatinon mode */
677#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
678
679/* stbc_param */
680#define HT_STBC_PARAM_MCS 0x007f
681
682/**
683 * hdd_copy_ht_operation()- copy HT operation element from roam info to
684 * hdd station context.
685 * @hdd_sta_ctx: pointer to hdd station context
686 * @roam_info: pointer to roam info
687 *
688 * Return: None
689 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700690static void hdd_copy_ht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800691 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530692{
693 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
694 struct ieee80211_ht_operation *hdd_ht_ops =
695 &hdd_sta_ctx->conn_info.ht_operation;
696 uint32_t i, temp_ht_ops;
697
698 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
699
700 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
701
702 /* HT_PARAMS */
703 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
704 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
705 if (temp_ht_ops)
706 hdd_ht_ops->ht_param |= temp_ht_ops;
707 else
708 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
709 if (roam_ht_ops->recommendedTxWidthSet)
710 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
711 if (roam_ht_ops->rifsMode)
712 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
713 if (roam_ht_ops->controlledAccessOnly)
714 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
715 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
716 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
717 if (temp_ht_ops)
718 hdd_ht_ops->ht_param |= temp_ht_ops <<
719 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
720
721 /* operation mode */
722 temp_ht_ops = roam_ht_ops->opMode &
723 IEEE80211_HT_OP_MODE_PROTECTION;
724 switch (temp_ht_ops) {
725 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
726 hdd_ht_ops->operation_mode |=
727 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
728 break;
729 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
730 hdd_ht_ops->operation_mode |=
731 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
732 break;
733 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
734 hdd_ht_ops->operation_mode |=
735 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
736 break;
737 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
738 default:
739 hdd_ht_ops->operation_mode |=
740 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
741 }
742 if (roam_ht_ops->nonGFDevicesPresent)
743 hdd_ht_ops->operation_mode |=
744 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
745 if (roam_ht_ops->transmitBurstLimit)
746 hdd_ht_ops->operation_mode |=
747 HT_OP_MODE_TX_BURST_LIMIT;
748 if (roam_ht_ops->obssNonHTStaPresent)
749 hdd_ht_ops->operation_mode |=
750 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
751
752 /* stbc_param */
753 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
754 HT_STBC_PARAM_MCS;
755 if (temp_ht_ops)
756 hdd_ht_ops->stbc_param |= temp_ht_ops;
757 if (roam_ht_ops->dualCTSProtection)
758 hdd_ht_ops->stbc_param |=
759 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
760 if (roam_ht_ops->secondaryBeacon)
761 hdd_ht_ops->stbc_param |=
762 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
763 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
764 hdd_ht_ops->stbc_param |=
765 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
766 if (roam_ht_ops->pcoActive)
767 hdd_ht_ops->stbc_param |=
768 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
769 if (roam_ht_ops->pcoPhase)
770 hdd_ht_ops->stbc_param |=
771 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
772
773 /* basic MCs set */
774 for (i = 0; i < 16; ++i)
775 hdd_ht_ops->basic_set[i] =
776 roam_ht_ops->basicMCSSet[i];
777}
778
Dustin Brown8aef46d2017-08-10 15:44:50 -0700779#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
780static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
781 tDot11fIEVHTOperation *roam_ops)
782{
783 ieee_ops->center_freq_seg0_idx = roam_ops->chanCenterFreqSeg1;
784 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg2;
785}
786#else
787static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
788 tDot11fIEVHTOperation *roam_ops)
789{
790 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg1;
791 ieee_ops->center_freq_seg2_idx = roam_ops->chanCenterFreqSeg2;
792}
793#endif /* KERNEL_VERSION(4, 12, 0) */
794
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530795/**
796 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
797 * hdd station context.
798 * @hdd_sta_ctx: pointer to hdd station context
799 * @roam_info: pointer to roam info
800 *
801 * Return: None
802 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700803static void hdd_copy_vht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800804 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530805{
806 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
807 struct ieee80211_vht_operation *hdd_vht_ops =
808 &hdd_sta_ctx->conn_info.vht_operation;
809
810 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
811
812 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
Dustin Brown8aef46d2017-08-10 15:44:50 -0700813 hdd_copy_vht_center_freq(hdd_vht_ops, roam_vht_ops);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530814 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
815}
816
817
818/**
819 * hdd_save_bss_info() - save connection info in hdd sta ctx
820 * @adapter: Pointer to adapter
821 * @roam_info: pointer to roam info
822 *
823 * Return: None
824 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700825static void hdd_save_bss_info(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -0800826 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530827{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700828 struct hdd_station_ctx *hdd_sta_ctx =
829 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530830
831 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
832 hdd_sta_ctx->conn_info.operationChannel);
833 if (roam_info->vht_caps.present) {
834 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530835 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
836 &roam_info->vht_caps);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530837 } else {
838 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
839 }
840 if (roam_info->ht_caps.present) {
841 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530842 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps,
843 &roam_info->ht_caps);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530844 } else {
845 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
846 }
847 if (roam_info->reassoc)
848 hdd_sta_ctx->conn_info.roam_count++;
849 if (roam_info->hs20vendor_ie.present) {
850 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
851 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
852 &roam_info->hs20vendor_ie,
853 sizeof(roam_info->hs20vendor_ie));
854 } else {
855 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
856 }
857 if (roam_info->ht_operation.present) {
858 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
859 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
860 } else {
861 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
862 }
863 if (roam_info->vht_operation.present) {
864 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
865 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
866 } else {
867 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
868 }
869}
870
871/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 * hdd_conn_save_connect_info() - save current connection information
Jeff Johnsonba388342017-10-02 13:31:01 -0700873 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -0700874 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 * @eBssType: bss type
876 *
877 * Return: none
878 */
879static void
Jeff Johnson172237b2017-11-07 15:32:59 -0800880hdd_conn_save_connect_info(struct hdd_adapter *adapter,
881 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 eCsrRoamBssType eBssType)
883{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700884 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
886
Jeff Johnsonfd060852017-10-04 10:50:51 -0700887 QDF_ASSERT(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888
Jeff Johnsonfd060852017-10-04 10:50:51 -0700889 if (roam_info) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 /* Save the BSSID for the connection */
891 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Jeff Johnsonfd060852017-10-04 10:50:51 -0700892 QDF_ASSERT(roam_info->pBssDesc);
Jeff Johnsond377dce2017-10-04 10:32:42 -0700893 qdf_copy_macaddr(&sta_ctx->conn_info.bssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700894 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895
896 /*
897 * Save the Station ID for this station from
898 * the 'Roam Info'. For IBSS mode, staId is
899 * assigned in NEW_PEER_IND. For reassoc,
900 * the staID doesn't change and it may be invalid
901 * in this structure so no change here.
902 */
Jeff Johnsonfd060852017-10-04 10:50:51 -0700903 if (!roam_info->fReassocReq) {
Jeff Johnsond377dce2017-10-04 10:32:42 -0700904 sta_ctx->conn_info.staId[0] =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700905 roam_info->staId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 }
907 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Jeff Johnsond377dce2017-10-04 10:32:42 -0700908 qdf_copy_macaddr(&sta_ctx->conn_info.bssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700909 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 } else {
911 /*
912 * can't happen. We need a valid IBSS or Infra setting
913 * in the BSSDescription or we can't function.
914 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530915 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 }
917
918 /* notify WMM */
Jeff Johnsonfd060852017-10-04 10:50:51 -0700919 hdd_wmm_connect(adapter, roam_info, eBssType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920
Jeff Johnsonfd060852017-10-04 10:50:51 -0700921 if (!roam_info->u.pConnectedProfile) {
922 QDF_ASSERT(roam_info->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923 } else {
924 /* Get Multicast Encryption Type */
925 encryptType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700926 roam_info->u.pConnectedProfile->mcEncryptionType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700927 sta_ctx->conn_info.mcEncryptionType = encryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 /* Get Unicast Encryption Type */
929 encryptType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700930 roam_info->u.pConnectedProfile->EncryptionType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700931 sta_ctx->conn_info.ucEncryptionType = encryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932
Jeff Johnsond377dce2017-10-04 10:32:42 -0700933 sta_ctx->conn_info.authType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700934 roam_info->u.pConnectedProfile->AuthType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700935 sta_ctx->conn_info.last_auth_type =
936 sta_ctx->conn_info.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937
Jeff Johnsond377dce2017-10-04 10:32:42 -0700938 sta_ctx->conn_info.operationChannel =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700939 roam_info->u.pConnectedProfile->operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940
941 /* Save the ssid for the connection */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700942 qdf_mem_copy(&sta_ctx->conn_info.SSID.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700943 &roam_info->u.pConnectedProfile->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 sizeof(tSirMacSSid));
Jeff Johnsond377dce2017-10-04 10:32:42 -0700945 qdf_mem_copy(&sta_ctx->conn_info.last_ssid.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700946 &roam_info->u.pConnectedProfile->SSID,
Zhang Qian32fd43e2017-08-24 18:36:28 +0800947 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948
949 /* Save dot11mode in which STA associated to AP */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700950 sta_ctx->conn_info.dot11Mode =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700951 roam_info->u.pConnectedProfile->dot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952
Jeff Johnsond377dce2017-10-04 10:32:42 -0700953 sta_ctx->conn_info.proxyARPService =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700954 roam_info->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530955
Jeff Johnsonfd060852017-10-04 10:50:51 -0700956 sta_ctx->conn_info.nss = roam_info->chan_info.nss;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530957
Jeff Johnsond377dce2017-10-04 10:32:42 -0700958 sta_ctx->conn_info.rate_flags =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700959 roam_info->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 }
Jeff Johnsonfd060852017-10-04 10:50:51 -0700961 hdd_save_bss_info(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963}
964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965/**
966 * hdd_send_ft_assoc_response() - send fast transition assoc response
967 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -0700968 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 * @pCsrRoamInfo: pointer to roam info
970 *
971 * Send the 11R key information to the supplicant. Only then can the supplicant
972 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
973 * for the same purpose.)
974 *
975 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
976 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
977 * This is the Assoc Response.
978 *
979 * Return: none
980 */
981static void
982hdd_send_ft_assoc_response(struct net_device *dev,
Jeff Johnsonba388342017-10-02 13:31:01 -0700983 struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -0800984 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985{
986 union iwreq_data wrqu;
987 char *buff;
988 unsigned int len = 0;
989 u8 *pFTAssocRsp = NULL;
990
991 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700992 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 return;
994 }
995
996 pFTAssocRsp =
997 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
998 pCsrRoamInfo->nAssocReqLength);
999 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001000 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 return;
1002 }
1003 /* pFTAssocRsp needs to point to the IEs */
1004 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001005 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001006 (unsigned int)pFTAssocRsp[0],
1007 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008
1009 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001010 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001012 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 return;
1014 }
1015 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
1016 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1017 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 memcpy(buff, pFTAssocRsp, len);
1019 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
1020
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001021 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001022}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024/**
1025 * hdd_send_ft_event() - send fast transition event
Jeff Johnsonba388342017-10-02 13:31:01 -07001026 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 *
1028 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
1029 * FT events to the supplicant. At the reception of Auth2 we send the RIC
1030 * followed by the auth response IEs to the supplicant.
1031 * Once both are received in the supplicant, an FT event is generated
1032 * to the supplicant.
1033 *
1034 * Return: none
1035 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001036static void hdd_send_ft_event(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037{
1038 uint16_t auth_resp_len = 0;
1039 uint32_t ric_ies_length = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001040 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041
1042#if defined(KERNEL_SUPPORT_11R_CFG80211)
1043 struct cfg80211_ft_event_params ftEvent;
1044 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1045 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
Jeff Johnsonba388342017-10-02 13:31:01 -07001046 struct net_device *dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047#else
1048 char *buff;
1049 union iwreq_data wrqu;
1050 uint16_t str_len;
1051#endif
1052
1053#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301054 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1055 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056
Jeff Johnson1b780e42017-10-31 14:11:45 -07001057 sme_get_rici_es(hdd_ctx->hHal, adapter->session_id, (u8 *) ricIe,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001059 if (ric_ies_length == 0)
1060 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061
1062 ftEvent.ric_ies = ricIe;
1063 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001064 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065
Jeff Johnson1b780e42017-10-31 14:11:45 -07001066 sme_get_ft_pre_auth_response(hdd_ctx->hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1068 &auth_resp_len);
1069
1070 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001071 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 return;
1073 }
1074
Jeff Johnson1b780e42017-10-31 14:11:45 -07001075 sme_set_ft_pre_auth_state(hdd_ctx->hHal, adapter->session_id, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076
1077 ftEvent.target_ap = ftIe;
1078
Anurag Chouhan6d760662016-02-20 16:05:43 +05301079 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1080 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001082 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1083 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1084 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 ftEvent.target_ap[0], ftEvent.target_ap[1],
1086 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1087 ftEvent.target_ap[5]);
1088
1089 (void)cfg80211_ft_event(dev, &ftEvent);
1090
1091#else
1092 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001093 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001095 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 return;
1097 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001098
1099 /* Sme needs to send the RIC IEs first */
1100 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Jeff Johnson1b780e42017-10-31 14:11:45 -07001101 sme_get_rici_es(hdd_ctx->hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1103 &ric_ies_length);
1104 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001105 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 } else {
1107 wrqu.data.length = str_len + ric_ies_length;
Jeff Johnsonba388342017-10-02 13:31:01 -07001108 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 }
1110
1111 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301112 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Jeff Johnson1b780e42017-10-31 14:11:45 -07001114 sme_get_ft_pre_auth_response(hdd_ctx->hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115 (u8 *) &buff[str_len],
1116 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1117
1118 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001119 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001120 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 return;
1122 }
1123
1124 wrqu.data.length = str_len + auth_resp_len;
Jeff Johnsonba388342017-10-02 13:31:01 -07001125 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001127 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128#endif
1129}
1130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131#ifdef FEATURE_WLAN_ESE
1132/**
1133 * hdd_send_new_ap_channel_info() - send new ap channel info
1134 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07001135 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 * @pCsrRoamInfo: pointer to roam info
1137 *
1138 * Send the ESE required "new AP Channel info" to the supplicant.
1139 * (This keeps the supplicant "up to date" on the current channel.)
1140 *
1141 * The current (new AP) channel information is passed in.
1142 *
1143 * Return: none
1144 */
1145static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07001146hdd_send_new_ap_channel_info(struct net_device *dev,
1147 struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001148 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149{
1150 union iwreq_data wrqu;
Jeff Johnson4ba73cb2017-10-06 11:12:33 -07001151 struct bss_description *descriptor = pCsrRoamInfo->pBssDesc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152
1153 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001154 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 return;
1156 }
1157 /*
1158 * Send the Channel event, the supplicant needs this to generate
1159 * the Adjacent AP report.
1160 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001161 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001162 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 memset(&wrqu, '\0', sizeof(wrqu));
1164 wrqu.freq.m = descriptor->channelId;
1165 wrqu.freq.e = 0;
1166 wrqu.freq.i = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001167 wireless_send_event(adapter->dev, SIOCGIWFREQ, &wrqu, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001168}
1169
1170#endif /* FEATURE_WLAN_ESE */
1171
1172/**
1173 * hdd_send_update_beacon_ies_event() - send update beacons ie event
Jeff Johnsonba388342017-10-02 13:31:01 -07001174 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 * @pCsrRoamInfo: pointer to roam info
1176 *
1177 * Return: none
1178 */
1179static void
Jeff Johnsonba388342017-10-02 13:31:01 -07001180hdd_send_update_beacon_ies_event(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001181 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182{
1183 union iwreq_data wrqu;
Jeff Johnson04e00082017-10-04 12:15:58 -07001184 u8 *beacon_ies;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001185 u8 currentLen = 0;
1186 char *buff;
1187 int totalIeLen = 0, currentOffset = 0, strLen;
1188
1189 memset(&wrqu, '\0', sizeof(wrqu));
1190
1191 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001192 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001193 return;
1194 }
Jeff Johnson04e00082017-10-04 12:15:58 -07001195 beacon_ies = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1196 if (beacon_ies == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001197 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 return;
1199 }
Jeff Johnson04e00082017-10-04 12:15:58 -07001200 /* beacon_ies needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001201 hdd_debug("Beacon IEs is now at %02x%02x",
Jeff Johnson04e00082017-10-04 12:15:58 -07001202 (unsigned int)beacon_ies[0],
1203 (unsigned int)beacon_ies[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001204 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001205 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206
1207 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001208 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001210 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211 return;
1212 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213
1214 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1215 currentLen = strLen + 1;
1216
1217 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1218 do {
1219 /*
1220 * If the beacon size exceeds max CUSTOM event size, break it
1221 * into chunks of CUSTOM event max size and send it to
1222 * supplicant. Changes are done in supplicant to handle this.
1223 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301224 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301226 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Jeff Johnson04e00082017-10-04 12:15:58 -07001227 qdf_mem_copy(&buff[strLen + 1], beacon_ies + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228 currentLen);
1229 currentOffset += currentLen;
1230 totalIeLen -= currentLen;
1231 wrqu.data.length = strLen + 1 + currentLen;
1232 if (totalIeLen)
1233 buff[strLen] = 1; /* more chunks pending */
1234 else
1235 buff[strLen] = 0; /* last chunk */
1236
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001237 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001238 currentLen);
Jeff Johnsonba388342017-10-02 13:31:01 -07001239 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 } while (totalIeLen > 0);
1241
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001242 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243}
1244
1245/**
1246 * hdd_send_association_event() - send association event
1247 * @dev: pointer to net device
1248 * @pCsrRoamInfo: pointer to roam info
1249 *
1250 * Return: none
1251 */
1252static void hdd_send_association_event(struct net_device *dev,
Jeff Johnson172237b2017-11-07 15:32:59 -08001253 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254{
Rajeev Kumar78427682017-01-13 16:13:11 -08001255 int ret;
Jeff Johnsonba388342017-10-02 13:31:01 -07001256 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1257 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001258 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 union iwreq_data wrqu;
1260 int we_event;
1261 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301262 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 /* Added to find the auth type on the fly at run time */
1265 /* rather than with cfg to see if FT is enabled */
Jeff Johnson2a722002017-09-30 20:02:35 -07001266 struct hdd_wext_state *pWextState =
Jeff Johnsonba388342017-10-02 13:31:01 -07001267 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001268 tCsrRoamProfile *roam_profile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269
1270 memset(&wrqu, '\0', sizeof(wrqu));
1271 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1272 we_event = SIOCGIWAP;
1273#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1274 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301275 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001277 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301278 /* Update tdls module about the disconnection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001279 hdd_notify_sta_disconnect(adapter->session_id,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001280 true, false,
1281 adapter->hdd_vdev);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301282 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283#endif
Jeff Johnsond377dce2017-10-04 10:32:42 -07001284 if (eConnectionState_Associated == sta_ctx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001285 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301286
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001288 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 return;
1290 }
1291
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001292 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Jeff Johnson8095a312017-09-03 09:13:24 -07001293 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001294 adapter->device_mode, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1296 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1297
Wu Gaoc02785d2017-09-07 18:17:13 +08001298 ucfg_p2p_status_connect(adapter->hdd_vdev);
1299
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1301 MAC_ADDRESS_STR "\n",
Jeff Johnson1e851a12017-10-28 14:36:12 -07001302 MAC_ADDR_ARRAY(adapter->mac_addr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnsonba388342017-10-02 13:31:01 -07001304 hdd_send_update_beacon_ies_event(adapter, pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305
1306 /*
1307 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1308 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001309 * fFTEnable is true.
1310 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001312 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001313 eCSR_AUTH_TYPE_FT_RSN_PSK)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001314 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 eCSR_AUTH_TYPE_FT_RSN)
1316#ifdef FEATURE_WLAN_ESE
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001317 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 eCSR_AUTH_TYPE_CCKM_RSN)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001319 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 eCSR_AUTH_TYPE_CCKM_WPA)
1321#endif
1322 ) {
Jeff Johnsonba388342017-10-02 13:31:01 -07001323 hdd_send_ft_assoc_response(dev, adapter, pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301325 qdf_copy_macaddr(&peerMacAddr,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001326 &sta_ctx->conn_info.bssId);
Abhishek Singh1c676222016-05-09 14:20:28 +05301327 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1328 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1329 chan_info.info = pCsrRoamInfo->chan_info.info;
1330 chan_info.band_center_freq1 =
1331 pCsrRoamInfo->chan_info.band_center_freq1;
1332 chan_info.band_center_freq2 =
1333 pCsrRoamInfo->chan_info.band_center_freq2;
1334 chan_info.reg_info_1 =
1335 pCsrRoamInfo->chan_info.reg_info_1;
1336 chan_info.reg_info_2 =
1337 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301338
Jeff Johnsonba388342017-10-02 13:31:01 -07001339 ret = hdd_objmgr_add_peer_object(adapter->hdd_vdev,
1340 adapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301341 peerMacAddr.bytes,
1342 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001343 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301344 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1345 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Jeff Johnsonba388342017-10-02 13:31:01 -07001346 ret = hdd_objmgr_set_peer_mlme_state(adapter->hdd_vdev,
Dustin Brown7d043f62017-03-27 12:07:36 -07001347 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301348 if (ret)
1349 hdd_err("Peer object %pM fail to set associated state",
1350 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301351
Abhishek Singh1c676222016-05-09 14:20:28 +05301352 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001353 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1354 ePeerConnected,
1355 pCsrRoamInfo->timingMeasCap,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001356 adapter->session_id, &chan_info,
Jeff Johnsonba388342017-10-02 13:31:01 -07001357 adapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001358 /* Update tdls module about connection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001359 hdd_notify_sta_connect(adapter->session_id,
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001360 pCsrRoamInfo->tdls_chan_swit_prohibited,
1361 pCsrRoamInfo->tdls_prohibited,
Jeff Johnsonba388342017-10-02 13:31:01 -07001362 adapter->hdd_vdev);
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364#ifdef MSM_PLATFORM
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 /* start timer in sta/p2p_cli */
Jeff Johnson8095a312017-09-03 09:13:24 -07001366 spin_lock_bh(&hdd_ctx->bus_bw_lock);
Jeff Johnsonba388342017-10-02 13:31:01 -07001367 adapter->prev_tx_packets = adapter->stats.tx_packets;
1368 adapter->prev_rx_packets = adapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001369 cdp_get_intra_bss_fwd_pkts_count(
Jeff Johnson1b780e42017-10-31 14:11:45 -07001370 cds_get_context(QDF_MODULE_ID_SOC), adapter->session_id,
Jeff Johnsonba388342017-10-02 13:31:01 -07001371 &adapter->prev_fwd_tx_packets,
1372 &adapter->prev_fwd_rx_packets);
Jeff Johnson8095a312017-09-03 09:13:24 -07001373 spin_unlock_bh(&hdd_ctx->bus_bw_lock);
1374 hdd_bus_bw_compute_timer_start(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 } else if (eConnectionState_IbssConnected == /* IBss Associated */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001377 sta_ctx->conn_info.connState) {
Jeff Johnson8095a312017-09-03 09:13:24 -07001378 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001379 adapter->session_id);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001380 memcpy(wrqu.ap_addr.sa_data, sta_ctx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001381 ETH_ALEN);
Abhishek Singh44725482017-11-02 16:53:23 +05301382 hdd_debug("wlan: new IBSS peer connection to BSSID " MAC_ADDRESS_STR,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001383 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 } else { /* Not Associated */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301385 hdd_debug("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Jeff Johnson8095a312017-09-03 09:13:24 -07001387 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001388 adapter->device_mode, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389
1390#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001391 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392#endif
1393
Jeff Johnsonba388342017-10-02 13:31:01 -07001394 if ((adapter->device_mode == QDF_STA_MODE) ||
1395 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301396 qdf_copy_macaddr(&peerMacAddr,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001397 &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398
1399 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001400 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301401 ePeerDisconnected, 0,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001402 adapter->session_id,
Abhishek Singh1c676222016-05-09 14:20:28 +05301403 NULL,
Jeff Johnsonba388342017-10-02 13:31:01 -07001404 adapter->device_mode);
Abhishek Singh44725482017-11-02 16:53:23 +05301405 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev,
1406 peerMacAddr.bytes);
1407 if (ret)
1408 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301409 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Abhishek Singh44725482017-11-02 16:53:23 +05301410 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301411
Jeff Johnsonba388342017-10-02 13:31:01 -07001412 hdd_lpass_notify_disconnect(adapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001413 /* Update tdls module about the disconnection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001414 hdd_notify_sta_disconnect(adapter->session_id,
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001415 false,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001416 false,
Jeff Johnsonba388342017-10-02 13:31:01 -07001417 adapter->hdd_vdev);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001418
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419#ifdef MSM_PLATFORM
1420 /* stop timer in sta/p2p_cli */
Jeff Johnson8095a312017-09-03 09:13:24 -07001421 spin_lock_bh(&hdd_ctx->bus_bw_lock);
Jeff Johnsonba388342017-10-02 13:31:01 -07001422 adapter->prev_tx_packets = 0;
1423 adapter->prev_rx_packets = 0;
1424 adapter->prev_fwd_tx_packets = 0;
1425 adapter->prev_fwd_rx_packets = 0;
Jeff Johnson8095a312017-09-03 09:13:24 -07001426 spin_unlock_bh(&hdd_ctx->bus_bw_lock);
1427 hdd_bus_bw_compute_timer_try_stop(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428#endif
1429 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001430 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 /* Send SCC/MCC Switching event to IPA */
Jeff Johnson8095a312017-09-03 09:13:24 -07001432 hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433
1434 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001435 /* During the WLAN uninitialization,supplicant is stopped before the
1436 * driver so not sending the status of the connection to supplicant
1437 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001438 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 wireless_send_event(dev, we_event, &wrqu, msg);
1440#ifdef FEATURE_WLAN_ESE
1441 if (eConnectionState_Associated ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001442 sta_ctx->conn_info.connState) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001443 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 eCSR_AUTH_TYPE_CCKM_RSN) ||
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001445 (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 eCSR_AUTH_TYPE_CCKM_WPA))
Jeff Johnsonba388342017-10-02 13:31:01 -07001447 hdd_send_new_ap_channel_info(dev, adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 pCsrRoamInfo);
1449 }
1450#endif
1451 }
1452}
1453
1454/**
1455 * hdd_conn_remove_connect_info() - remove connection info
Jeff Johnsond377dce2017-10-04 10:32:42 -07001456 * @sta_ctx: pointer to global HDD station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 * @pCsrRoamInfo: pointer to roam info
1458 *
1459 * Return: none
1460 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001461static void hdd_conn_remove_connect_info(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462{
1463 /* Remove staId, bssId and peerMacAddress */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001464 sta_ctx->conn_info.staId[0] = HDD_WLAN_INVALID_STA_ID;
1465 qdf_mem_zero(&sta_ctx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1466 qdf_mem_zero(&sta_ctx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301467 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468
1469 /* Clear all security settings */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001470 sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1471 sta_ctx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1472 sta_ctx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473
Jeff Johnsond377dce2017-10-04 10:32:42 -07001474 qdf_mem_zero(&sta_ctx->conn_info.Keys, sizeof(tCsrKeys));
1475 qdf_mem_zero(&sta_ctx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476
Jeff Johnsond377dce2017-10-04 10:32:42 -07001477 sta_ctx->conn_info.proxyARPService = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478
Jeff Johnsond377dce2017-10-04 10:32:42 -07001479 qdf_mem_zero(&sta_ctx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480}
1481
1482/**
1483 * hdd_roam_deregister_sta() - deregister station
Jeff Johnsonba388342017-10-02 13:31:01 -07001484 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 * @staId: station identifier
1486 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301487 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07001489QDF_STATUS hdd_roam_deregister_sta(struct hdd_adapter *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301491 QDF_STATUS qdf_status;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001492 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301493 int ret = 0;
Abhishek Singh44725482017-11-02 16:53:23 +05301494 struct qdf_mac_addr *peer_mac = NULL;
Dustin Brownce5b3d32018-01-17 15:07:38 -08001495 struct qdf_mac_addr broadcastMacAddr = QDF_MAC_ADDR_BCAST_INIT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 if (eConnectionState_IbssDisconnected ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001497 sta_ctx->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 /*
1499 * Do not set the carrier off when the last peer leaves.
1500 * We will set the carrier off while stopping the IBSS.
1501 */
1502 }
1503
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001504 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001505 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301506 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301507 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301508 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1509 staid, qdf_status, qdf_status);
1510 }
1511
1512 if (adapter->device_mode == QDF_STA_MODE) {
Abhishek Singh44725482017-11-02 16:53:23 +05301513 peer_mac = &sta_ctx->conn_info.bssId;
Naveen Rawat95eb4062017-11-02 16:46:41 -07001514 } else if (adapter->device_mode == QDF_IBSS_MODE ||
1515 adapter->device_mode == QDF_NDI_MODE) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07001516 if (sta_ctx->broadcast_staid == staid)
Abhishek Singh44725482017-11-02 16:53:23 +05301517 peer_mac = &broadcastMacAddr;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301518 else
Abhishek Singh44725482017-11-02 16:53:23 +05301519 peer_mac =
1520 hdd_wlan_get_ibss_mac_addr_from_staid(adapter, staid);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301521 }
Naveen Rawat95eb4062017-11-02 16:46:41 -07001522
Abhishek Singh44725482017-11-02 16:53:23 +05301523 if (!peer_mac) {
1524 hdd_err("Coudnt find peer MAC for staid %d, delete fails",
1525 staid);
1526 return QDF_STATUS_E_FAILURE;
1527 }
Naveen Rawat95eb4062017-11-02 16:46:41 -07001528
1529 hdd_debug("peer_mac_addr: "MAC_ADDRESS_STR,
1530 MAC_ADDR_ARRAY(peer_mac->bytes));
Abhishek Singh44725482017-11-02 16:53:23 +05301531 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac->bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301532 if (ret) {
1533 hdd_err("Peer obj %pM delete fails", peer_mac);
1534 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301536 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537}
1538
1539/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301540 * hdd_print_bss_info() - print bss info
1541 * @hdd_sta_ctx: pointer to hdd station context
1542 *
1543 * Return: None
1544 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001545static void hdd_print_bss_info(struct hdd_station_ctx *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301546{
1547 uint32_t *cap_info;
1548
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301549 hdd_debug("WIFI DATA LOGGER");
1550 hdd_debug("channel: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301551 hdd_sta_ctx->conn_info.freq);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301552 hdd_debug("dot11mode: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301553 hdd_sta_ctx->conn_info.dot11Mode);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301554 hdd_debug("AKM: %d",
1555 hdd_sta_ctx->conn_info.last_auth_type);
1556 hdd_debug("ssid: %.*s",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001557 hdd_sta_ctx->conn_info.last_ssid.SSID.length,
1558 hdd_sta_ctx->conn_info.last_ssid.SSID.ssId);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301559 hdd_debug("roam count: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301560 hdd_sta_ctx->conn_info.roam_count);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301561 hdd_debug("ant_info: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301562 hdd_sta_ctx->conn_info.txrate.nss);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301563 hdd_debug("datarate legacy %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301564 hdd_sta_ctx->conn_info.txrate.legacy);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301565 hdd_debug("datarate mcs: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301566 hdd_sta_ctx->conn_info.txrate.mcs);
1567 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1568 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301569 hdd_debug("ht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301570 }
1571 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1572 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301573 hdd_debug("vht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301574 }
1575 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301576 hdd_debug("hs20 info: %x",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301577 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301578 hdd_debug("signal: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301579 hdd_sta_ctx->conn_info.signal);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301580 hdd_debug("noise: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301581 hdd_sta_ctx->conn_info.noise);
1582}
1583
1584/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 * hdd_dis_connect_handler() - disconnect event handler
Jeff Johnsonba388342017-10-02 13:31:01 -07001586 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07001587 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 * @roamId: roam identifier
1589 * @roamStatus: roam status
1590 * @roamResult: roam result
1591 *
1592 * This function handles disconnect event:
1593 * 1. Disable transmit queues;
1594 * 2. Clean up internal connection states and data structures;
1595 * 3. Send disconnect indication to supplicant.
1596 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301597 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001599static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001600 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 uint32_t roamId,
1602 eRoamCmdStatus roamStatus,
1603 eCsrRoamResult roamResult)
1604{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301605 QDF_STATUS status = QDF_STATUS_SUCCESS;
1606 QDF_STATUS vstatus;
Jeff Johnsonba388342017-10-02 13:31:01 -07001607 struct net_device *dev = adapter->dev;
1608 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001609 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 uint8_t sta_id;
1611 bool sendDisconInd = true;
1612
1613 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001614 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301615 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 }
1617 /* notify apps that we can't pass traffic anymore */
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001618 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07001619 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301620 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1621 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622
Jeff Johnson8095a312017-09-03 09:13:24 -07001623 if (hdd_ipa_is_enabled(hdd_ctx))
Jeff Johnsond377dce2017-10-04 10:32:42 -07001624 hdd_ipa_wlan_evt(adapter, sta_ctx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001625 HDD_IPA_STA_DISCONNECT,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001626 sta_ctx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627
1628#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001629 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630#endif
1631
Nirav Shah1da77682016-05-03 20:16:39 +05301632 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001633 adapter->session_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001634 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301635 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636
1637 /* HDD has initiated disconnect, do not send disconnect indication
1638 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301639 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 * to cfg80211_disconnected.
1641 */
1642 if ((eConnectionState_Disconnecting ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001643 sta_ctx->conn_info.connState) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 (eConnectionState_NotConnected ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001645 sta_ctx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001646 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 sendDisconInd = false;
1648 }
1649
Jeff Johnsond377dce2017-10-04 10:32:42 -07001650 if (sta_ctx->conn_info.connState != eConnectionState_Disconnecting) {
Jeff Johnsonba388342017-10-02 13:31:01 -07001651 INIT_COMPLETION(adapter->disconnect_comp_var);
1652 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 eConnectionState_Disconnecting);
1654 }
1655
Jeff Johnsonba388342017-10-02 13:31:01 -07001656 hdd_clear_roam_profile_ie(adapter);
1657 hdd_wmm_init(adapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001658 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301659 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660
1661 /* indicate 'disconnect' status to wpa_supplicant... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07001662 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 /* indicate disconnected event to nl80211 */
1664 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1665 /*
1666 * Only send indication to kernel if not initiated
1667 * by kernel
1668 */
1669 if (sendDisconInd) {
1670 /*
1671 * To avoid wpa_supplicant sending "HANGED" CMD
1672 * to ICS UI.
1673 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001674 if (eCSR_ROAM_LOSTLINK == roamStatus) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07001675 if (roam_info->reasonCode ==
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001676 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
Jeff Johnson435e1b82017-10-07 14:13:10 -07001677 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n",
1678 roam_info->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301679 wlan_hdd_cfg80211_indicate_disconnect(
1680 dev, false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001681 roam_info->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001682 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301683 wlan_hdd_cfg80211_indicate_disconnect(
1684 dev, false,
1685 WLAN_REASON_UNSPECIFIED
1686 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001687 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301689 hdd_debug("sent disconnected event to nl80211, reason code %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301690 (eCSR_ROAM_LOSTLINK == roamStatus) ?
Jeff Johnsonfd060852017-10-04 10:50:51 -07001691 roam_info->reasonCode :
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301692 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694
Wu Gaoc02785d2017-09-07 18:17:13 +08001695 /* update P2P connection status */
1696 ucfg_p2p_status_disconnect(adapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 }
1698
Jeff Johnsonba388342017-10-02 13:31:01 -07001699 hdd_wmm_adapter_clear(adapter);
Jeff Johnson1b780e42017-10-31 14:11:45 -07001700 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(adapter), adapter->session_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001701 if (hdd_remove_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001702 hdd_err("hdd_remove_beacon_filter() failed");
1703
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301705 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001706
Jeff Johnsond377dce2017-10-04 10:32:42 -07001707 sta_id = sta_ctx->broadcast_staid;
Jeff Johnsonba388342017-10-02 13:31:01 -07001708 vstatus = hdd_roam_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301709 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001710 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301711 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301712 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001714 if (sta_id < HDD_MAX_ADAPTERS)
1715 hdd_ctx->sta_to_adapter[sta_id] = NULL;
1716 else
1717 hdd_debug("invalid sta id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301718 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001719 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001720 if (HDD_WLAN_INVALID_STA_ID ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001721 sta_ctx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301722 continue;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001723 sta_id = sta_ctx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001724 hdd_debug("Deregister StaID %d", sta_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001725 vstatus = hdd_roam_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301726 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001727 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301728 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301729 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301730 }
1731 /* set the staid and peer mac as 0, all other
1732 * reset are done in hdd_connRemoveConnectInfo.
1733 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001734 sta_ctx->conn_info.staId[i] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301735 HDD_WLAN_INVALID_STA_ID;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001736 qdf_mem_zero(&sta_ctx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301737 sizeof(struct qdf_mac_addr));
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001738 if (sta_id < HDD_MAX_ADAPTERS)
Jeff Johnson8095a312017-09-03 09:13:24 -07001739 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001740 else
1741 hdd_debug("invalid sta_id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301742 }
1743 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07001744 sta_id = sta_ctx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001745 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301746
1747 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001748 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1749 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301750 eCSR_ROAM_LOSTLINK == roamStatus) {
Jeff Johnsonba388342017-10-02 13:31:01 -07001751 wlan_hdd_cfg80211_update_bss_list(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001752 sta_ctx->conn_info.bssId.bytes);
Jeff Johnson8095a312017-09-03 09:13:24 -07001753 sme_remove_bssid_from_scan_list(hdd_ctx->hHal,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001754 sta_ctx->conn_info.bssId.bytes);
Abhishek Singhc9941602016-08-09 16:06:22 +05301755 }
Rajeev Kumar4bc998f2017-10-19 14:41:43 -07001756 if (sta_id < HDD_MAX_ADAPTERS)
1757 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001758 else
1759 hdd_debug("invalid sta_id %d", sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761 /* Clear saved connection information in HDD */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001762 hdd_conn_remove_connect_info(sta_ctx);
Jeff Johnsonba388342017-10-02 13:31:01 -07001763 hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected);
1764 pmo_ucfg_flush_gtk_offload_req(adapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765
Jeff Johnsonba388342017-10-02 13:31:01 -07001766 if ((QDF_STA_MODE == adapter->device_mode) ||
1767 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07001769 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07001770 adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 }
Jeff Johnsonba388342017-10-02 13:31:01 -07001772 wlan_hdd_clear_link_layer_stats(adapter);
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301773
Jeff Johnson6ced42c2017-10-20 12:48:11 -07001774 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301775
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 /* Unblock anyone waiting for disconnect to complete */
Jeff Johnsonba388342017-10-02 13:31:01 -07001777 complete(&adapter->disconnect_comp_var);
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +05301778
1779 hdd_reset_limit_off_chan(adapter);
1780
Jeff Johnsond377dce2017-10-04 10:32:42 -07001781 hdd_print_bss_info(sta_ctx);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05301782
1783 if (policy_mgr_is_sta_active_connection_exists(hdd_ctx->hdd_psoc))
1784 sme_enable_roaming_on_connected_sta(hdd_ctx->hHal);
1785
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 return status;
1787}
1788
1789/**
1790 * hdd_set_peer_authorized_event() - set peer_authorized_event
1791 * @vdev_id: vdevid
1792 *
1793 * Return: None
1794 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001795static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796{
Jeff Johnson49432062017-08-28 12:08:45 -07001797 struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Jeff Johnsonb1704c82017-08-29 14:40:57 -07001798 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799
1800 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1801 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001802 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001803 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 }
1805 complete(&adapter->sta_authorized_event);
1806}
1807
1808/**
1809 * hdd_change_peer_state() - change peer state
Jeff Johnsonba388342017-10-02 13:31:01 -07001810 * @adapter: HDD adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 * @sta_state: peer state
1812 * @roam_synch_in_progress: roam synch in progress
1813 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301814 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001816QDF_STATUS hdd_change_peer_state(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 uint8_t sta_id,
1818 enum ol_txrx_peer_state sta_state,
1819 bool roam_synch_in_progress)
1820{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301821 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001822 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001823 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1824 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1825 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826
1827 if (!pdev) {
1828 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301829 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 }
1831
1832 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001833 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301834 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 }
1836
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001837 peer = cdp_peer_find_by_local_id(soc,
1838 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301840 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841
Leo Changfdb45c32016-10-28 11:09:23 -07001842 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001843 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001844 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001845 return QDF_STATUS_E_FAULT;
1846 }
1847
Leo Changfdb45c32016-10-28 11:09:23 -07001848 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301849 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001850 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301851 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 }
1853#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1854 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301855 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856#endif
1857
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001858 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1860 /* make sure event is reset */
Jeff Johnsonba388342017-10-02 13:31:01 -07001861 INIT_COMPLETION(adapter->sta_authorized_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862#endif
1863
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001864 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 hdd_set_peer_authorized_event,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001866 adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301867 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001868 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301869 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 }
1871
Jeff Johnsonba388342017-10-02 13:31:01 -07001872 if (adapter->device_mode == QDF_STA_MODE ||
1873 adapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001875 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 unsigned long rc;
1877
1878 /* wait for event from firmware to set the event */
1879 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07001880 &adapter->sta_authorized_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001882 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001883 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001884
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001885 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1886 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001887 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888#endif
1889 }
1890 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301891 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892}
1893
1894/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001895 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1896 * @cbk_data: callback data
1897 * @sta_id: station id
1898 * @vdev_param: vdev parameter
1899 * @is_link_up: link state up or down
1900 *
1901 * Return: QDF status
1902 */
1903QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1904 uint8_t sta_id,
1905 uint32_t vdev_param,
1906 bool is_link_up)
1907{
1908 struct cdp_vdev *data_vdev;
1909 QDF_STATUS status = QDF_STATUS_SUCCESS;
1910 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Jeff Johnson49432062017-08-28 12:08:45 -07001911 struct hdd_context *hdd_ctx;
Yun Park0dad1002017-07-14 14:57:01 -07001912 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Kabilan Kannan256e3182017-05-02 16:02:37 -07001913 struct wlan_objmgr_psoc **psoc;
1914
1915 if (!cbk_data)
1916 return status;
1917
1918 psoc = cbk_data;
Kabilan Kannan256e3182017-05-02 16:02:37 -07001919
Kabilan Kannanc0e3d582017-09-13 00:26:33 -07001920 hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Sourav Mohapatra5febc932018-01-08 14:38:30 +05301921 if (!hdd_ctx) {
1922 hdd_err("Invalid HDD Context");
1923 return QDF_STATUS_E_INVAL;
1924 }
1925
Kabilan Kannan256e3182017-05-02 16:02:37 -07001926 if (!hdd_ctx->tdls_nap_active)
1927 return status;
1928
Yun Park0dad1002017-07-14 14:57:01 -07001929 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, pdev, sta_id);
Kabilan Kannan256e3182017-05-02 16:02:37 -07001930 if (NULL == data_vdev) {
1931 status = QDF_STATUS_E_FAILURE;
1932 return status;
1933 }
1934
1935 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1936
1937 return status;
1938}
1939
1940/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 * hdd_roam_register_sta() - register station
Jeff Johnsonba388342017-10-02 13:31:01 -07001942 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07001943 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 * @staId: station identifier
1945 * @pPeerMacAddress: peer MAC address
1946 * @pBssDesc: pointer to BSS description
1947 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301948 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001950QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001951 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301953 struct qdf_mac_addr *pPeerMacAddress,
Jeff Johnson4ba73cb2017-10-06 11:12:33 -07001954 struct bss_description *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301956 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsond377dce2017-10-04 10:32:42 -07001958 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001959 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001960 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1961 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962
1963 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301964 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965
1966 /* Get the Station ID from the one saved during the association */
1967 staDesc.sta_id = staId;
1968
1969 /* set the QoS field appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07001970 if (hdd_wmm_is_active(adapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 staDesc.is_qos_enabled = 1;
1972 else
1973 staDesc.is_qos_enabled = 0;
1974
1975#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07001976 hdd_debug("WAPI STA Registered: %d",
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07001977 adapter->wapi_info.is_wapi_sta);
1978 if (adapter->wapi_info.is_wapi_sta)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 staDesc.is_wapi_supported = 1;
1980 else
1981 staDesc.is_wapi_supported = 0;
1982#endif /* FEATURE_WLAN_WAPI */
1983
Dhanashri Atre50141c52016-04-07 13:15:29 -07001984 /* Register the vdev transmit and receive functions */
1985 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1986 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001987
Jeff Johnsonba388342017-10-02 13:31:01 -07001988 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001989 (struct cdp_pdev *)pdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001990 adapter->session_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001991 if (!adapter->txrx_vdev) {
Leo Changfdb45c32016-10-28 11:09:23 -07001992 hdd_err("%s find vdev fail", __func__);
1993 return QDF_STATUS_E_FAILURE;
1994 }
1995
1996 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001997 cdp_vdev_register(soc,
Jeff Johnsonba388342017-10-02 13:31:01 -07001998 (struct cdp_vdev *)adapter->txrx_vdev, adapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001999 if (!txrx_ops.tx.tx) {
2000 hdd_err("%s vdev register fail", __func__);
2001 return QDF_STATUS_E_FAILURE;
2002 }
2003
Jeff Johnsonba388342017-10-02 13:31:01 -07002004 adapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002005 qdf_status = cdp_peer_register(soc,
2006 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302007 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002008 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002009 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302010 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 }
2012
Jeff Johnsonfd060852017-10-04 10:50:51 -07002013 if (!roam_info->fAuthRequired) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 /*
2015 * Connections that do not need Upper layer auth, transition
2016 * TLSHIM directly to 'Authenticated' state
2017 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302018 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002019 hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002020 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002022 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023#else
2024 false
2025#endif
2026 );
2027
Jeff Johnsonba388342017-10-02 13:31:01 -07002028 hdd_conn_set_authenticated(adapter, true);
2029 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002031 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002032 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302033 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002034 hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002035 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002037 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038#else
2039 false
2040#endif
2041 );
Jeff Johnsonba388342017-10-02 13:31:01 -07002042 hdd_conn_set_authenticated(adapter, false);
2043 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302045 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046}
2047
2048/**
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302049 * hdd_send_roamed_ind() - send roamed indication to cfg80211
2050 * @dev: network device
2051 * @bss: cfg80211 roamed bss pointer
2052 * @req_ie: IEs used in reassociation request
2053 * @req_ie_len: Length of the @req_ie
2054 * @resp_ie: IEs received in successful reassociation response
2055 * @resp_ie_len: Length of @resp_ie
2056 *
2057 * Return: none
2058 */
2059#if defined CFG80211_ROAMED_API_UNIFIED || \
2060 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
2061static void hdd_send_roamed_ind(struct net_device *dev,
2062 struct cfg80211_bss *bss, const uint8_t *req_ie,
2063 size_t req_ie_len, const uint8_t *resp_ie,
2064 size_t resp_ie_len)
2065{
2066 struct cfg80211_roam_info info = {0};
2067
2068 info.bss = bss;
2069 info.req_ie = req_ie;
2070 info.req_ie_len = req_ie_len;
2071 info.resp_ie = resp_ie;
2072 info.resp_ie_len = resp_ie_len;
2073 cfg80211_roamed(dev, &info, GFP_KERNEL);
2074}
2075#else
2076static inline void hdd_send_roamed_ind(struct net_device *dev,
2077 struct cfg80211_bss *bss,
2078 const uint8_t *req_ie, size_t req_ie_len,
2079 const uint8_t *resp_ie,
2080 size_t resp_ie_len)
2081{
2082 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
2083 GFP_KERNEL);
2084}
2085#endif
2086
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302087#if defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302088#if defined(WLAN_FEATURE_FILS_SK)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302089void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002090 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302091{
2092 uint8_t *kek;
2093 uint32_t kek_len;
2094
2095 if (is_reassoc) {
2096 kek = csr_roam_info->kek;
2097 kek_len = csr_roam_info->kek_len;
2098 } else {
2099 /*
2100 * This should come for FILS case only.
2101 * Caller should make sure fils_join_rsp is
2102 * not NULL, if there is need to use else where.
2103 */
2104 kek = csr_roam_info->fils_join_rsp->kek;
2105 kek_len = csr_roam_info->fils_join_rsp->kek_len;
2106 }
2107
2108 wlan_hdd_save_gtk_offload_params(adapter, NULL, kek, kek_len,
2109 csr_roam_info->replay_ctr, true);
2110
2111 hdd_debug("Kek len %d", kek_len);
2112}
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302113#else
2114void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002115 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302116{
2117 uint8_t *kek;
2118 uint32_t kek_len;
2119
2120 /*
2121 * is_reassoc is set to true always for Legacy GTK offload
2122 * case, It is false only for FILS case
2123 */
2124 kek = csr_roam_info->kek;
2125 kek_len = csr_roam_info->kek_len;
2126
2127 wlan_hdd_save_gtk_offload_params(adapter, NULL, kek, kek_len,
2128 csr_roam_info->replay_ctr, true);
2129
2130 hdd_debug("Kek len %d", kek_len);
2131}
2132#endif
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302133#endif
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302134/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 * hdd_send_re_assoc_event() - send reassoc event
2136 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07002137 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 * @pCsrRoamInfo: pointer to roam info
2139 * @reqRsnIe: pointer to RSN Information element
2140 * @reqRsnLength: length of RSN IE
2141 *
2142 * Return: none
2143 */
2144static void hdd_send_re_assoc_event(struct net_device *dev,
Jeff Johnson172237b2017-11-07 15:32:59 -08002145 struct hdd_adapter *adapter, struct csr_roam_info *pCsrRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2147{
2148 unsigned int len = 0;
2149 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002150 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2151 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 uint32_t rspRsnLength = 0;
2153 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2155 uint8_t *buf_ptr, ssid_ie_len;
2156 struct cfg80211_bss *bss = NULL;
2157 uint8_t *final_req_ie = NULL;
2158 tCsrRoamConnectedProfile roam_profile;
Jeff Johnsonba388342017-10-02 13:31:01 -07002159 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(adapter);
2160 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302161 int chan_no;
2162 int freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002164 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2165
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002167 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002168 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 }
2170
Naveen Rawat14298b92015-11-25 16:27:41 -08002171 if (!assoc_req_ies) {
2172 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002173 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002174 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002176 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 goto done;
2178 }
2179
2180 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002181 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002182 goto done;
2183 }
2184
2185 pFTAssocRsp =
2186 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2187 pCsrRoamInfo->nAssocReqLength);
2188 if (pFTAssocRsp == NULL)
2189 goto done;
2190
2191 /* pFTAssocRsp needs to point to the IEs */
2192 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002193 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002194 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195
2196 /*
2197 * Active session count is decremented upon disconnection, but during
2198 * roaming, there is no disconnect indication and hence active session
2199 * count is not decremented.
2200 * After roaming is completed, active session count is incremented
2201 * as a part of connect indication but effectively after roaming the
2202 * active session count should still be the same and hence upon
2203 * successful reassoc decrement the active session count here.
2204 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002205 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002206 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002207 adapter->device_mode, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208
2209 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2210 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2211 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302212 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2213 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302215 chan_no = pCsrRoamInfo->pBssDesc->channelId;
2216 if (chan_no <= 14)
2217 freq = ieee80211_channel_to_frequency(chan_no,
2218 NL80211_BAND_2GHZ);
2219 else
2220 freq = ieee80211_channel_to_frequency(chan_no,
2221 NL80211_BAND_5GHZ);
Jeff Johnsonba388342017-10-02 13:31:01 -07002222 chan = ieee80211_get_channel(adapter->wdev.wiphy, freq);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302223
Jeff Johnson1b780e42017-10-31 14:11:45 -07002224 sme_roam_get_connect_profile(hal_handle, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302226
Jeff Johnsonba388342017-10-02 13:31:01 -07002227 bss = hdd_cfg80211_get_bss(adapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302228 chan, pCsrRoamInfo->bssid.bytes,
2229 &roam_profile.SSID.ssId[0],
2230 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231
2232 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002233 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 buf_ptr = buf_ssid_ie;
2235 *buf_ptr = SIR_MAC_SSID_EID;
2236 buf_ptr++;
2237 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2238 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302239 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 roam_profile.SSID.length);
2241 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002242 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302243 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002244 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002245 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Kapil Gupta8731e812017-07-11 18:42:39 +05302246 if (final_req_ie == NULL) {
2247 if (bss)
Jeff Johnsonba388342017-10-02 13:31:01 -07002248 cfg80211_put_bss(adapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302250 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302252 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302254 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2255 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2256 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002258 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302259 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002260 final_req_ie, (ssid_ie_len + reqRsnLength));
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302261 hdd_send_roamed_ind(dev, bss, final_req_ie,
2262 (ssid_ie_len + reqRsnLength), rspRsnIe,
2263 rspRsnLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302265 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002266 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2267 pCsrRoamInfo->nAssocReqLength);
2268
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302269 hdd_save_gtk_params(adapter, pCsrRoamInfo, true);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302270
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002271 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302272 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002273 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2274
Jeff Johnsonba388342017-10-02 13:31:01 -07002275 wlan_hdd_send_roam_auth_event(adapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002276 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2277 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002278 pCsrRoamInfo);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302279
2280 hdd_update_hlp_info(dev, pCsrRoamInfo);
2281
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002283 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002285 qdf_mem_free(final_req_ie);
2286 qdf_mem_free(rspRsnIe);
2287 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288}
2289
2290/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302291 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002292 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302293 *
2294 * Return: roam sync status if roaming offloaded else false
2295 */
2296#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson172237b2017-11-07 15:32:59 -08002297bool hdd_is_roam_sync_in_progress(struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302298{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002299 if (roaminfo)
2300 return roaminfo->roamSynchInProgress;
2301 else
2302 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302303}
2304#endif
2305
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002306/**
2307 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2308 * @hddstactx: pointer to HDD sta context
2309 * @roaminfo: pointer to roaminfo structure
2310 *
2311 * This function returns staid for IBSS peer. If peer is broadcast
2312 * MAC address return self staid(0) else find the peer sta id of
2313 * the peer.
2314 *
2315 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2316 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002317static uint8_t hdd_get_ibss_peer_staid(struct hdd_station_ctx *hddstactx,
Jeff Johnson172237b2017-11-07 15:32:59 -08002318 struct csr_roam_info *roaminfo)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002319{
2320 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2321 QDF_STATUS status;
2322
2323 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2324 staid = 0;
2325 } else {
2326 status = hdd_get_peer_sta_id(hddstactx,
2327 &roaminfo->peerMac, &staid);
2328 if (status != QDF_STATUS_SUCCESS) {
2329 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2330 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2331 }
2332 }
2333
2334 return staid;
2335}
Govind Singhedc5cda2015-10-23 17:11:35 +05302336
2337/**
2338 * hdd_change_sta_state_authenticated()-
2339 * This function changes STA state to authenticated
2340 * @adapter: pointer to the adapter structure.
2341 * @roaminfo: pointer to the RoamInfo structure.
2342 *
2343 * This is called from hdd_RoamSetKeyCompleteHandler
2344 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2345 *
2346 * Return: 0 on success and errno on failure
2347 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002348static int hdd_change_sta_state_authenticated(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002349 struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302350{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002351 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002352 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002353 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Jeff Johnson435e1b82017-10-07 14:13:10 -07002354 struct hdd_station_ctx *hddstactx =
2355 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson49432062017-08-28 12:08:45 -07002356 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302357
Jeff Johnson690fe952017-10-25 11:48:39 -07002358 timeout = hddstactx->hdd_reassoc_scenario ?
Dustin Brownf660fb42016-09-09 12:04:00 -07002359 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002360 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002361
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002362 if (QDF_IBSS_MODE == adapter->device_mode)
2363 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2364 else
2365 staid = hddstactx->conn_info.staId[0];
2366
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002367 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302368
2369 /* Connections that do not need Upper layer authentication,
2370 * transition TL to 'Authenticated' state after the keys are set
2371 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002372 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302373 hdd_is_roam_sync_in_progress(roaminfo));
2374 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002375 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2376
Krunal Sonibe766b02016-03-10 13:00:44 -08002377 if ((QDF_STA_MODE == adapter->device_mode) ||
2378 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302379 sme_ps_enable_auto_ps_timer(
2380 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002381 adapter->session_id,
Dustin Brown84411b02017-07-21 16:44:44 -07002382 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302383 }
2384
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002385 return qdf_status_to_os_return(status);
2386}
2387
2388/**
2389 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2390 * if key installation is required
2391 * @encr_type: encryption type
2392 *
2393 * Return: true if key installation is required and false otherwise.
2394 */
2395static inline bool hdd_is_key_install_required_for_ibss(
2396 eCsrEncryptionType encr_type)
2397{
2398 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2399 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2400 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05302401 eCSR_ENCRYPT_TYPE_AES_GCMP == encr_type ||
2402 eCSR_ENCRYPT_TYPE_AES_GCMP_256 == encr_type ||
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002403 eCSR_ENCRYPT_TYPE_AES == encr_type)
2404 return true;
2405 else
2406 return false;
2407}
2408
2409/**
2410 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2411 * complete
2412 * @adapter: pointer to HDD adapter
2413 * @roaminfo: pointer to roam info
2414 * @roam_result: roam result
2415 *
2416 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2417 * This function checks for the successful set key completion and update
2418 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2419 *
2420 * Return: None
2421 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002422static void hdd_change_peer_state_after_set_key(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002423 struct csr_roam_info *roaminfo,
2424 eCsrRoamResult roam_result)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002425{
Jeff Johnson435e1b82017-10-07 14:13:10 -07002426 struct hdd_station_ctx *hdd_sta_ctx =
2427 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002428 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2429
2430 /*
2431 * If the security mode is one of the following, IBSS peer will be
2432 * waiting in CONN state and we will move the peer state to AUTH
2433 * here. For non-secure connection, no need to wait for set-key complete
2434 * peer will be moved to AUTH in hdd_roam_register_sta.
2435 */
2436 if (QDF_IBSS_MODE == adapter->device_mode) {
2437 if (hdd_is_key_install_required_for_ibss(encr_type))
2438 hdd_change_sta_state_authenticated(adapter, roaminfo);
2439
2440 return;
2441 }
2442
2443 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2444 hdd_sta_ctx->conn_info.gtk_installed = true;
2445 /*
2446 * PTK exchange happens in preauthentication itself if key_mgmt
2447 * is FT-PSK, ptk_installed was false as there is no set PTK
2448 * after roaming. STA TL state moves to authenticated only if
2449 * ptk_installed is true. So, make ptk_installed to true in
2450 * case of 11R roaming.
2451 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302452 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002453 adapter->session_id))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002454 hdd_sta_ctx->conn_info.ptk_installed = true;
2455 } else {
2456 hdd_sta_ctx->conn_info.ptk_installed = true;
2457 }
2458
2459 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2460 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2461 * unicast key and it was resulting in sending few un-encrypted packet.
2462 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2463 * set the unicast and broadcast key.
2464 */
2465 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2466 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2467 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2468 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2469 if (hdd_sta_ctx->conn_info.gtk_installed &&
2470 hdd_sta_ctx->conn_info.ptk_installed)
2471 hdd_change_sta_state_authenticated(adapter, roaminfo);
2472 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2473 hdd_change_sta_state_authenticated(adapter, roaminfo);
2474 }
2475
2476 if (hdd_sta_ctx->conn_info.gtk_installed &&
2477 hdd_sta_ctx->conn_info.ptk_installed) {
2478 hdd_sta_ctx->conn_info.gtk_installed = false;
2479 hdd_sta_ctx->conn_info.ptk_installed = false;
2480 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302481}
2482
2483/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 * hdd_roam_set_key_complete_handler() - Update the security parameters
Jeff Johnsonba388342017-10-02 13:31:01 -07002485 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002486 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 * @roamId: roam id
2488 * @roamStatus: roam status
2489 * @roamResult: roam result
2490 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302491 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 */
Jeff Johnson172237b2017-11-07 15:32:59 -08002493static QDF_STATUS
2494hdd_roam_set_key_complete_handler(struct hdd_adapter *adapter,
2495 struct csr_roam_info *roam_info,
2496 uint32_t roamId,
2497 eRoamCmdStatus roamStatus,
2498 eCsrRoamResult roamResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499{
2500 eCsrEncryptionType connectedCipherAlgo;
2501 bool fConnected = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002502 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302503
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504 ENTER();
2505
Jeff Johnsonfd060852017-10-04 10:50:51 -07002506 if (NULL == roam_info) {
2507 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302508 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 }
2510 /*
2511 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2512 * then go to 'authenticated'. For all other authentication types
2513 * (those that do not require upper layer authentication) we can put TL
2514 * directly into 'authenticated' state.
2515 */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05302516 hdd_debug("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 MAC_ADDRESS_STR, roamStatus, roamResult,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002518 MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519
Jeff Johnsond377dce2017-10-04 10:32:42 -07002520 fConnected = hdd_conn_get_connected_cipher_algo(sta_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 &connectedCipherAlgo);
2522 if (fConnected) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002523 hdd_change_peer_state_after_set_key(adapter, roam_info,
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002524 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 }
2526
2527 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302528 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529}
2530
2531/**
2532 * hdd_perform_roam_set_key_complete() - perform set key complete
Jeff Johnsonba388342017-10-02 13:31:01 -07002533 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 *
2535 * Return: none
2536 */
Jeff Johnsonba388342017-10-02 13:31:01 -07002537void hdd_perform_roam_set_key_complete(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302539 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002540 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson172237b2017-11-07 15:32:59 -08002541 struct csr_roam_info roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302544 qdf_mem_copy(roamInfo.bssid.bytes,
Jeff Johnsond377dce2017-10-04 10:32:42 -07002545 sta_ctx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302546 qdf_mem_copy(roamInfo.peerMac.bytes,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002547 sta_ctx->roam_info.peer_mac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302549 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002550 hdd_roam_set_key_complete_handler(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551 &roamInfo,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002552 sta_ctx->roam_info.roam_id,
2553 sta_ctx->roam_info.roam_status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302555 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002556 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002558 sta_ctx->roam_info.defer_key_complete = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559}
2560
Vignesh Viswanathan3fa1d382017-08-02 19:36:43 +05302561#if defined(WLAN_FEATURE_FILS_SK) && \
2562 (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \
2563 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)))
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002564void hdd_clear_fils_connection_info(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302565{
Jeff Johnson2a722002017-09-30 20:02:35 -07002566 struct hdd_wext_state *wext_state;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302567
2568 if ((adapter->device_mode == QDF_SAP_MODE) ||
2569 (adapter->device_mode == QDF_P2P_GO_MODE))
2570 return;
2571
2572 wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
2573 if (wext_state->roamProfile.fils_con_info) {
2574 qdf_mem_free(wext_state->roamProfile.fils_con_info);
2575 wext_state->roamProfile.fils_con_info = NULL;
2576 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302577
2578 if (wext_state->roamProfile.hlp_ie) {
2579 qdf_mem_free(wext_state->roamProfile.hlp_ie);
2580 wext_state->roamProfile.hlp_ie = NULL;
2581 wext_state->roamProfile.hlp_ie_len = 0;
2582 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302583}
2584#endif
2585
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002586/**
2587 * hdd_association_completion_handler() - association completion handler
Jeff Johnsonba388342017-10-02 13:31:01 -07002588 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002589 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590 * @roamId: roam id
2591 * @roamStatus: roam status
2592 * @roamResult: roam result
2593 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302594 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 */
Jeff Johnson435e1b82017-10-07 14:13:10 -07002596static QDF_STATUS
2597hdd_association_completion_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002598 struct csr_roam_info *roam_info,
Jeff Johnson435e1b82017-10-07 14:13:10 -07002599 uint32_t roamId,
2600 eRoamCmdStatus roamStatus,
2601 eCsrRoamResult roamResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602{
Jeff Johnsonba388342017-10-02 13:31:01 -07002603 struct net_device *dev = adapter->dev;
2604 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002605 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302606 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002608 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 bool hddDisconInProgress = false;
2611 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302612 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302613 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614
Jeff Johnson8095a312017-09-03 09:13:24 -07002615 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302617 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 }
2619
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302620 /* validate config */
Jeff Johnson8095a312017-09-03 09:13:24 -07002621 if (!hdd_ctx->config) {
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302622 hdd_err("config is NULL");
2623 return QDF_STATUS_E_NULL_VALUE;
2624 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 /* HDD has initiated disconnect, do not send connect result indication
2626 * to kernel as it will be handled by __cfg80211_disconnect.
2627 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302628 if (((eConnectionState_Disconnecting ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07002629 sta_ctx->conn_info.connState) ||
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302630 (eConnectionState_NotConnected ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07002631 sta_ctx->conn_info.connState)) &&
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302632 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2633 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002634 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002635 sta_ctx->conn_info.connState,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002636 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 hddDisconInProgress = true;
2638 }
2639
2640 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002641 if (NULL == roam_info) {
2642 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302643 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 }
2645 if (!hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07002646 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647 eConnectionState_Associated);
2648 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002651 hdd_conn_save_connect_info(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002653
Jeff Johnsonba388342017-10-02 13:31:01 -07002654 if (hdd_add_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002655 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656#ifdef FEATURE_WLAN_WAPI
Jeff Johnsonfd060852017-10-04 10:50:51 -07002657 if (roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
Jeff Johnsonfd060852017-10-04 10:50:51 -07002659 || roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002661 adapter->wapi_info.is_wapi_sta = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 } else {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002663 adapter->wapi_info.is_wapi_sta = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 }
2665#endif /* FEATURE_WLAN_WAPI */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002666 hdd_debug("bss_descr[%d] devicemode[%d]", !!roam_info->pBssDesc,
Jeff Johnsonba388342017-10-02 13:31:01 -07002667 adapter->device_mode);
2668 if ((QDF_STA_MODE == adapter->device_mode) &&
Jeff Johnsonfd060852017-10-04 10:50:51 -07002669 roam_info->pBssDesc) {
2670 ie_len = GET_IE_LEN_IN_BSS(roam_info->pBssDesc->length);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002671 sta_ctx->ap_supports_immediate_power_save =
Krunal Soni364e0872017-05-10 21:24:34 -07002672 wlan_hdd_is_ap_supports_immediate_power_save(
Jeff Johnsonfd060852017-10-04 10:50:51 -07002673 (uint8_t *) roam_info->pBssDesc->ieFields,
Krunal Soni364e0872017-05-10 21:24:34 -07002674 ie_len);
2675 hdd_debug("ap_supports_immediate_power_save flag [%d]",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002676 sta_ctx->ap_supports_immediate_power_save);
Krunal Soni364e0872017-05-10 21:24:34 -07002677 }
2678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 /* Indicate 'connect' status to user space */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002680 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681
Jeff Johnson8095a312017-09-03 09:13:24 -07002682 if (policy_mgr_is_mcc_in_24G(hdd_ctx->hdd_psoc)) {
2683 if (hdd_ctx->miracast_value)
Jeff Johnsonba388342017-10-02 13:31:01 -07002684 wlan_hdd_set_mas(adapter,
Jeff Johnson8095a312017-09-03 09:13:24 -07002685 hdd_ctx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 }
2687
2688 /* Initialize the Linkup event completion variable */
Jeff Johnsonba388342017-10-02 13:31:01 -07002689 INIT_COMPLETION(adapter->linkup_event_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690
2691 /*
2692 * Sometimes Switching ON the Carrier is taking time to activate
2693 * the device properly. Before allowing any packet to go up to
2694 * the application, device activation has to be ensured for
2695 * proper queue mapping by the kernel. we have registered net
2696 * device notifier for device change notification. With this we
2697 * will come to know that the device is getting
2698 * activated properly.
2699 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07002700 if (sta_ctx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002701 /*
2702 * Enable Linkup Event Servicing which allows the net
2703 * device notifier to set the linkup event variable.
2704 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002705 adapter->is_link_up_service_needed = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002707 /* Switch on the Carrier to activate the device */
Jeff Johnsonba388342017-10-02 13:31:01 -07002708 wlan_hdd_netif_queue_control(adapter,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002709 WLAN_NETIF_CARRIER_ON,
2710 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002712 /*
2713 * Wait for the Link to up to ensure all the queues
2714 * are set properly by the kernel.
2715 */
2716 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07002717 &adapter->linkup_event_var,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002718 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2719 );
2720 if (!rc)
2721 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002723 /*
2724 * Disable Linkup Event Servicing - no more service
2725 * required from the net device notifier call.
2726 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002727 adapter->is_link_up_service_needed = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002728 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07002729 sta_ctx->ft_carrier_on = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002730 ft_carrier_on = true;
2731 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07002732 if (roam_info->staId < HDD_MAX_ADAPTERS)
Jeff Johnsonfd060852017-10-04 10:50:51 -07002733 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 else
Jeff Johnsonfd060852017-10-04 10:50:51 -07002735 hdd_err("Wrong Staid: %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736
Jeff Johnson8095a312017-09-03 09:13:24 -07002737 if (hdd_ipa_is_enabled(hdd_ctx))
Jeff Johnsonfd060852017-10-04 10:50:51 -07002738 hdd_ipa_wlan_evt(adapter, roam_info->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002739 HDD_IPA_STA_CONNECT,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002740 roam_info->bssid.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741
2742#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07002743 wlan_hdd_auto_shutdown_enable(hdd_ctx, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744#endif
2745
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302746 hdd_debug("check if STA chan ok for DNBS");
Jeff Johnson8095a312017-09-03 09:13:24 -07002747 if (policy_mgr_is_chan_ok_for_dnbs(hdd_ctx->hdd_psoc,
Jeff Johnsond377dce2017-10-04 10:32:42 -07002748 sta_ctx->conn_info.operationChannel,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302749 &ok)) {
2750 hdd_err("Unable to check DNBS eligibility for chan:%d",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002751 sta_ctx->conn_info.operationChannel);
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302752 return QDF_STATUS_E_FAILURE;
2753 }
2754
2755 if (!ok) {
2756 hdd_err("Chan:%d not suitable for DNBS",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002757 sta_ctx->conn_info.operationChannel);
Jeff Johnsonba388342017-10-02 13:31:01 -07002758 wlan_hdd_netif_queue_control(adapter,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302759 WLAN_NETIF_CARRIER_OFF,
2760 WLAN_CONTROL_PATH);
2761 if (!hddDisconInProgress) {
2762 hdd_err("Disconnecting...");
2763 sme_roam_disconnect(
Jeff Johnsonba388342017-10-02 13:31:01 -07002764 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002765 adapter->session_id,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302766 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2767 }
2768 return QDF_STATUS_E_FAILURE;
2769 }
2770
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002771 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002772 policy_mgr_check_concurrent_intf_and_restart_sap(
Jeff Johnson8095a312017-09-03 09:13:24 -07002773 hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774
Nirav Shah1da77682016-05-03 20:16:39 +05302775 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002776 adapter->session_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002777 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302778 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2779
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 /*
2781 * For reassoc, the station is already registered, all we need
2782 * is to change the state of the STA in TL.
2783 * If authentication is required (WPA/WPA2/DWEP), change TL to
2784 * CONNECTED instead of AUTHENTICATED.
2785 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002786 if (!roam_info->fReassocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 u8 *pFTAssocRsp = NULL;
2789 unsigned int assocRsplen = 0;
2790 u8 *pFTAssocReq = NULL;
2791 unsigned int assocReqlen = 0;
2792 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2794 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2795
2796 /* add bss_id to cfg80211 data base */
2797 bss =
Jeff Johnsonba388342017-10-02 13:31:01 -07002798 wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002799 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302801 hdd_err("wlan: Not able to create BSS entry");
Jeff Johnsonba388342017-10-02 13:31:01 -07002802 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 WLAN_NETIF_CARRIER_OFF,
2804 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302805 if (!hddDisconInProgress) {
2806 /*
2807 * Here driver was not able to add bss
2808 * in cfg80211 database this can happen
2809 * if connected channel is not valid,
2810 * i.e reg domain was changed during
2811 * connection. Queue disconnect for the
2812 * session if disconnect is not in
2813 * progress.
2814 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002815 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302816 sme_roam_disconnect(
Jeff Johnsonba388342017-10-02 13:31:01 -07002817 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002818 adapter->session_id,
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302819 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2820 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302821 return QDF_STATUS_E_FAILURE;
Jiachao Wu0411bc92017-11-21 10:43:27 +08002822 } else {
2823 cfg80211_put_bss(
2824 hdd_ctx->wiphy,
2825 bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 }
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302827
2828 /* Association Response */
2829 pFTAssocRsp =
2830 (u8 *) (roam_info->pbFrames +
2831 roam_info->nBeaconLength +
2832 roam_info->nAssocReqLength);
2833 if (pFTAssocRsp != NULL) {
2834 /*
2835 * pFTAssocRsp needs to point to the IEs
2836 */
2837 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2838 hdd_debug("AssocRsp is now at %02x%02x",
2839 (unsigned int)pFTAssocRsp[0],
2840 (unsigned int)pFTAssocRsp[1]);
2841 assocRsplen =
2842 roam_info->nAssocRspLength -
2843 FT_ASSOC_RSP_IES_OFFSET;
2844
2845 hdd_debug("assocRsplen %d", assocRsplen);
2846 hdd_debug("Assoc Rsp IE dump");
2847 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
2848 QDF_TRACE_LEVEL_DEBUG,
2849 pFTAssocRsp,
2850 assocRsplen);
2851 } else {
2852 hdd_debug("AssocRsp is NULL");
2853 assocRsplen = 0;
2854 }
2855
2856 /* Association Request */
2857 pFTAssocReq = (u8 *) (roam_info->pbFrames +
2858 roam_info->nBeaconLength);
2859 if (pFTAssocReq != NULL) {
2860 if (!ft_carrier_on) {
2861 /*
2862 * pFTAssocReq needs to point to
2863 * the IEs
2864 */
2865 pFTAssocReq +=
2866 FT_ASSOC_REQ_IES_OFFSET;
2867 hdd_debug("pFTAssocReq is now at %02x%02x",
2868 (unsigned int)
2869 pFTAssocReq[0],
2870 (unsigned int)
2871 pFTAssocReq[1]);
2872 assocReqlen =
2873 roam_info->nAssocReqLength -
2874 FT_ASSOC_REQ_IES_OFFSET;
2875 } else {
2876 /*
2877 * This should contain only the
2878 * FTIEs
2879 */
2880 assocReqlen =
2881 roam_info->nAssocReqLength;
2882 }
2883
2884 hdd_debug("assocReqlen %d", assocReqlen);
2885 hdd_debug("Assoc/Reassoc Req IE dump");
2886 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
2887 QDF_TRACE_LEVEL_DEBUG,
2888 pFTAssocReq,
2889 assocReqlen);
2890 } else {
2891 hdd_debug("AssocReq is NULL");
2892 assocReqlen = 0;
2893 }
2894
Jeff Johnsonfd060852017-10-04 10:50:51 -07002895 if (roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 eCSR_AUTH_TYPE_FT_RSN
Jeff Johnsonfd060852017-10-04 10:50:51 -07002897 || roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 eCSR_AUTH_TYPE_FT_RSN_PSK) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08002900 if (!hddDisconInProgress &&
Jeff Johnsonfd060852017-10-04 10:50:51 -07002901 roam_info->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302902 struct cfg80211_bss *roam_bss;
2903
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 /*
2905 * After roaming is completed,
2906 * active session count is
2907 * incremented as a part of
2908 * connect indication but
2909 * effectively the active
2910 * session count should still
2911 * be the same and hence upon
2912 * successful reassoc
2913 * decrement the active session
2914 * count here.
2915 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002916 if (!hdd_is_roam_sync_in_progress
Jeff Johnsonfd060852017-10-04 10:50:51 -07002917 (roam_info))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002918 policy_mgr_decr_session_set_pcl(
Jeff Johnson8095a312017-09-03 09:13:24 -07002919 hdd_ctx->hdd_psoc,
Jeff Johnsonba388342017-10-02 13:31:01 -07002920 adapter->device_mode,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002921 adapter->session_id);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002922 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002923 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 chan =
2925 ieee80211_get_channel
Jeff Johnsonba388342017-10-02 13:31:01 -07002926 (adapter->wdev.wiphy,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002927 (int)roam_info->pBssDesc->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 channelId);
Naveen Rawat14298b92015-11-25 16:27:41 -08002929
Abhishek Singh533c9da2017-05-04 10:23:34 +05302930 roam_bss =
2931 hdd_cfg80211_get_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07002932 adapter->wdev.wiphy,
Abhishek Singh533c9da2017-05-04 10:23:34 +05302933 chan,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002934 roam_info->bssid.bytes,
2935 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05302936 pConnectedProfile->SSID.ssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002937 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05302938 pConnectedProfile->SSID.length);
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302939 hdd_send_roamed_ind(
2940 dev,
2941 roam_bss,
2942 pFTAssocReq,
2943 assocReqlen,
2944 pFTAssocRsp,
2945 assocRsplen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302946 wlan_hdd_send_roam_auth_event(
Jeff Johnsonba388342017-10-02 13:31:01 -07002947 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002948 roam_info->bssid.bytes,
Abhishek Singh533c9da2017-05-04 10:23:34 +05302949 pFTAssocReq,
2950 assocReqlen,
2951 pFTAssocRsp,
2952 assocRsplen,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002953 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 }
2955 if (sme_get_ftptk_state
Jeff Johnsonba388342017-10-02 13:31:01 -07002956 (WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002957 adapter->session_id)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 sme_set_ftptk_state
2959 (WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07002960 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002961 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 false);
Jeff Johnsonfd060852017-10-04 10:50:51 -07002963 roam_info->fAuthRequired =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 false;
2965
Jeff Johnsond377dce2017-10-04 10:32:42 -07002966 qdf_mem_copy(sta_ctx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967 roam_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002968 roam_info->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302969 QDF_MAC_ADDR_SIZE);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002970 qdf_mem_copy(sta_ctx->
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002971 roam_info.peer_mac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002972 roam_info->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302973 QDF_MAC_ADDR_SIZE);
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002974 sta_ctx->roam_info.roam_id =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 roamId;
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002976 sta_ctx->roam_info.roam_status =
2977 roamStatus;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002978 sta_ctx->roam_info.
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002979 defer_key_complete = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002980 }
2981 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002982 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002983 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302984 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002985 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302986 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002987 roam_info,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302988 pFTAssocReq,
2989 assocReqlen,
2990 pFTAssocRsp,
2991 assocRsplen,
2992 WLAN_STATUS_SUCCESS,
2993 GFP_KERNEL,
2994 false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002995 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002997 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 /*
2999 * wpa supplicant expecting WPA/RSN IE in
3000 * connect result.
3001 */
3002 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07003003 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003004 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 &reqRsnLength,
3006 reqRsnIe);
3007
3008 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07003009 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003010 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 &rspRsnLength,
3012 rspRsnIe);
3013 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 if (ft_carrier_on)
3015 hdd_send_re_assoc_event(dev,
Jeff Johnsonba388342017-10-02 13:31:01 -07003016 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003017 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 reqRsnIe,
3019 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07003020 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003021 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003022 MAC_ADDRESS_STR
3023 " result:%d and Status:%d",
3024 MAC_ADDR_ARRAY
Jeff Johnsonfd060852017-10-04 10:50:51 -07003025 (roam_info->bssid.bytes),
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003026 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027
3028 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05303029 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003030 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303031 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003032 roam_info,
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303033 pFTAssocReq,
3034 assocReqlen,
3035 pFTAssocRsp,
3036 assocRsplen,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303037 WLAN_STATUS_SUCCESS,
3038 GFP_KERNEL,
3039 false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003040 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 }
3042 }
3043 }
3044 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 /*
3046 * Perform any WMM-related association
3047 * processing.
3048 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003049 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 eCSR_BSS_TYPE_INFRASTRUCTURE);
3051
3052 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08003053 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003055 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003056 roam_info,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003057 sta_ctx->conn_info.staId[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07003058 NULL, roam_info->pBssDesc);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303059 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003060 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 WLAN_WAKE_ALL_NETIF_QUEUE,
3062 WLAN_CONTROL_PATH);
3063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 }
3065 } else {
3066 /*
3067 * wpa supplicant expecting WPA/RSN IE in connect result
3068 * in case of reassociation also need to indicate it to
3069 * supplicant.
3070 */
3071 csr_roam_get_wpa_rsn_req_ie(
Jeff Johnsonba388342017-10-02 13:31:01 -07003072 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003073 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 &reqRsnLength, reqRsnIe);
3075
Jeff Johnsonfd060852017-10-04 10:50:51 -07003076 hdd_send_re_assoc_event(dev, adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 reqRsnIe, reqRsnLength);
3078 /* Reassoc successfully */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003079 if (roam_info->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303080 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003081 hdd_change_peer_state(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003082 sta_ctx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003083 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003085 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086#else
3087 false
3088#endif
3089 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003090 hdd_conn_set_authenticated(adapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003091 hdd_objmgr_set_peer_mlme_auth_state(
Jeff Johnsonba388342017-10-02 13:31:01 -07003092 adapter->hdd_vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003093 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003095 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Jeff Johnsond377dce2017-10-04 10:32:42 -07003096 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303097 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003098 hdd_change_peer_state(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003099 sta_ctx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003100 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003102 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103#else
3104 false
3105#endif
3106 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003107 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003108 hdd_objmgr_set_peer_mlme_auth_state(
Jeff Johnsonba388342017-10-02 13:31:01 -07003109 adapter->hdd_vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003110 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 }
3112
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303113 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 /*
3115 * Perform any WMM-related association
3116 * processing
3117 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003118 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 eCSR_BSS_TYPE_INFRASTRUCTURE);
3120 }
3121
3122 /* Start the tx queues */
3123#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003124 if (roam_info->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003125 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126#endif
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303127 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003128 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 WLAN_WAKE_ALL_NETIF_QUEUE,
3130 WLAN_CONTROL_PATH);
3131 }
3132
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303133 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003134 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303135 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 }
3137#ifdef WLAN_FEATURE_11W
Jeff Johnsondc179f42017-10-21 11:27:26 -07003138 qdf_mem_zero(&adapter->hdd_stats.hdd_pmf_stats,
3139 sizeof(adapter->hdd_stats.hdd_pmf_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140#endif
3141 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05303142 bool connect_timeout = false;
Vignesh Viswanathan014096a2017-12-07 01:24:44 +05303143 if (roam_info && roam_info->is_fils_connection &&
3144 eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult)
3145 qdf_copy_macaddr(&roam_info->bssid,
3146 &sta_ctx->requested_bssid);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003147 if (roam_info)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303148 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003149 " result: %d and Status: %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003150 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303151 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303153 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003154 " result: %d and Status: %d",
Jeff Johnson731bc322017-10-14 19:53:44 -07003155 MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303156 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05303157
3158 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
Jeff Johnsonfd060852017-10-04 10:50:51 -07003159 (roam_info &&
Abhishek Singhc9941602016-08-09 16:06:22 +05303160 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003161 roam_info->statusCode) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303162 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003163 roam_info->statusCode) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303164 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003165 roam_info->statusCode)))) {
Jeff Johnsonba388342017-10-02 13:31:01 -07003166 wlan_hdd_cfg80211_update_bss_list(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003167 roam_info ?
3168 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003169 sta_ctx->requested_bssid.bytes);
Jeff Johnson8095a312017-09-03 09:13:24 -07003170 sme_remove_bssid_from_scan_list(hdd_ctx->hHal,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003171 roam_info ?
3172 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003173 sta_ctx->requested_bssid.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303174 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303175 }
3176
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 /*
3178 * CR465478: Only send up a connection failure result when CSR
3179 * has completed operation - with a ASSOCIATION_FAILURE status.
3180 */
3181 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3182 && !hddDisconInProgress) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003183 if (roam_info) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003184 hdd_err("send connect failure to nl80211: for bssid "
3185 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003186 " result: %d and Status: %d reasoncode: %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003187 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003188 roamResult, roamStatus,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003189 roam_info->reasonCode);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003190 sta_ctx->conn_info.assoc_status_code =
Jeff Johnsonfd060852017-10-04 10:50:51 -07003191 roam_info->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003192 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003193 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003195 " result: %d and status: %d ",
Jeff Johnson731bc322017-10-14 19:53:44 -07003196 MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003198 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003199 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303200 wlan_deregister_txrx_packetdump();
3201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 /* inform association failure event to nl80211 */
3203 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3204 roamResult) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003205 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303206 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003207 roam_info->bssid.bytes,
3208 roam_info, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303210 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303211 connect_timeout,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003212 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303214 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003215 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303216 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303218 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303219 connect_timeout,
3220 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003222 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303223 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003224 roam_info->bssid.bytes,
3225 roam_info, NULL, 0, NULL, 0,
3226 roam_info->reasonCode ?
3227 roam_info->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303229 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303230 connect_timeout,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003231 roam_info->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003232 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303233 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003234 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303235 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303237 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303238 connect_timeout,
3239 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003241 hdd_clear_roam_profile_ie(adapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003242 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3243 && !hddDisconInProgress)) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003244 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003245 sta_ctx->requested_bssid.bytes,
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003246 NULL, NULL, 0, NULL, 0,
3247 WLAN_STATUS_UNSPECIFIED_FAILURE,
3248 GFP_KERNEL,
3249 connect_timeout,
3250 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 }
3252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 /*
3254 * Set connection state to eConnectionState_NotConnected only
3255 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003256 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003258 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3259 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 && !hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07003261 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 eConnectionState_NotConnected);
3263 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003264 hdd_wmm_init(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303266 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003267 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303268 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 WLAN_CONTROL_PATH);
3270 }
3271
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303272 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273}
3274
3275/**
3276 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
Jeff Johnsonba388342017-10-02 13:31:01 -07003277 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003278 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 * @roamId: roam id
3280 * @roamStatus: roam status
3281 * @roamResult: roam result
3282 *
3283 * Here we update the status of the Ibss when we receive information that we
3284 * have started/joined an ibss session.
3285 *
3286 * Return: none
3287 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003288static void hdd_roam_ibss_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003289 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 uint32_t roamId,
3291 eRoamCmdStatus roamStatus,
3292 eCsrRoamResult roamResult)
3293{
Jeff Johnsonba388342017-10-02 13:31:01 -07003294 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003295
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003296 hdd_debug("%s: id %d, status %d, result %d",
Jeff Johnsonba388342017-10-02 13:31:01 -07003297 adapter->dev->name, roamId,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003298 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299
3300 switch (roamResult) {
3301 /* both IBSS Started and IBSS Join should come in here. */
3302 case eCSR_ROAM_RESULT_IBSS_STARTED:
3303 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3304 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3305 {
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003306 struct hdd_station_ctx *hdd_sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003307 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dustin Brownce5b3d32018-01-17 15:07:38 -08003308 struct qdf_mac_addr broadcastMacAddr = QDF_MAC_ADDR_BCAST_INIT;
Abhishek Singh44725482017-11-02 16:53:23 +05303309 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310
Jeff Johnsonfd060852017-10-04 10:50:51 -07003311 if (NULL == roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303312 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 return;
3314 }
3315
3316 /* When IBSS Started comes from CSR, we need to move
3317 * connection state to IBSS Disconnected (meaning no peers
3318 * are in the IBSS).
3319 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003320 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 eConnectionState_IbssDisconnected);
3322 /* notify wmm */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003323 hdd_wmm_connect(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303325
Jeff Johnsonfd060852017-10-04 10:50:51 -07003326 hdd_sta_ctx->broadcast_staid = roam_info->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303327
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003328 if (roam_info->staId < HDD_MAX_ADAPTERS)
3329 hdd_ctx->sta_to_adapter[roam_info->staId] =
3330 adapter;
3331 else
3332 hdd_debug("invalid sta id %d", roam_info->staId);
Abhishek Singh44725482017-11-02 16:53:23 +05303333
Jeff Johnsonfd060852017-10-04 10:50:51 -07003334 hdd_roam_register_sta(adapter, roam_info,
3335 roam_info->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 &broadcastMacAddr,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003337 roam_info->pBssDesc);
Abhishek Singh44725482017-11-02 16:53:23 +05303338 ret = hdd_objmgr_add_peer_object(adapter->hdd_vdev,
3339 QDF_IBSS_MODE,
3340 broadcastMacAddr.bytes,
3341 false);
3342 if (ret)
3343 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
3344 MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345
Jeff Johnsonfd060852017-10-04 10:50:51 -07003346 if (roam_info->pBssDesc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 struct cfg80211_bss *bss;
3348#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3349 struct ieee80211_channel *chan;
3350 int chan_no;
3351 unsigned int freq;
3352#endif
3353 /* we created the IBSS, notify supplicant */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303354 hdd_debug("%s: created ibss " MAC_ADDRESS_STR,
Jeff Johnsonba388342017-10-02 13:31:01 -07003355 adapter->dev->name,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003356 MAC_ADDR_ARRAY(
Jeff Johnsonfd060852017-10-04 10:50:51 -07003357 roam_info->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358
3359 /* we must first give cfg80211 the BSS information */
Jeff Johnsonba388342017-10-02 13:31:01 -07003360 bss = wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003361 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003363 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003364 adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 return;
3366 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303367 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003368 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3370 WLAN_CONTROL_PATH);
3371
3372#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003373 chan_no = roam_info->pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374
3375 if (chan_no <= 14)
3376 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003377 HDD_NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 else
3379 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003380 HDD_NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381
Jeff Johnsonba388342017-10-02 13:31:01 -07003382 chan = ieee80211_get_channel(adapter->wdev.wiphy, freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383
3384 if (chan)
Jeff Johnsonba388342017-10-02 13:31:01 -07003385 cfg80211_ibss_joined(adapter->dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 bss->bssid, chan,
3387 GFP_KERNEL);
3388 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003389 hdd_warn("%s: chanId: %d, can't find channel",
Jeff Johnsonba388342017-10-02 13:31:01 -07003390 adapter->dev->name,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003391 (int)roam_info->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003393 cfg80211_ibss_joined(adapter->dev, bss->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 GFP_KERNEL);
3395#endif
3396 cfg80211_put_bss(
Jeff Johnson8095a312017-09-03 09:13:24 -07003397 hdd_ctx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 bss);
3399 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003400 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003401 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003402 adapter->device_mode, adapter->session_id);
Krunal Soni2c68f232015-10-26 20:52:51 -07003403 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3404 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003405 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003406 adapter->session_id);
Krunal Soni2c68f232015-10-26 20:52:51 -07003407 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 break;
3409 }
3410
3411 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3412 {
Jeff Johnsonba388342017-10-02 13:31:01 -07003413 hdd_err("%s: unable to create IBSS", adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 break;
3415 }
3416
3417 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003418 hdd_err("%s: unexpected result %d",
Jeff Johnsonba388342017-10-02 13:31:01 -07003419 adapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 break;
3421 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422}
3423
3424/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003425 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3426 * @sta_ctx: pointer to hdd station context
3427 * @sta_id: station ID
3428 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 *
3430 * This information is passed to iwconfig later. The peer that joined
3431 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003432
3433 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003435bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003436 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003438 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003440 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303441 if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003442 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003443 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003444 sta_ctx->conn_info.staId[idx] = sta_id;
3445 qdf_copy_macaddr(
3446 &sta_ctx->conn_info.peerMacAddress[idx],
3447 peer_mac_addr);
3448 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 }
3450 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003451 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452}
3453
3454/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003455 * hdd_delete_peer() - removes peer from hdd station context peer table
3456 * @sta_ctx: pointer to hdd station context
3457 * @sta_id: station ID
3458 *
3459 * Return: None
3460 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003461void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id)
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003462{
3463 int i;
3464
3465 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3466 if (sta_id == sta_ctx->conn_info.staId[i]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303467 sta_ctx->conn_info.staId[i] = HDD_WLAN_INVALID_STA_ID;
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003468 return;
3469 }
3470 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003471}
3472
3473/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
Jeff Johnsonba388342017-10-02 13:31:01 -07003475 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 * @staId: station id
3477 *
3478 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003479 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 * false otherwise.
3481 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003482static bool roam_remove_ibss_station(struct hdd_adapter *adapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483{
3484 bool fSuccess = false;
3485 int idx = 0;
3486 uint8_t valid_idx = 0;
3487 uint8_t del_idx = 0;
3488 uint8_t empty_slots = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003489 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490
Naveen Rawatc45d1622016-07-05 12:20:09 -07003491 for (idx = 0; idx < MAX_PEERS; idx++) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003492 if (staId == sta_ctx->conn_info.staId[idx]) {
3493 sta_ctx->conn_info.staId[idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303494 HDD_WLAN_INVALID_STA_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495
Jeff Johnsond377dce2017-10-04 10:32:42 -07003496 qdf_zero_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497 peerMacAddress[idx]);
3498
3499 fSuccess = true;
3500
3501 /*
3502 * Note the deleted Index, if its 0 we need special
3503 * handling.
3504 */
3505 del_idx = idx;
3506
3507 empty_slots++;
3508 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003509 if (sta_ctx->conn_info.staId[idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003510 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 valid_idx = idx;
3512 } else {
3513 /* Found an empty slot */
3514 empty_slots++;
3515 }
3516 }
3517 }
3518
Naveen Rawatc45d1622016-07-05 12:20:09 -07003519 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 /* Last peer departed, set the IBSS state appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07003521 hdd_conn_set_connection_state(adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003522 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003523 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 }
3525 /* Find next active staId, to have a valid sta trigger for TL. */
3526 if (fSuccess == true) {
3527 if (del_idx == 0) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003528 if (sta_ctx->conn_info.staId[valid_idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003529 HDD_WLAN_INVALID_STA_ID) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003530 sta_ctx->conn_info.staId[0] =
3531 sta_ctx->conn_info.staId[valid_idx];
3532 qdf_copy_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 peerMacAddress[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -07003534 &sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 peerMacAddress[valid_idx]);
3536
Jeff Johnsond377dce2017-10-04 10:32:42 -07003537 sta_ctx->conn_info.staId[valid_idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303538 HDD_WLAN_INVALID_STA_ID;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003539 qdf_zero_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 peerMacAddress[valid_idx]);
3541 }
3542 }
3543 }
3544 return fSuccess;
3545}
3546
3547/**
3548 * roam_ibss_connect_handler() - IBSS connection handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003549 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003550 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 *
3552 * We update the status of the IBSS to connected in this function.
3553 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303554 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003556static QDF_STATUS roam_ibss_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003557 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558{
3559 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 /*
3561 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3562 * a partner stations).
3563 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003564 hdd_conn_set_connection_state(adapter, eConnectionState_IbssConnected);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565
3566 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003567 hdd_conn_save_connect_info(adapter, roam_info, eCSR_BSS_TYPE_IBSS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568
3569 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003570 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 /* add bss_id to cfg80211 data base */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003572 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003574 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003575 adapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303576 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577 }
3578 cfg80211_put_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07003579 WLAN_HDD_GET_CTX(adapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 bss);
3581
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303582 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583}
3584
3585/**
3586 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003587 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003588 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 * @roamId: roam id
3590 * @roamStatus: roam status
3591 * @roamResult: roam result
3592 *
3593 * This function indicates the Mic failure to the supplicant
3594 *
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003595 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 */
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003597static void
Jeff Johnsonba388342017-10-02 13:31:01 -07003598hdd_roam_mic_error_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003599 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600{
Jeff Johnsond377dce2017-10-04 10:32:42 -07003601 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003602 tSirMicFailureInfo *mic_failure_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003604 if (eConnectionState_Associated != sta_ctx->conn_info.connState)
3605 return;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003606
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003607 mic_failure_info = roam_info->u.pMICFailureInfo;
3608 cfg80211_michael_mic_failure(adapter->dev,
3609 mic_failure_info->taMacAddr,
3610 mic_failure_info->multicast ?
3611 NL80211_KEYTYPE_GROUP :
3612 NL80211_KEYTYPE_PAIRWISE,
3613 mic_failure_info->keyId,
3614 mic_failure_info->TSC,
3615 GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616}
3617
3618/**
3619 * roam_roam_connect_status_update_handler() - IBSS connect status update
Jeff Johnsonba388342017-10-02 13:31:01 -07003620 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003621 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 * @roamId: roam id
3623 * @roamStatus: roam status
3624 * @roamResult: roam result
3625 *
3626 * The Ibss connection status is updated regularly here in this function.
3627 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303628 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303630static QDF_STATUS
Jeff Johnsonba388342017-10-02 13:31:01 -07003631roam_roam_connect_status_update_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003632 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 uint32_t roamId,
3634 eRoamCmdStatus roamStatus,
3635 eCsrRoamResult roamResult)
3636{
Jeff Johnsonba388342017-10-02 13:31:01 -07003637 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003638 QDF_STATUS qdf_status;
Abhishek Singh44725482017-11-02 16:53:23 +05303639 int ret;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 switch (roamResult) {
3642 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3643 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003644 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003645 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003646 struct station_info *stainfo;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003647 eCsrEncryptionType encr_type = sta_ctx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303649 hdd_debug("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303650 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3651 MAC_ADDRESS_STR " and stationID= %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003652 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
Jeff Johnsond377dce2017-10-04 10:32:42 -07003653 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003654 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003656 if (!hdd_save_peer
Jeff Johnsonba388342017-10-02 13:31:01 -07003657 (WLAN_HDD_GET_STATION_CTX_PTR(adapter),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003658 roam_info->staId,
3659 &roam_info->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003660 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 break;
3662 }
3663
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003664 if (roam_info->staId < HDD_MAX_ADAPTERS)
3665 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
3666 else
3667 hdd_debug("invalid sta id %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003669 if (hdd_is_key_install_required_for_ibss(encr_type))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003670 roam_info->fAuthRequired = true;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003672 /* Register the Station with TL for the new peer. */
Jeff Johnsonba388342017-10-02 13:31:01 -07003673 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003674 roam_info,
3675 roam_info->staId,
3676 &roam_info->peerMac,
3677 roam_info->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303678 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003679 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303680 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 }
Abhishek Singh44725482017-11-02 16:53:23 +05303682 ret = hdd_objmgr_add_peer_object(adapter->hdd_vdev,
3683 QDF_IBSS_MODE,
3684 roam_info->peerMac.bytes,
3685 false);
3686 if (ret)
3687 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
3688 MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Jeff Johnsond377dce2017-10-04 10:32:42 -07003689 sta_ctx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003690 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3691 if (stainfo == NULL) {
3692 hdd_err("memory allocation for station_info failed");
3693 return QDF_STATUS_E_NOMEM;
3694 }
3695 stainfo->filled = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003696 stainfo->generation = sta_ctx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697
Jeff Johnsonba388342017-10-02 13:31:01 -07003698 cfg80211_new_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003699 (const u8 *)roam_info->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003700 stainfo, GFP_KERNEL);
3701 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003703 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003704 sta_ctx->ibss_enc_key.keyDirection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 eSIR_TX_RX;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003706 qdf_copy_macaddr(&sta_ctx->ibss_enc_key.peerMac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003707 &roam_info->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303709 hdd_debug("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003710 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303712 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07003714 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003715 adapter->session_id,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003716 &sta_ctx->ibss_enc_key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 &roamId);
3718
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303719 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003720 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003721 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303722 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 }
3724 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303725 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003726 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3728 WLAN_CONTROL_PATH);
3729 break;
3730 }
3731
3732 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3733 {
3734
Jeff Johnsonfd060852017-10-04 10:50:51 -07003735 roam_ibss_connect_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736
3737 break;
3738 }
3739 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3740 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003741 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003742 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743
Jeff Johnsonfd060852017-10-04 10:50:51 -07003744 if (!roam_remove_ibss_station(adapter, roam_info->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003745 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303747 hdd_debug("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303748 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3749 MAC_ADDRESS_STR " and stationID= %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003750 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
Jeff Johnsond377dce2017-10-04 10:32:42 -07003751 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003752 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753
Jeff Johnsonfd060852017-10-04 10:50:51 -07003754 hdd_roam_deregister_sta(adapter, roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003756 if (roam_info->staId < HDD_MAX_ADAPTERS)
3757 hdd_ctx->sta_to_adapter[roam_info->staId] = NULL;
3758 else
3759 hdd_debug("invalid sta id %d", roam_info->staId);
3760
Jeff Johnsond377dce2017-10-04 10:32:42 -07003761 sta_ctx->ibss_sta_generation++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762
Jeff Johnsonba388342017-10-02 13:31:01 -07003763 cfg80211_del_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003764 (const u8 *)&roam_info->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 GFP_KERNEL);
3766 break;
3767 }
3768 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3769 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003770 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 /* Stop only when we are inactive */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303772 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003773 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303774 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07003776 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777 eConnectionState_NotConnected);
3778
3779 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003780 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 break;
3782 }
3783 default:
3784 break;
3785
3786 }
3787
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303788 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789}
3790
3791#ifdef FEATURE_WLAN_TDLS
3792/**
3793 * hdd_roam_register_tdlssta() - register new TDLS station
Jeff Johnsonba388342017-10-02 13:31:01 -07003794 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 * @peerMac: pointer to peer MAC address
3796 * @staId: station identifier
3797 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303798 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 *
3800 * Construct the staDesc and register with TL the new STA.
3801 * This is called as part of ADD_STA in the TDLS setup.
3802 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303803 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003805QDF_STATUS hdd_roam_register_tdlssta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303807 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303809 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003811 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003812 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3813 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814
3815 /*
3816 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3817 * be peer MAC, here we are working on direct Link
3818 */
3819 staDesc.sta_id = staId;
3820
3821 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303822 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823
Dhanashri Atre50141c52016-04-07 13:15:29 -07003824 /* Register the vdev transmit and receive functions */
3825 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3826 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003827 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003828 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003829 (struct cdp_pdev *)pdev, adapter->session_id),
Jeff Johnsonba388342017-10-02 13:31:01 -07003830 adapter, &txrx_ops);
3831 adapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832
3833 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003834 qdf_status = cdp_peer_register(soc,
3835 (struct cdp_pdev *)pdev, &staDesc);
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("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303838 qdf_status, qdf_status);
3839 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 }
3841
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303842 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843}
3844
3845/**
3846 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
Jeff Johnsonba388342017-10-02 13:31:01 -07003847 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848 * @staId: station identifier
3849 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303850 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 */
Jeff Johnson53367842017-10-03 11:10:34 -07003852QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
3853 uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303855 QDF_STATUS qdf_status;
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07003856
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003857 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003858 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3859 staId);
Kabilan Kannanb4e01372018-01-15 13:33:10 -08003860
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303861 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862}
3863
Kabilan Kannan32eb5022016-10-04 12:24:50 -07003864#else
3865
Jeff Johnsonba388342017-10-02 13:31:01 -07003866inline QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07003867 uint8_t staId)
3868{
3869 return QDF_STATUS_SUCCESS;
3870}
3871
3872static inline QDF_STATUS
Jeff Johnsonba388342017-10-02 13:31:01 -07003873hdd_roam_tdls_status_update_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003874 struct csr_roam_info *roam_info,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07003875 uint32_t roamId,
3876 eRoamCmdStatus roamStatus,
3877 eCsrRoamResult roamResult)
3878{
3879 return QDF_STATUS_SUCCESS;
3880}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881#endif
3882
3883#ifdef WLAN_FEATURE_11W
3884/**
3885 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
Jeff Johnsonba388342017-10-02 13:31:01 -07003886 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 * @nFrameLength: Length of the unprotected frame being passed
3888 * @pbFrames: Pointer to the frame buffer
3889 * @frameType: 802.11 frame type
3890 *
3891 * This function forwards the unprotected management frame to the supplicant.
3892 *
3893 * Return: nothing
3894 */
3895static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07003896hdd_indicate_unprot_mgmt_frame(struct hdd_adapter *adapter,
3897 uint32_t nFrameLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003898 uint8_t *pbFrames, uint8_t frameType)
3899{
3900 uint8_t type = 0;
3901 uint8_t subType = 0;
3902
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003903 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003904 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905
3906 /* Sanity Checks */
Jeff Johnsonba388342017-10-02 13:31:01 -07003907 if (NULL == adapter) {
3908 hdd_err("adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 return;
3910 }
3911
Jeff Johnsonba388342017-10-02 13:31:01 -07003912 if (NULL == adapter->dev) {
3913 hdd_err("adapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 return;
3915 }
3916
Jeff Johnsonba388342017-10-02 13:31:01 -07003917 if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
3918 hdd_err("adapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 return;
3920 }
3921
3922 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003923 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924 return;
3925 }
3926
3927 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003928 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 return;
3930 }
3931
3932 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3933 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3934
Jeff Johnsonba388342017-10-02 13:31:01 -07003935 /* Get adapter from Destination mac address of the frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
3937#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
Jeff Johnsonba388342017-10-02 13:31:01 -07003938 cfg80211_rx_unprot_mlme_mgmt(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939 nFrameLength);
3940#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003941 cfg80211_send_unprot_disassoc(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942 nFrameLength);
3943#endif
Jeff Johnsondc179f42017-10-21 11:27:26 -07003944 adapter->hdd_stats.hdd_pmf_stats.num_unprot_disassoc_rx++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945 } else if (type == SIR_MAC_MGMT_FRAME &&
3946 subType == SIR_MAC_MGMT_DEAUTH) {
3947#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
Jeff Johnsonba388342017-10-02 13:31:01 -07003948 cfg80211_rx_unprot_mlme_mgmt(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 nFrameLength);
3950#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003951 cfg80211_send_unprot_deauth(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952 nFrameLength);
3953#endif
Jeff Johnsondc179f42017-10-21 11:27:26 -07003954 adapter->hdd_stats.hdd_pmf_stats.num_unprot_deauth_rx++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003956 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003957 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958 return;
3959 }
3960}
3961#endif
3962
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003963#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964/**
3965 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
Jeff Johnsonba388342017-10-02 13:31:01 -07003966 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 * @tid: traffic identifier
3968 * @state: state
3969 * @measInterval: measurement interval
3970 *
3971 * This function sends traffic stream metrics IE information to
3972 * the supplicant via wireless event.
3973 *
3974 * Return: none
3975 */
3976static void
Jeff Johnsonba388342017-10-02 13:31:01 -07003977hdd_indicate_tsm_ie(struct hdd_adapter *adapter, uint8_t tid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 uint8_t state, uint16_t measInterval)
3979{
3980 union iwreq_data wrqu;
3981 char buf[IW_CUSTOM_MAX + 1];
3982 int nBytes = 0;
3983
Jeff Johnsonba388342017-10-02 13:31:01 -07003984 if (NULL == adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 return;
3986
3987 /* create the event */
3988 memset(&wrqu, '\0', sizeof(wrqu));
3989 memset(buf, '\0', sizeof(buf));
3990
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003991 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003992 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993
3994 nBytes =
3995 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
3996 measInterval);
3997
3998 wrqu.data.pointer = buf;
3999 wrqu.data.length = nBytes;
4000 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004001 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002}
4003
4004/**
4005 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004006 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004007 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 *
4009 * This function sends cckm preauth indication to the supplicant
4010 * via wireless custom event.
4011 *
4012 * Return: none
4013 */
4014static void
Jeff Johnson172237b2017-11-07 15:32:59 -08004015hdd_indicate_cckm_pre_auth(struct hdd_adapter *adapter,
4016 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017{
4018 union iwreq_data wrqu;
4019 char buf[IW_CUSTOM_MAX + 1];
4020 char *pos = buf;
4021 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4022
Jeff Johnsonfd060852017-10-04 10:50:51 -07004023 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024 return;
4025
4026 /* create the event */
4027 memset(&wrqu, '\0', sizeof(wrqu));
4028 memset(buf, '\0', sizeof(buf));
4029
4030 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004031 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004032 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
4033 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034
4035 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4036 pos += nBytes;
4037 freeBytes -= nBytes;
4038
Jeff Johnsonfd060852017-10-04 10:50:51 -07004039 qdf_mem_copy(pos, roam_info->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304040 pos += QDF_MAC_ADDR_SIZE;
4041 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042
4043 nBytes = snprintf(pos, freeBytes, " %u:%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004044 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 freeBytes -= nBytes;
4046
4047 wrqu.data.pointer = buf;
4048 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4049
4050 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004051 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052}
4053
4054/**
4055 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004056 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004057 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 *
4059 * Return: none
4060 */
4061static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004062hdd_indicate_ese_adj_ap_rep_ind(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004063 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064{
4065 union iwreq_data wrqu;
4066 char buf[IW_CUSTOM_MAX + 1];
4067 int nBytes = 0;
4068
Jeff Johnsonfd060852017-10-04 10:50:51 -07004069 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 return;
4071
4072 /* create the event */
4073 memset(&wrqu, '\0', sizeof(wrqu));
4074 memset(buf, '\0', sizeof(buf));
4075
Jeff Johnsonfd060852017-10-04 10:50:51 -07004076 hdd_debug("CCXADJAPREP=%u", roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077
4078 nBytes =
4079 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004080 roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081
4082 wrqu.data.pointer = buf;
4083 wrqu.data.length = nBytes;
4084
4085 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004086 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087}
4088
4089/**
4090 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
Jeff Johnsonba388342017-10-02 13:31:01 -07004091 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 * @measurementToken: measurement token
4093 * @flag: flag
4094 * @numBss: number of bss
4095 *
4096 * If the measurement is none and no scan results found,
4097 * indicate the supplicant about measurement done.
4098 *
4099 * Return: none
4100 */
4101void
Jeff Johnsonba388342017-10-02 13:31:01 -07004102hdd_indicate_ese_bcn_report_no_results(const struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103 const uint16_t measurementToken,
4104 const bool flag, const uint8_t numBss)
4105{
4106 union iwreq_data wrqu;
4107 char buf[IW_CUSTOM_MAX];
4108 char *pos = buf;
4109 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4110
4111 memset(&wrqu, '\0', sizeof(wrqu));
4112 memset(buf, '\0', sizeof(buf));
4113
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004114 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004115 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116
4117 nBytes =
4118 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4119 flag, numBss);
4120
4121 wrqu.data.pointer = buf;
4122 wrqu.data.length = nBytes;
4123 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004124 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125}
4126
4127/**
4128 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004129 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004130 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 *
4132 * If the measurement is none and no scan results found,
4133 * indicate the supplicant about measurement done.
4134 *
4135 * Return: none
4136 */
4137static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004138hdd_indicate_ese_bcn_report_ind(const struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004139 const struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140{
4141 union iwreq_data wrqu;
4142 char buf[IW_CUSTOM_MAX];
4143 char *pos = buf;
4144 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4145 uint8_t i = 0, len = 0;
4146 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4147 uint8_t lastSent = 0, sendBss = 0;
4148 int bcnRepFieldSize =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004149 sizeof(roam_info->pEseBcnReportRsp->bcnRepBssInfo[0].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150 bcnReportFields);
4151 uint8_t ieLenByte = 1;
4152 /*
4153 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4154 */
4155#define ESEBCNREPHEADER_LEN (18)
4156
Jeff Johnsonfd060852017-10-04 10:50:51 -07004157 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 return;
4159
4160 /*
4161 * Custom event can pass maximum of 256 bytes of data,
4162 * based on the IE len we need to identify how many BSS info can
4163 * be filled in to custom event data.
4164 */
4165 /*
4166 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4167 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4168 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4169 */
4170
Jeff Johnsonfd060852017-10-04 10:50:51 -07004171 if ((roam_info->pEseBcnReportRsp->flag >> 1)
4172 && (!roam_info->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004173 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004175 * indicate the supplicant about measurement done
4176 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 hdd_indicate_ese_bcn_report_no_results(
Jeff Johnsonba388342017-10-02 13:31:01 -07004178 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004179 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004181 roam_info->pEseBcnReportRsp->flag,
4182 roam_info->pEseBcnReportRsp->numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004184 while (lastSent < roam_info->pEseBcnReportRsp->numBss) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 memset(&wrqu, '\0', sizeof(wrqu));
4186 memset(buf, '\0', sizeof(buf));
4187 tot_bcn_ieLen = 0;
4188 sendBss = 0;
4189 pos = buf;
4190 freeBytes = IW_CUSTOM_MAX;
4191
4192 for (i = lastSent;
Jeff Johnsonfd060852017-10-04 10:50:51 -07004193 i < roam_info->pEseBcnReportRsp->numBss; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 len =
4195 bcnRepFieldSize + ieLenByte +
Jeff Johnsonfd060852017-10-04 10:50:51 -07004196 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 bcnRepBssInfo[i].ieLen;
4198 if ((len + tot_bcn_ieLen) >
4199 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4200 break;
4201 }
4202 tot_bcn_ieLen += len;
4203 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004204 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004205 i, bcnRepFieldSize, 1,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004206 roam_info->pEseBcnReportRsp->
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004207 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 }
4209
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004210 hdd_debug("Sending %d BSS Info", sendBss);
4211 hdd_debug("CCXBCNREP=%d %d %d %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004212 roam_info->pEseBcnReportRsp->measurementToken,
4213 roam_info->pEseBcnReportRsp->flag, sendBss,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004214 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215
4216 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004217 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004219 roam_info->pEseBcnReportRsp->flag,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 sendBss);
4221 pos += nBytes;
4222 freeBytes -= nBytes;
4223
4224 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304225 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 sizeof(tot_bcn_ieLen));
4227 pos += sizeof(tot_bcn_ieLen);
4228 freeBytes -= sizeof(tot_bcn_ieLen);
4229
4230 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004231 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4233 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4234 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004235 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236 bcnRepBssInfo[i +
4237 lastSent].bcnReportFields.
4238 ChanNum,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004239 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 bcnRepBssInfo[i +
4241 lastSent].bcnReportFields.
4242 Spare,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004243 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 bcnRepBssInfo[i +
4245 lastSent].bcnReportFields.
4246 MeasDuration,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004247 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248 bcnRepBssInfo[i +
4249 lastSent].bcnReportFields.
4250 PhyType,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004251 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 bcnRepBssInfo[i +
4253 lastSent].bcnReportFields.
4254 RecvSigPower,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004255 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 bcnRepBssInfo[i +
4257 lastSent].bcnReportFields.
4258 ParentTsf,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004259 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 bcnRepBssInfo[i +
4261 lastSent].bcnReportFields.
4262 TargetTsf[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004263 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 bcnRepBssInfo[i +
4265 lastSent].bcnReportFields.
4266 TargetTsf[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004267 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 bcnRepBssInfo[i +
4269 lastSent].bcnReportFields.
4270 BcnInterval,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004271 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 bcnRepBssInfo[i +
4273 lastSent].bcnReportFields.
4274 CapabilityInfo,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004275 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 bcnRepBssInfo[i +
4277 lastSent].bcnReportFields.
4278 Bssid[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004279 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 bcnRepBssInfo[i +
4281 lastSent].bcnReportFields.
4282 Bssid[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004283 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 bcnRepBssInfo[i +
4285 lastSent].bcnReportFields.
4286 Bssid[2],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004287 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288 bcnRepBssInfo[i +
4289 lastSent].bcnReportFields.
4290 Bssid[3],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004291 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292 bcnRepBssInfo[i +
4293 lastSent].bcnReportFields.
4294 Bssid[4],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004295 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 bcnRepBssInfo[i +
4297 lastSent].bcnReportFields.
4298 Bssid[5]);
4299
4300 /* bcn report fields are copied */
4301 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004302 sizeof(roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303 bcnRepBssInfo[i +
4304 lastSent].
4305 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304306 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004307 (char *)&roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 pEseBcnReportRsp->bcnRepBssInfo[i +
4309 lastSent].
4310 bcnReportFields, len);
4311 pos += len;
4312 freeBytes -= len;
4313
4314 /* Add 1 byte of ie len */
4315 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004316 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304318 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 pos += sizeof(len);
4320 freeBytes -= sizeof(len);
4321
4322 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304323 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004324 (char *)roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325 pEseBcnReportRsp->bcnRepBssInfo[i +
4326 lastSent].
4327 pBuf, len);
4328 pos += len;
4329 freeBytes -= len;
4330 }
4331
4332 wrqu.data.pointer = buf;
4333 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4334
4335 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004336 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 buf);
4338 lastSent += sendBss;
4339 }
4340 }
4341}
4342
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004343#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344
4345/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304346 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
Jeff Johnsond377dce2017-10-04 10:32:42 -07004347 * @sta_ctx: Station Context
Komal Seelam98760ba2015-12-15 11:05:18 +05304348 *
4349 * API to check if the connection authentication type is 8021x_sha256.
4350 *
4351 * Return: bool
4352 */
4353#ifdef WLAN_FEATURE_11W
Jeff Johnson435e1b82017-10-07 14:13:10 -07004354static inline bool
4355hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304356{
4357 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004358 sta_ctx->conn_info.authType;
Komal Seelam98760ba2015-12-15 11:05:18 +05304359}
4360#else
Jeff Johnson435e1b82017-10-07 14:13:10 -07004361static inline bool
4362hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304363{
4364 return false;
4365}
4366#endif
4367
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304368/*
4369 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4370 * @adapter: Pointer to adapter context
4371 * @roam_info: Pointer to roam info
4372 *
4373 * Return: None
4374 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004375static void hdd_roam_channel_switch_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004376 struct csr_roam_info *roam_info)
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304377{
4378 struct hdd_chan_change_params chan_change;
4379 struct cfg80211_bss *bss;
4380 struct net_device *dev = adapter->dev;
4381 struct wireless_dev *wdev = dev->ieee80211_ptr;
4382 struct wiphy *wiphy = wdev->wiphy;
4383 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -07004384 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304385
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004386 hdd_debug("channel switch for session:%d to channel:%d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004387 adapter->session_id, roam_info->chan_info.chan_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304388
4389 chan_change.chan = roam_info->chan_info.chan_id;
4390 chan_change.chan_params.ch_width =
4391 roam_info->chan_info.ch_width;
4392 chan_change.chan_params.sec_ch_offset =
4393 roam_info->chan_info.sec_ch_offset;
4394 chan_change.chan_params.center_freq_seg0 =
4395 roam_info->chan_info.band_center_freq1;
4396 chan_change.chan_params.center_freq_seg1 =
4397 roam_info->chan_info.band_center_freq2;
4398
4399 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4400 if (NULL == bss)
4401 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4402 else
4403 cfg80211_put_bss(wiphy, bss);
4404
bings58ce8622017-07-10 15:55:36 +08004405 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4406 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304407 if (QDF_IS_STATUS_ERROR(status))
4408 hdd_err("channel change notification failed");
4409
Ganesh Kondabattini41f34782017-09-14 21:14:29 +05304410 hdd_debug("check for SAP restart");
4411 policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->hdd_psoc);
4412
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004413 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004414 adapter->session_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304415 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004416 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304417}
4418
Komal Seelam98760ba2015-12-15 11:05:18 +05304419/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 * hdd_sme_roam_callback() - hdd sme roam callback
4421 * @pContext: pointer to adapter context
Jeff Johnsonfd060852017-10-04 10:50:51 -07004422 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 * @roamId: roam id
4424 * @roamStatus: roam status
4425 * @roamResult: roam result
4426 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304427 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304429QDF_STATUS
Jeff Johnson172237b2017-11-07 15:32:59 -08004430hdd_sme_roam_callback(void *pContext, struct csr_roam_info *roam_info,
4431 uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4433{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304434 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnsonba388342017-10-02 13:31:01 -07004435 struct hdd_adapter *adapter = (struct hdd_adapter *) pContext;
Jeff Johnson2a722002017-09-30 20:02:35 -07004436 struct hdd_wext_state *pWextState = NULL;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004437 struct hdd_station_ctx *sta_ctx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304438 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304439 struct cfg80211_bss *bss_status;
Jeff Johnson49432062017-08-28 12:08:45 -07004440 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441
Abhinav Kumar5670d362018-01-16 17:31:54 +05304442 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4443 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
4444 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445
4446 /* Sanity check */
Jeff Johnsonba388342017-10-02 13:31:01 -07004447 if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004448 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304449 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 }
4451
Jeff Johnsonba388342017-10-02 13:31:01 -07004452 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004453 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonba388342017-10-02 13:31:01 -07004454 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304456 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4457 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4458 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004459 adapter->session_id, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304460
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 switch (roamStatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 /*
4463 * We did pre-auth,then we attempted a 11r or ese reassoc.
4464 * reassoc failed due to failure, timeout, reject from ap
4465 * in any case tell the OS, our carrier is off and mark
4466 * interface down.
4467 */
4468 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004469 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004470 roamStatus, roamResult, adapter->session_id);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304471 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004472 hdd_dis_connect_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 roamStatus, roamResult);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004474 sta_ctx->ft_carrier_on = false;
Jeff Johnson690fe952017-10-25 11:48:39 -07004475 sta_ctx->hdd_reassoc_scenario = false;
4476 hdd_debug("hdd_reassoc_scenario set to: %d, ReAssoc Failed, session: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004477 sta_ctx->hdd_reassoc_scenario, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 break;
4479
4480 case eCSR_ROAM_FT_START:
4481 /*
4482 * When we roam for ESE and 11r, we dont want the OS to be
4483 * informed that the link is down. So mark the link ready for
4484 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4485 * be received. Where in we will not mark the link down
4486 * Also we want to stop tx at this point when we will be
4487 * doing disassoc at this time. This saves 30-60 msec
4488 * after reassoc.
4489 */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304490 hdd_debug("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004491 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004492 hdd_napi_serialize(1);
Jeff Johnsonba388342017-10-02 13:31:01 -07004493 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304494 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004495 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07004496 status = hdd_roam_deregister_sta(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004497 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304498 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304499 qdf_ret_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004500 sta_ctx->ft_carrier_on = true;
Jeff Johnson690fe952017-10-25 11:48:39 -07004501 sta_ctx->hdd_reassoc_scenario = true;
4502 hdd_debug("hdd_reassoc_scenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004503 sta_ctx->hdd_reassoc_scenario, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004505 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004506 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004507 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004508 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304509 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
Jeff Johnsonba388342017-10-02 13:31:01 -07004510 adapter->roam_ho_fail = true;
Abhishek Singh533c9da2017-05-04 10:23:34 +05304511 else
Jeff Johnsonba388342017-10-02 13:31:01 -07004512 adapter->roam_ho_fail = false;
4513 complete(&adapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004514 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6598eea2017-07-06 19:26:19 -07004517 hdd_info("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004518 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304519 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 WLAN_CONTROL_PATH);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004521 if (sta_ctx->ft_carrier_on == false) {
Jeff Johnsonba388342017-10-02 13:31:01 -07004522 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 WLAN_NETIF_CARRIER_OFF,
4524 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526 break;
4527 case eCSR_ROAM_LOSTLINK:
4528 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004529 hdd_debug("Roaming started due to connection lost");
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304530 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004531 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304532 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 WLAN_CONTROL_PATH);
4534 break;
4535 }
4536 case eCSR_ROAM_DISASSOCIATED:
4537 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004538 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304539 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004540 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304541 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004542 adapter->roam_ho_fail = false;
4543 complete(&adapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 /* Call to clear any MC Addr List filter applied after
4546 * successful connection.
4547 */
Jeff Johnsonba388342017-10-02 13:31:01 -07004548 hdd_disable_and_flush_mc_addr_list(adapter,
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304549 pmo_peer_disconnect);
4550 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004551 hdd_dis_connect_handler(adapter, roam_info, roamId,
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304552 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 }
4554 break;
4555 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004556 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304557 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004558 hdd_dis_connect_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 roamStatus, roamResult);
4560 break;
4561 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004562 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 /*
4564 * To Do - address probable memory leak with WEP encryption upon
4565 * successful association.
4566 */
4567 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4568 /* Clear saved connection information in HDD */
4569 hdd_conn_remove_connect_info(
Jeff Johnsonba388342017-10-02 13:31:01 -07004570 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304572 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004573 hdd_association_completion_handler(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 roamId, roamStatus,
4575 roamResult);
4576#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07004577 if (roam_info)
4578 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579#endif
4580 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004581 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004582 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 case eCSR_ROAM_ASSOCIATION_FAILURE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004584 qdf_ret_status = hdd_association_completion_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004585 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 roamId,
4587 roamStatus,
4588 roamResult);
4589 break;
4590 case eCSR_ROAM_IBSS_IND:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004591 hdd_roam_ibss_indication_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 roamStatus, roamResult);
4593 break;
4594
4595 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304596 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07004597 roam_roam_connect_status_update_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004598 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 roamId,
4600 roamStatus,
4601 roamResult);
4602 break;
4603
4604 case eCSR_ROAM_MIC_ERROR_IND:
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07004605 hdd_roam_mic_error_indication_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 break;
4607
4608 case eCSR_ROAM_SET_KEY_COMPLETE:
4609 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304610 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004611 hdd_roam_set_key_complete_handler(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 roamId, roamStatus,
4613 roamResult);
4614 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Jeff Johnson690fe952017-10-25 11:48:39 -07004615 sta_ctx->hdd_reassoc_scenario = false;
4616 hdd_debug("hdd_reassoc_scenario set to: %d, set key complete, session: %d",
4617 sta_ctx->hdd_reassoc_scenario,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004618 adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 }
4620 }
4621#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07004622 if (roam_info != NULL)
4623 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624#endif
4625 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 case eCSR_ROAM_FT_RESPONSE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004628 hdd_send_ft_event(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 case eCSR_ROAM_PMK_NOTIFY:
Jeff Johnsond377dce2017-10-04 10:32:42 -07004632 if (eCSR_AUTH_TYPE_RSN == sta_ctx->conn_info.authType
4633 || hdd_is_8021x_sha256_auth_type(sta_ctx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304635 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 wlan_hdd_cfg80211_pmksa_candidate_notify(
Jeff Johnsonfd060852017-10-04 10:50:51 -07004637 adapter, roam_info, 1, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 }
4639 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640
4641#ifdef FEATURE_WLAN_LFR_METRICS
4642 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4643 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304644 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004645 wlan_hdd_cfg80211_roam_metrics_preauth(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004646 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304647 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 }
4649 break;
4650 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4651 /*
4652 * This event will notify pre-auth completion in case of success
4653 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304654 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004655 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004656 roam_info, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304657 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 }
4659 break;
4660 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4661 /*
4662 * This event will notify pre-auth completion incase of failure.
4663 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304664 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004665 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004666 roam_info, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304667 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 }
4669 break;
4670 case eCSR_ROAM_HANDOVER_SUCCESS:
4671 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004672 * It will be only invoked on success
4673 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304674 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004675 wlan_hdd_cfg80211_roam_metrics_handover(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004676 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304677 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 }
4679 break;
4680#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681#ifdef WLAN_FEATURE_11W
4682 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
Jeff Johnsonba388342017-10-02 13:31:01 -07004683 hdd_indicate_unprot_mgmt_frame(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004684 roam_info->nFrameLength,
4685 roam_info->pbFrames,
4686 roam_info->frameType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 break;
4688#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004689#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 case eCSR_ROAM_TSM_IE_IND:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004691 hdd_indicate_tsm_ie(adapter, roam_info->tsmIe.tsid,
4692 roam_info->tsmIe.state,
4693 roam_info->tsmIe.msmt_interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 break;
4695
4696 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4697 {
4698 if (eCSR_AUTH_TYPE_CCKM_WPA ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004699 sta_ctx->conn_info.authType
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 || eCSR_AUTH_TYPE_CCKM_RSN ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004701 sta_ctx->conn_info.authType) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004702 hdd_indicate_cckm_pre_auth(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 }
4704 break;
4705 }
4706
4707 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4708 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004709 hdd_indicate_ese_adj_ap_rep_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 break;
4711 }
4712
4713 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4714 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004715 hdd_indicate_ese_bcn_report_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 break;
4717 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004718#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304719 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004720 hdd_roam_channel_switch_handler(adapter, roam_info);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304721 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304722
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304723 case eCSR_ROAM_UPDATE_SCAN_RESULT:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004724 if ((NULL != roam_info) && (NULL != roam_info->pBssDesc)) {
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304725 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
Jeff Johnsonfd060852017-10-04 10:50:51 -07004726 adapter, roam_info->pBssDesc);
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304727 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004728 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304729 else
4730 cfg80211_put_bss(
4731#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
Jeff Johnsonba388342017-10-02 13:31:01 -07004732 (WLAN_HDD_GET_CTX(adapter))->wiphy,
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304733#endif
4734 bss_status);
4735 }
4736 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004737 case eCSR_ROAM_NDP_STATUS_UPDATE:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004738 hdd_ndp_event_handler(adapter, roam_info, roamId, roamStatus,
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004739 roamResult);
4740 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004741 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004742 hdd_debug("Process ROAM_START from firmware");
Jeff Johnsonba388342017-10-02 13:31:01 -07004743 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304744 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004745 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004746 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08004747 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004748 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004749 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004750 break;
4751 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004752 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004753 hdd_napi_serialize(0);
Jeff Johnsonba388342017-10-02 13:31:01 -07004754 wlan_hdd_netif_queue_control(adapter,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004755 WLAN_WAKE_ALL_NETIF_QUEUE,
4756 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08004757 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004758 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004759 adapter->roam_ho_fail = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004760 sta_ctx->ft_carrier_on = false;
Jeff Johnsonba388342017-10-02 13:31:01 -07004761 complete(&adapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004762 break;
4763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 default:
4765 break;
4766 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304767 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768}
4769
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304770#ifdef WLAN_FEATURE_FILS_SK
4771/**
4772 * hdd_translate_fils_rsn_to_csr_auth() - Translate FILS RSN to CSR auth type
4773 * @auth_suite: auth suite
4774 * @auth_type: pointer to eCsrAuthType
4775 *
4776 * Return: None
4777 */
4778static void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
4779 eCsrAuthType *auth_type)
4780{
4781 if (!memcmp(auth_suite, ccp_rsn_oui_0e, 4))
4782 *auth_type = eCSR_AUTH_TYPE_FILS_SHA256;
4783 else if (!memcmp(auth_suite, ccp_rsn_oui_0f, 4))
4784 *auth_type = eCSR_AUTH_TYPE_FILS_SHA384;
4785 else if (!memcmp(auth_suite, ccp_rsn_oui_10, 4))
4786 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA256;
4787 else if (!memcmp(auth_suite, ccp_rsn_oui_11, 4))
4788 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA384;
4789}
4790#else
4791static inline void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
4792 eCsrAuthType *auth_type)
4793{
4794}
4795#endif
4796
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05304797#ifdef WLAN_FEATURE_SAE
4798/**
4799 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
4800 * @auth_suite: auth suite
4801 * @auth_type: pointer to eCsrAuthType
4802 *
4803 * Return: None
4804 */
4805static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4806 eCsrAuthType *auth_type)
4807{
4808 if (qdf_mem_cmp(auth_suite, ccp_rsn_oui_80, 4) == 0)
4809 *auth_type = eCSR_AUTH_TYPE_SAE;
4810}
4811#else
4812static inline void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4813 eCsrAuthType *auth_type)
4814{
4815}
4816#endif
4817
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818/**
4819 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4820 * @auth_suite: auth suite
4821 *
4822 * Return: eCsrAuthType enumeration
4823 */
4824eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4825{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304826 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 /* is the auth type supported? */
4828 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4829 auth_type = eCSR_AUTH_TYPE_RSN;
4830 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
4831 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004832 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004833 /* Check for 11r FT Authentication with PSK */
4834 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
4835 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
4836 /* Check for 11R FT Authentication with 802.1X */
4837 auth_type = eCSR_AUTH_TYPE_FT_RSN;
4838 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839#ifdef FEATURE_WLAN_ESE
4840 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
4841 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4842 } else
4843#endif /* FEATURE_WLAN_ESE */
4844#ifdef WLAN_FEATURE_11W
4845 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
4846 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4847 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
4848 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05304849 } else if (memcmp(auth_suite, ccp_rsn_oui_18, 4) == 0) {
4850 auth_type = eCSR_AUTH_TYPE_OWE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 } else
4852#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +05304853 if (memcmp(auth_suite, ccp_rsn_oui_12, 4) == 0) {
4854 auth_type = eCSR_AUTH_TYPE_DPP_RSN;
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05304855 } else if (memcmp(auth_suite, ccp_rsn_oui_0b, 4) == 0) {
4856 /* Check for Suite B EAP 256 */
4857 auth_type = eCSR_AUTH_TYPE_SUITEB_EAP_SHA256;
4858 } else if (memcmp(auth_suite, ccp_rsn_oui_0c, 4) == 0) {
4859 /* Check for Suite B EAP 384 */
4860 auth_type = eCSR_AUTH_TYPE_SUITEB_EAP_SHA384;
Abhishek Singh02cb9e02017-08-30 17:39:50 +05304861 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304863 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05304864 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865 }
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304866 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004867 return auth_type;
4868}
4869
4870/**
4871 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
4872 * @auth_suite: auth suite
4873 *
4874 * Return: eCsrAuthType enumeration
4875 */
4876eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
4877{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304878 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004879 /* is the auth type supported? */
4880 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
4881 auth_type = eCSR_AUTH_TYPE_WPA;
4882 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
4883 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
4884 } else
4885#ifdef FEATURE_WLAN_ESE
4886 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
4887 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
4888 } else
4889#endif /* FEATURE_WLAN_ESE */
4890 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304891 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004893 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894 return auth_type;
4895}
4896
4897/**
4898 * hdd_translate_rsn_to_csr_encryption_type() -
4899 * Translate RSN to CSR encryption type
4900 * @cipher_suite: cipher suite
4901 *
4902 * Return: eCsrEncryptionType enumeration
4903 */
4904eCsrEncryptionType
4905hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
4906{
4907 eCsrEncryptionType cipher_type;
4908
4909 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
4910 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Mukul Sharma05504ac2017-06-08 12:35:53 +05304911 else if (memcmp(cipher_suite, ccp_rsn_oui09, 4) == 0)
4912 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP;
4913 else if (memcmp(cipher_suite, ccp_rsn_oui0a, 4) == 0)
4914 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP_256;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004915 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
4916 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
4917 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
4918 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
4919 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
4920 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4921 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
4922 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4923 else
4924 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4925
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004926 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 return cipher_type;
4928}
4929
4930/**
4931 * hdd_translate_wpa_to_csr_encryption_type() -
4932 * Translate WPA to CSR encryption type
4933 * @cipher_suite: cipher suite
4934 *
4935 * Return: eCsrEncryptionType enumeration
4936 */
4937eCsrEncryptionType
4938hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
4939{
4940 eCsrEncryptionType cipher_type;
4941
4942 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
4943 cipher_type = eCSR_ENCRYPT_TYPE_AES;
4944 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
4945 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
4946 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
4947 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
4948 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
4949 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4950 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
4951 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4952 else
4953 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4954
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004955 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956 return cipher_type;
4957}
4958
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304959#ifdef WLAN_FEATURE_FILS_SK
4960/*
4961 * hdd_is_fils_connection: API to determine if connection is FILS
4962 * @adapter: hdd adapter
4963 *
4964 * Return: true if fils connection else false
4965 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004966static inline bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304967{
Jeff Johnson2a722002017-09-30 20:02:35 -07004968 struct hdd_wext_state *wext_state =
4969 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304970
4971 if (wext_state->roamProfile.fils_con_info)
4972 return wext_state->roamProfile.
4973 fils_con_info->is_fils_connection;
Min Liuab6ed4f2018-01-09 13:13:57 +08004974
4975 return false;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304976}
4977#else
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004978static inline bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304979{
4980 return false;
4981}
4982#endif
4983
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984/**
4985 * hdd_process_genie() - process gen ie
Jeff Johnsonba388342017-10-02 13:31:01 -07004986 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 * @bssid: pointer to mac address
4988 * @pEncryptType: pointer to encryption type
4989 * @mcEncryptType: pointer to multicast encryption type
4990 * @pAuthType: pointer to auth type
4991 *
4992 * Return: 0 on success, error number otherwise
4993 */
Jeff Johnsonba388342017-10-02 13:31:01 -07004994static int32_t hdd_process_genie(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004995 u8 *bssid,
4996 eCsrEncryptionType *pEncryptType,
4997 eCsrEncryptionType *mcEncryptType,
4998 eCsrAuthType *pAuthType,
4999#ifdef WLAN_FEATURE_11W
5000 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5001#endif
5002 uint16_t gen_ie_len, uint8_t *gen_ie)
5003{
Jeff Johnsonba388342017-10-02 13:31:01 -07005004 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005 tDot11fIERSN dot11RSNIE;
5006 tDot11fIEWPA dot11WPAIE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007 uint8_t *pRsnIe;
5008 uint16_t RSNIeLen;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305009 uint32_t parse_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010
5011 /*
5012 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5013 * setting present flag to 0.
5014 */
5015 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5016 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5017
5018 /* Type check */
5019 if (gen_ie[0] == DOT11F_EID_RSN) {
5020 /* Validity checks */
5021 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5022 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005023 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005024 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005025 return -EINVAL;
5026 }
5027 /* Skip past the EID byte and length byte */
5028 pRsnIe = gen_ie + 2;
5029 RSNIeLen = gen_ie_len - 2;
5030 /* Unpack the RSN IE */
Abhishek Singh6454ad32017-12-20 10:42:21 +05305031 parse_status = sme_unpack_rsn_ie(halHandle, pRsnIe, RSNIeLen,
Abhishek Singh7dcb85b2017-12-27 15:15:01 +05305032 &dot11RSNIE, false);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305033 if (!DOT11F_SUCCEEDED(parse_status)) {
5034 hdd_err("Invalid RSN IE: parse status %d",
5035 parse_status);
5036 return -EINVAL;
5037 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005039 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005040 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005041 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005042 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005043 /* dot11RSNIE.akm_suite_count */
5044 /* Just translate the FIRST one */
5045 *pAuthType =
5046 hdd_translate_rsn_to_csr_auth_type(
5047 dot11RSNIE.akm_suites[0]);
5048 /* dot11RSNIE.pwise_cipher_suite_count */
5049 *pEncryptType =
5050 hdd_translate_rsn_to_csr_encryption_type(
5051 dot11RSNIE.pwise_cipher_suites[0]);
5052 /* dot11RSNIE.gp_cipher_suite_count */
5053 *mcEncryptType =
5054 hdd_translate_rsn_to_csr_encryption_type(
5055 dot11RSNIE.gp_cipher_suite);
5056#ifdef WLAN_FEATURE_11W
5057 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
Srinivas Girigowda6519b932017-08-03 14:10:57 -07005058 *pMfpCapable = csr_is_mfpc_capable(&dot11RSNIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005059#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5061 /* Validity checks */
5062 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5063 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005064 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005065 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005066 return -EINVAL;
5067 }
5068 /* Skip past the EID and length byte - and four byte WiFi OUI */
5069 pRsnIe = gen_ie + 2 + 4;
5070 RSNIeLen = gen_ie_len - (2 + 4);
5071 /* Unpack the WPA IE */
Abhishek Singh6454ad32017-12-20 10:42:21 +05305072 parse_status = dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305073 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305074 if (!DOT11F_SUCCEEDED(parse_status)) {
5075 hdd_err("Invalid WPA IE: parse status %d",
5076 parse_status);
5077 return -EINVAL;
5078 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005080 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005081 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005082 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005083 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 /* dot11WPAIE.auth_suite_count */
5085 /* Just translate the FIRST one */
5086 *pAuthType =
5087 hdd_translate_wpa_to_csr_auth_type(
5088 dot11WPAIE.auth_suites[0]);
5089 /* dot11WPAIE.unicast_cipher_count */
5090 *pEncryptType =
5091 hdd_translate_wpa_to_csr_encryption_type(
5092 dot11WPAIE.unicast_ciphers[0]);
5093 /* dot11WPAIE.unicast_cipher_count */
5094 *mcEncryptType =
5095 hdd_translate_wpa_to_csr_encryption_type(
5096 dot11WPAIE.multicast_cipher);
5097 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005098 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 return -EINVAL;
5100 }
5101 return 0;
5102}
5103
5104/**
Abhishek Singh6454ad32017-12-20 10:42:21 +05305105 * hdd_set_def_rsne_override() - set default encryption type and auth type
5106 * in profile.
5107 * @roam_profile: pointer to adapter
5108 * @auth_type: pointer to auth type
5109 *
5110 * Set default value of encryption type and auth type in profile to
5111 * search the AP using filter, as in force_rsne_override the RSNIE can be
5112 * currupt and we might not get the proper encryption type and auth type
5113 * while parsing the RSNIE.
5114 *
5115 * Return: void
5116 */
5117static void hdd_set_def_rsne_override(
5118 tCsrRoamProfile *roam_profile, eCsrAuthType *auth_type)
5119{
5120
5121 hdd_debug("Set def values in roam profile");
5122 roam_profile->MFPCapable = roam_profile->MFPEnabled;
5123 roam_profile->EncryptionType.numEntries = 2;
5124 roam_profile->mcEncryptionType.numEntries = 2;
5125 /* Use the cipher type in the RSN IE */
5126 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
5127 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
5128 roam_profile->mcEncryptionType.encryptionType[0] =
5129 eCSR_ENCRYPT_TYPE_AES;
5130 roam_profile->mcEncryptionType.encryptionType[1] =
5131 eCSR_ENCRYPT_TYPE_TKIP;
5132 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
5133}
5134
5135/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 * hdd_set_genie_to_csr() - set genie to csr
Jeff Johnsonba388342017-10-02 13:31:01 -07005137 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005138 * @RSNAuthType: pointer to auth type
5139 *
5140 * Return: 0 on success, error number otherwise
5141 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005142int hdd_set_genie_to_csr(struct hdd_adapter *adapter,
Jeff Johnson2a722002017-09-30 20:02:35 -07005143 eCsrAuthType *RSNAuthType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144{
Jeff Johnson2a722002017-09-30 20:02:35 -07005145 struct hdd_wext_state *pWextState =
Jeff Johnsonba388342017-10-02 13:31:01 -07005146 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 uint32_t status = 0;
5148 eCsrEncryptionType RSNEncryptType;
5149 eCsrEncryptionType mcRSNEncryptType;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305150 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151#ifdef WLAN_FEATURE_11W
5152 uint8_t RSNMfpRequired = 0;
5153 uint8_t RSNMfpCapable = 0;
5154#endif
5155 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5156 /* MAC address of assoc peer */
5157 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305158 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159 pWextState->roamProfile.BSSIDs.bssid,
5160 sizeof(bssid));
5161 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5162 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5163 /* continue */
5164 } else {
5165 return 0;
5166 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305167
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168 /* The actual processing may eventually be more extensive than this. */
5169 /* Right now, just consume any PMKIDs that are sent in by the app. */
Jeff Johnsonba388342017-10-02 13:31:01 -07005170 status = hdd_process_genie(adapter, bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 &RSNEncryptType,
5172 &mcRSNEncryptType, RSNAuthType,
5173#ifdef WLAN_FEATURE_11W
5174 &RSNMfpRequired, &RSNMfpCapable,
5175#endif
5176 pWextState->WPARSNIE[1] + 2,
5177 pWextState->WPARSNIE);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305178
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179 if (status == 0) {
5180 /*
5181 * Now copy over all the security attributes
5182 * you have parsed out.
5183 */
5184 pWextState->roamProfile.EncryptionType.numEntries = 1;
5185 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5186
Jeff Johnson435e1b82017-10-07 14:13:10 -07005187 /* Use the cipher type in the RSN IE */
5188 pWextState->roamProfile.EncryptionType.encryptionType[0] =
5189 RSNEncryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5191 mcRSNEncryptType;
5192
Jeff Johnsonba388342017-10-02 13:31:01 -07005193 if ((QDF_IBSS_MODE == adapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05305195 (eCSR_ENCRYPT_TYPE_AES_GCMP == mcRSNEncryptType) ||
5196 (eCSR_ENCRYPT_TYPE_AES_GCMP_256 == mcRSNEncryptType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5198 /*
5199 * For wpa none supplicant sends the WPA IE with unicast
5200 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5201 * multicast cipher as either AES/TKIP based on group
5202 * cipher configuration mentioned in the
5203 * wpa_supplicant.conf.
5204 */
5205
5206 /* Set the unicast cipher same as multicast cipher */
5207 pWextState->roamProfile.EncryptionType.encryptionType[0]
5208 = mcRSNEncryptType;
5209 }
5210#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005211 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005212 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5214 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5215#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005216 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005217 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305219
5220 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5221 if (hdd_ctx->force_rsne_override &&
5222 (pWextState->WPARSNIE[0] == DOT11F_EID_RSN)) {
5223 hdd_warn("Test mode enabled set def Auth and enc type. RSN IE passed in connect req: ");
5224 qdf_trace_hex_dump(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
5225 pWextState->roamProfile.pRSNReqIE,
5226 pWextState->roamProfile.nRSNReqIELength);
5227
5228 pWextState->roamProfile.force_rsne_override = true;
5229 /* If parsing failed set the def value for the roam profile */
5230 if (status)
5231 hdd_set_def_rsne_override(&pWextState->roamProfile,
5232 RSNAuthType);
5233 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 return 0;
5235}
5236
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305237#ifdef WLAN_FEATURE_FILS_SK
5238/**
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305239 * hdd_check_fils_rsn_n_set_auth_type() - This API checks whether a give
5240 * auth type is fils if yes, sets it in profile.
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305241 * @rsn_auth_type: auth type
5242 *
5243 * Return: true if FILS auth else false
5244 */
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305245static bool hdd_check_fils_rsn_n_set_auth_type(tCsrRoamProfile *roam_profile,
5246 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305247{
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305248 bool is_fils_rsn = false;
5249
5250 if (!roam_profile->fils_con_info)
5251 return false;
5252
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305253 if ((rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA256) ||
5254 (rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA384) ||
5255 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA256) ||
5256 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA384))
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305257 is_fils_rsn = true;
5258 if (is_fils_rsn)
5259 roam_profile->fils_con_info->akm_type = rsn_auth_type;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305260
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305261 return is_fils_rsn;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305262}
5263#else
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305264static bool hdd_check_fils_rsn_n_set_auth_type(tCsrRoamProfile *roam_profile,
5265 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305266{
5267 return false;
5268}
5269#endif
5270
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005271/**
5272 * hdd_set_csr_auth_type() - set csr auth type
Jeff Johnsonba388342017-10-02 13:31:01 -07005273 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005274 * @RSNAuthType: auth type
5275 *
5276 * Return: 0 on success, error number otherwise
5277 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005278int hdd_set_csr_auth_type(struct hdd_adapter *adapter,
Jeff Johnson2a722002017-09-30 20:02:35 -07005279 eCsrAuthType RSNAuthType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280{
Jeff Johnson2a722002017-09-30 20:02:35 -07005281 struct hdd_wext_state *pWextState =
Jeff Johnsonba388342017-10-02 13:31:01 -07005282 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005283 tCsrRoamProfile *roam_profile = &(pWextState->roamProfile);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005284 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07005285 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005287 roam_profile->AuthType.numEntries = 1;
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305288 hdd_debug("authType = %d RSNAuthType %d wpa_versions %d",
5289 sta_ctx->conn_info.authType, RSNAuthType,
5290 sta_ctx->wpa_versions);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291
Jeff Johnsond377dce2017-10-04 10:32:42 -07005292 switch (sta_ctx->conn_info.authType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5294#ifdef FEATURE_WLAN_ESE
5295 case eCSR_AUTH_TYPE_CCKM_WPA:
5296 case eCSR_AUTH_TYPE_CCKM_RSN:
5297#endif
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005298 if (!sta_ctx->wpa_versions) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005300 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301 eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005302 } else if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303
5304#ifdef FEATURE_WLAN_ESE
5305 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5306 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5307 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005308 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005309 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 eCSR_AUTH_TYPE_CCKM_WPA;
5311 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005312 hdd_debug("Last chance to set authType to CCKM WPA.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005313 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 eCSR_AUTH_TYPE_CCKM_WPA;
5315 } else
5316#endif
5317 if ((pWextState->
5318 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5319 == IW_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005320 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 eCSR_AUTH_TYPE_WPA;
5322 } else
5323 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5324 == IW_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005325 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 eCSR_AUTH_TYPE_WPA_PSK;
5327 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005328 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005329 eCSR_AUTH_TYPE_WPA_NONE;
5330 }
5331 }
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005332 if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_2) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333#ifdef FEATURE_WLAN_ESE
5334 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5335 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5336 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005337 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005338 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339 eCSR_AUTH_TYPE_CCKM_RSN;
5340 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005341 hdd_debug("Last chance to set authType to CCKM RSN.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005342 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 eCSR_AUTH_TYPE_CCKM_RSN;
5344 } else
5345#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +05305346 if (RSNAuthType == eCSR_AUTH_TYPE_DPP_RSN) {
5347 roam_profile->AuthType.authType[0] =
5348 eCSR_AUTH_TYPE_DPP_RSN;
5349 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005350 ((pWextState->
5351 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5352 == IW_AUTH_KEY_MGMT_802_1X)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005353 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 eCSR_AUTH_TYPE_FT_RSN;
5355 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5356 &&
5357 ((pWextState->
5358 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5359 == IW_AUTH_KEY_MGMT_PSK)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005360 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005361 eCSR_AUTH_TYPE_FT_RSN_PSK;
5362 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005363
5364#ifdef WLAN_FEATURE_11W
5365 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005366 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005367 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5368 } else if (RSNAuthType ==
5369 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005370 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005371 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5372 } else
5373#endif
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005374 if (hdd_check_fils_rsn_n_set_auth_type(roam_profile,
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305375 RSNAuthType)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005376 roam_profile->AuthType.authType[0] =
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305377 RSNAuthType;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05305378 hdd_debug("updated profile authtype as %d",
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305379 RSNAuthType);
5380
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305381 } else if ((RSNAuthType == eCSR_AUTH_TYPE_OWE) &&
5382 ((pWextState->
5383 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5384 == IW_AUTH_KEY_MGMT_802_1X)) {
5385 /* OWE case */
5386 roam_profile->AuthType.authType[0] =
5387 eCSR_AUTH_TYPE_OWE;
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305388 } else if ((RSNAuthType ==
5389 eCSR_AUTH_TYPE_SUITEB_EAP_SHA256) &&
5390 ((pWextState->
5391 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5392 == IW_AUTH_KEY_MGMT_802_1X)) {
5393 /* Suite B EAP SHA 256 */
5394 roam_profile->AuthType.authType[0] =
5395 eCSR_AUTH_TYPE_SUITEB_EAP_SHA256;
5396 } else if ((RSNAuthType ==
5397 eCSR_AUTH_TYPE_SUITEB_EAP_SHA384) &&
5398 ((pWextState->
5399 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5400 == IW_AUTH_KEY_MGMT_802_1X)) {
5401 /* Suite B EAP SHA 384 */
5402 roam_profile->AuthType.authType[0] =
5403 eCSR_AUTH_TYPE_SUITEB_EAP_SHA384;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305404 } else if ((pWextState->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005405 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5406 == IW_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005407 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 eCSR_AUTH_TYPE_RSN;
5409 } else
5410 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5411 == IW_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005412 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 eCSR_AUTH_TYPE_RSN_PSK;
5414 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005415 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 eCSR_AUTH_TYPE_UNKNOWN;
5417 }
5418 }
5419 break;
5420
5421 case eCSR_AUTH_TYPE_SHARED_KEY:
5422
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005423 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305425
5426 case eCSR_AUTH_TYPE_SAE:
5427 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5428 break;
5429
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 default:
5431
5432#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005433 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005434#endif /* FEATURE_WLAN_ESE */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005435 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436 break;
5437 }
5438
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005439 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005440 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442 return 0;
5443}