blob: f0cb0d7f704552f3f16a587119e3d6b4d2812021 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302 * Copyright (c) 2012-2017 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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
69/* These are needed to recognize WPA and RSN suite types */
70#define HDD_WPA_OUI_SIZE 4
71#define HDD_RSN_OUI_SIZE 4
72uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
73uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
74uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
75uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
76uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
77uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
78
79#ifdef FEATURE_WLAN_ESE
80/* CCKM */
81uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
82/* CCKM */
83uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
84#endif /* FEATURE_WLAN_ESE */
85
86/* group cipher */
87uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
88
89/* WEP-40 or RSN */
90uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
91
92/* TKIP or RSN-PSK */
93uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
94
95/* Reserved */
96uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
97
98/* AES-CCMP */
99uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
100
101/* WEP-104 */
102uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
103
104#ifdef WLAN_FEATURE_11W
105/* RSN-PSK-SHA256 */
106uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
107
108/* RSN-8021X-SHA256 */
109uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
110#endif
111
Mukul Sharma05504ac2017-06-08 12:35:53 +0530112/* AES-GCMP-128 */
113uint8_t ccp_rsn_oui09[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x08 };
114
115/* AES-GCMP-256 */
116uint8_t ccp_rsn_oui0a[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x09 };
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +0530117#ifdef WLAN_FEATURE_FILS_SK
118uint8_t ccp_rsn_oui_0e[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0E};
119uint8_t ccp_rsn_oui_0f[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0F};
120uint8_t ccp_rsn_oui_10[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x10};
121uint8_t ccp_rsn_oui_11[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x11};
122#endif
Mukul Sharma05504ac2017-06-08 12:35:53 +0530123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124/* Offset where the EID-Len-IE, start. */
125#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
126#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127
128#define BEACON_FRAME_IES_OFFSET 12
129#define HDD_PEER_AUTHORIZE_WAIT 10
130
131/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700132 * beacon_filter_table - table of IEs used for beacon filtering
133 */
134static const int beacon_filter_table[] = {
135 SIR_MAC_DS_PARAM_SET_EID,
136 SIR_MAC_ERP_INFO_EID,
137 SIR_MAC_EDCA_PARAM_SET_EID,
138 SIR_MAC_QOS_CAPABILITY_EID,
139 SIR_MAC_HT_INFO_EID,
140 SIR_MAC_VHT_OPMODE_EID,
141 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700142#ifdef WLAN_FEATURE_11AX_BSS_COLOR
143 /*
144 * EID: 221 vendor IE is being used temporarily by 11AX
145 * bss-color-change IE till it gets any fixed number. This
146 * vendor EID needs to be replaced with bss-color-change IE
147 * number.
148 */
149 SIR_MAC_EID_VENDOR,
150#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700151};
152
153/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 * hdd_conn_set_authenticated() - set authentication state
155 * @pAdapter: pointer to the adapter
156 * @authState: authentication state
157 *
158 * This function updates the global HDD station context
159 * authentication state.
160 *
161 * Return: none
162 */
163static void
164hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
165{
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700166 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson49432062017-08-28 12:08:45 -0700167 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168
169 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700170 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700171 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 pHddStaCtx->conn_info.uIsAuthenticated = authState;
173
174 /* Check is pending ROC request or not when auth state changed */
175 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
176}
177
178/**
179 * hdd_conn_set_connection_state() - set connection state
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700180 * @adapter: pointer to the adapter
181 * @conn_state: connection state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 *
183 * This function updates the global HDD station context connection state.
184 *
185 * Return: none
186 */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700187void hdd_conn_set_connection_state(hdd_adapter_t *adapter,
188 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189{
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700190 struct hdd_station_ctx *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson49432062017-08-28 12:08:45 -0700191 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192
193 /* save the new connection state */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700194 hdd_debug("%pS Changed conn state from old:%d to new:%d for dev %s",
195 (void *)_RET_IP_, hdd_sta_ctx->conn_info.connState,
196 conn_state, adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800197
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700198 hdd_tsf_notify_wlan_state_change(adapter,
199 hdd_sta_ctx->conn_info.connState,
200 conn_state);
201 hdd_sta_ctx->conn_info.connState = conn_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700203 schedule_delayed_work(&hdd_ctx->roc_req_work, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204}
205
206/**
207 * hdd_conn_get_connection_state() - get connection state
208 * @pAdapter: pointer to the adapter
209 * @pConnState: pointer to connection state
210 *
211 * This function updates the global HDD station context connection state.
212 *
213 * Return: true if (Infra Associated or IBSS Connected)
214 * and sets output parameter pConnState;
215 * false otherwise
216 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700217static inline bool hdd_conn_get_connection_state(struct hdd_station_ctx *pHddStaCtx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 eConnectionState *pConnState)
219{
220 bool fConnected = false;
221 eConnectionState connState;
222
223 /* get the connection state. */
224 connState = pHddStaCtx->conn_info.connState;
225
226 if (eConnectionState_Associated == connState ||
227 eConnectionState_IbssConnected == connState ||
228 eConnectionState_IbssDisconnected == connState) {
229 fConnected = true;
230 }
231
232 if (pConnState)
233 *pConnState = connState;
234
235 return fConnected;
236}
237
238/**
239 * hdd_is_connecting() - Function to check connection progress
240 * @hdd_sta_ctx: pointer to global HDD Station context
241 *
242 * Return: true if connecting, false otherwise
243 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700244bool hdd_is_connecting(struct hdd_station_ctx *hdd_sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245{
246 return hdd_sta_ctx->conn_info.connState ==
247 eConnectionState_Connecting;
248}
249
250/**
251 * hdd_conn_is_connected() - Function to check connection status
252 * @pHddStaCtx: pointer to global HDD Station context
253 *
254 * Return: false if any errors encountered, true otherwise
255 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700256bool hdd_conn_is_connected(struct hdd_station_ctx *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257{
258 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
259}
260
261/**
262 * hdd_conn_get_connected_band() - get current connection radio band
263 * @pHddStaCtx: pointer to global HDD Station context
264 *
265 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
266 * eCSR_BAND_ALL if not connected
267 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700268enum band_info hdd_conn_get_connected_band(struct hdd_station_ctx *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269{
270 uint8_t staChannel = 0;
271
272 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
273 staChannel = pHddStaCtx->conn_info.operationChannel;
274
275 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700276 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700278 return BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 else /* If station is not connected return as eCSR_BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700280 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281}
282
283/**
284 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
285 * @pHddStaCtx: pointer to global HDD Station context
286 * @pConnectedCipherAlgo: pointer to connected cipher algo
287 *
288 * Return: false if any errors encountered, true otherwise
289 */
290static inline bool
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700291hdd_conn_get_connected_cipher_algo(struct hdd_station_ctx *pHddStaCtx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 eCsrEncryptionType *pConnectedCipherAlgo)
293{
294 bool fConnected = false;
295
296 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
297
298 if (pConnectedCipherAlgo)
299 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
300
301 return fConnected;
302}
303
304/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700305 * hdd_remove_beacon_filter() - remove beacon filter
306 * @adapter: Pointer to the hdd adapter
307 *
308 * Return: 0 on success and errno on failure
309 */
310static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
311{
312 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700313 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700314
315 status = sme_remove_beacon_filter(hdd_ctx->hHal,
316 adapter->sessionId);
317 if (!QDF_IS_STATUS_SUCCESS(status)) {
318 hdd_err("sme_remove_beacon_filter() failed");
319 return -EFAULT;
320 }
321
322 return 0;
323}
324
325/**
326 * hdd_add_beacon_filter() - add beacon filter
327 * @adapter: Pointer to the hdd adapter
328 *
329 * Return: 0 on success and errno on failure
330 */
331static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
332{
333 int i;
334 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
335 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700336 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700337
338 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530339 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700340 (unsigned long int *)ie_map);
341
342 status = sme_add_beacon_filter(hdd_ctx->hHal,
343 adapter->sessionId, ie_map);
344 if (!QDF_IS_STATUS_SUCCESS(status)) {
345 hdd_err("sme_add_beacon_filter() failed");
346 return -EFAULT;
347 }
348 return 0;
349}
350
351/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530352 * hdd_copy_vht_caps()- copy vht caps info from roam info to
353 * hdd station context.
354 * @hdd_sta_ctx: pointer to hdd station context
355 * @roam_info: pointer to roam info
356 *
357 * Return: None
358 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700359static void hdd_copy_ht_caps(struct hdd_station_ctx *hdd_sta_ctx,
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530360 tCsrRoamInfo *roam_info)
361{
362 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
363 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
364 uint32_t i, temp_ht_cap;
365
366 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
367
368 if (roam_ht_cap->advCodingCap)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
370 if (roam_ht_cap->supportedChannelWidthSet)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
372 temp_ht_cap = roam_ht_cap->mimoPowerSave &
373 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
374 if (temp_ht_cap)
375 hdd_ht_cap->cap_info |=
376 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
377 if (roam_ht_cap->greenField)
378 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
379 if (roam_ht_cap->shortGI20MHz)
380 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
381 if (roam_ht_cap->shortGI40MHz)
382 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
383 if (roam_ht_cap->txSTBC)
384 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
385 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
386 IEEE80211_HT_CAP_RX_STBC_SHIFT);
387 if (temp_ht_cap)
388 hdd_ht_cap->cap_info |=
389 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
390 if (roam_ht_cap->delayedBA)
391 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
392 if (roam_ht_cap->maximalAMSDUsize)
393 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
394 if (roam_ht_cap->dsssCckMode40MHz)
395 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
396 if (roam_ht_cap->psmp)
397 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
398 if (roam_ht_cap->stbcControlFrame)
399 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
400 if (roam_ht_cap->lsigTXOPProtection)
401 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
402
403 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
404 if (roam_ht_cap->maxRxAMPDUFactor)
405 hdd_ht_cap->ampdu_params_info |=
406 IEEE80211_HT_AMPDU_PARM_FACTOR;
407 temp_ht_cap = roam_ht_cap->mpduDensity &
408 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
409 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
410 if (temp_ht_cap)
411 hdd_ht_cap->ampdu_params_info |=
412 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
413
414 /* 802.11n HT extended capabilities masks */
415 if (roam_ht_cap->pco)
416 hdd_ht_cap->extended_ht_cap_info |=
417 IEEE80211_HT_EXT_CAP_PCO;
418 temp_ht_cap = roam_ht_cap->transitionTime &
419 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
420 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
421 if (temp_ht_cap)
422 hdd_ht_cap->extended_ht_cap_info |=
423 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
424 temp_ht_cap = roam_ht_cap->mcsFeedback &
425 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
426 if (temp_ht_cap)
427 hdd_ht_cap->extended_ht_cap_info |=
428 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
429
430 /* tx_bf_cap_info capabilities */
431 if (roam_ht_cap->txBF)
432 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
433 if (roam_ht_cap->rxStaggeredSounding)
434 hdd_ht_cap->tx_BF_cap_info |=
435 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
436 if (roam_ht_cap->txStaggeredSounding)
437 hdd_ht_cap->tx_BF_cap_info |=
438 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
439 if (roam_ht_cap->rxZLF)
440 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
441 if (roam_ht_cap->txZLF)
442 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
443 if (roam_ht_cap->implicitTxBF)
444 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
445 temp_ht_cap = roam_ht_cap->calibration &
446 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
447 if (temp_ht_cap)
448 hdd_ht_cap->tx_BF_cap_info |=
449 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
450 if (roam_ht_cap->explicitCSITxBF)
451 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
452 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
453 hdd_ht_cap->tx_BF_cap_info |=
454 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
455 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
456 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
457 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
458 if (temp_ht_cap)
459 hdd_ht_cap->tx_BF_cap_info |=
460 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
461 temp_ht_cap =
462 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
463 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
464 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
465 if (temp_ht_cap)
466 hdd_ht_cap->tx_BF_cap_info |=
467 temp_ht_cap <<
468 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
469 temp_ht_cap =
470 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
471 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
472 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
473 if (temp_ht_cap)
474 hdd_ht_cap->tx_BF_cap_info |=
475 temp_ht_cap <<
476 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
477 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
478 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
479 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
480 if (temp_ht_cap)
481 hdd_ht_cap->tx_BF_cap_info |=
482 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
483 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
484 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
485 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
486 if (temp_ht_cap)
487 hdd_ht_cap->tx_BF_cap_info |=
488 temp_ht_cap <<
489 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
490 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
491 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
492 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
493 if (temp_ht_cap)
494 hdd_ht_cap->tx_BF_cap_info |=
495 temp_ht_cap <<
496 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
497
498 /* antenna selection */
499 if (roam_ht_cap->antennaSelection)
500 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
501 if (roam_ht_cap->explicitCSIFeedbackTx)
502 hdd_ht_cap->antenna_selection_info |=
503 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
504 if (roam_ht_cap->antennaIndicesFeedbackTx)
505 hdd_ht_cap->antenna_selection_info |=
506 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
507 if (roam_ht_cap->explicitCSIFeedback)
508 hdd_ht_cap->antenna_selection_info |=
509 ANTENNA_SEL_INFO_EXP_CSI_FB;
510 if (roam_ht_cap->antennaIndicesFeedback)
511 hdd_ht_cap->antenna_selection_info |=
512 ANTENNA_SEL_INFO_ANT_ID_FB;
513 if (roam_ht_cap->rxAS)
514 hdd_ht_cap->antenna_selection_info |=
515 ANTENNA_SEL_INFO_RX_AS;
516 if (roam_ht_cap->txSoundingPPDUs)
517 hdd_ht_cap->antenna_selection_info |=
518 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
519
520 /* mcs data rate */
521 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
522 hdd_ht_cap->mcs.rx_mask[i] =
523 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800524 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530525 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
526 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800527 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530528 roam_ht_cap->supportedMCSSet[12];
529}
530
531#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
532#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
533#define VHT_CAP_RXSTBC_MASK_SHIFT 8
534#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
535#define VHT_CAP_BEAMFORMEE_STS_MASK \
536 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
537#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
538#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
539 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
540#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
541#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
542 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
543#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
544
545/**
546 * hdd_copy_ht_caps()- copy ht caps info from roam info to
547 * hdd station context.
548 * @hdd_sta_ctx: pointer to hdd station context
549 * @roam_info: pointer to roam info
550 *
551 * Return: None
552 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700553static void hdd_copy_vht_caps(struct hdd_station_ctx *hdd_sta_ctx,
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530554 tCsrRoamInfo *roam_info)
555{
556 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
557 struct ieee80211_vht_cap *hdd_vht_cap =
558 &hdd_sta_ctx->conn_info.vht_caps;
559 uint32_t temp_vht_cap;
560
561 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
562
563 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
564 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
565 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
566 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
567 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800568 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530569 if (roam_vht_cap->supportedChannelWidthSet &
570 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
571 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
572 hdd_vht_cap->vht_cap_info |=
573 temp_vht_cap <<
574 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
575 if (roam_vht_cap->supportedChannelWidthSet &
576 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
577 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
578 hdd_vht_cap->vht_cap_info |=
579 temp_vht_cap <<
580 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800581 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530582 if (roam_vht_cap->ldpcCodingCap)
583 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
584 if (roam_vht_cap->shortGI80MHz)
585 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
586 if (roam_vht_cap->shortGI160and80plus80MHz)
587 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
588 if (roam_vht_cap->txSTBC)
589 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
590 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
591 VHT_CAP_RXSTBC_MASK_SHIFT);
592 if (temp_vht_cap)
593 hdd_vht_cap->vht_cap_info |=
594 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
595 if (roam_vht_cap->suBeamFormerCap)
596 hdd_vht_cap->vht_cap_info |=
597 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
598 if (roam_vht_cap->suBeamformeeCap)
599 hdd_vht_cap->vht_cap_info |=
600 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
601 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
602 (VHT_CAP_BEAMFORMEE_STS_MASK);
603 if (temp_vht_cap)
604 hdd_vht_cap->vht_cap_info |=
605 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
606 temp_vht_cap = roam_vht_cap->numSoundingDim &
607 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
608 if (temp_vht_cap)
609 hdd_vht_cap->vht_cap_info |=
610 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
611 if (roam_vht_cap->muBeamformerCap)
612 hdd_vht_cap->vht_cap_info |=
613 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
614 if (roam_vht_cap->muBeamformeeCap)
615 hdd_vht_cap->vht_cap_info |=
616 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
617 if (roam_vht_cap->vhtTXOPPS)
618 hdd_vht_cap->vht_cap_info |=
619 IEEE80211_VHT_CAP_VHT_TXOP_PS;
620 if (roam_vht_cap->htcVHTCap)
621 hdd_vht_cap->vht_cap_info |=
622 IEEE80211_VHT_CAP_HTC_VHT;
623 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
624 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
625 if (temp_vht_cap)
626 hdd_vht_cap->vht_cap_info |=
627 temp_vht_cap <<
628 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
629 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
630 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
631 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
632 if (temp_vht_cap)
633 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
634 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
635 if (roam_vht_cap->rxAntPattern)
636 hdd_vht_cap->vht_cap_info |=
637 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
638 if (roam_vht_cap->txAntPattern)
639 hdd_vht_cap->vht_cap_info |=
640 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
641 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
642 hdd_vht_cap->supp_mcs.rx_highest =
643 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
644 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
645 hdd_vht_cap->supp_mcs.tx_highest =
646 ((uint16_t)roam_vht_cap->txSupDataRate);
647}
648
649/* ht param */
650#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
651#define HT_PARAM_SERVICE_INT_GRAN 0xe0
652#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
653
654/* operatinon mode */
655#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
656
657/* stbc_param */
658#define HT_STBC_PARAM_MCS 0x007f
659
660/**
661 * hdd_copy_ht_operation()- copy HT operation element from roam info to
662 * hdd station context.
663 * @hdd_sta_ctx: pointer to hdd station context
664 * @roam_info: pointer to roam info
665 *
666 * Return: None
667 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700668static void hdd_copy_ht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530669 tCsrRoamInfo *roam_info)
670{
671 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
672 struct ieee80211_ht_operation *hdd_ht_ops =
673 &hdd_sta_ctx->conn_info.ht_operation;
674 uint32_t i, temp_ht_ops;
675
676 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
677
678 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
679
680 /* HT_PARAMS */
681 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
682 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
683 if (temp_ht_ops)
684 hdd_ht_ops->ht_param |= temp_ht_ops;
685 else
686 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
687 if (roam_ht_ops->recommendedTxWidthSet)
688 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
689 if (roam_ht_ops->rifsMode)
690 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
691 if (roam_ht_ops->controlledAccessOnly)
692 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
693 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
694 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
695 if (temp_ht_ops)
696 hdd_ht_ops->ht_param |= temp_ht_ops <<
697 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
698
699 /* operation mode */
700 temp_ht_ops = roam_ht_ops->opMode &
701 IEEE80211_HT_OP_MODE_PROTECTION;
702 switch (temp_ht_ops) {
703 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
704 hdd_ht_ops->operation_mode |=
705 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
706 break;
707 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
708 hdd_ht_ops->operation_mode |=
709 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
710 break;
711 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
712 hdd_ht_ops->operation_mode |=
713 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
714 break;
715 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
716 default:
717 hdd_ht_ops->operation_mode |=
718 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
719 }
720 if (roam_ht_ops->nonGFDevicesPresent)
721 hdd_ht_ops->operation_mode |=
722 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
723 if (roam_ht_ops->transmitBurstLimit)
724 hdd_ht_ops->operation_mode |=
725 HT_OP_MODE_TX_BURST_LIMIT;
726 if (roam_ht_ops->obssNonHTStaPresent)
727 hdd_ht_ops->operation_mode |=
728 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
729
730 /* stbc_param */
731 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
732 HT_STBC_PARAM_MCS;
733 if (temp_ht_ops)
734 hdd_ht_ops->stbc_param |= temp_ht_ops;
735 if (roam_ht_ops->dualCTSProtection)
736 hdd_ht_ops->stbc_param |=
737 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
738 if (roam_ht_ops->secondaryBeacon)
739 hdd_ht_ops->stbc_param |=
740 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
741 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
742 hdd_ht_ops->stbc_param |=
743 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
744 if (roam_ht_ops->pcoActive)
745 hdd_ht_ops->stbc_param |=
746 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
747 if (roam_ht_ops->pcoPhase)
748 hdd_ht_ops->stbc_param |=
749 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
750
751 /* basic MCs set */
752 for (i = 0; i < 16; ++i)
753 hdd_ht_ops->basic_set[i] =
754 roam_ht_ops->basicMCSSet[i];
755}
756
Dustin Brown8aef46d2017-08-10 15:44:50 -0700757#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
758static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
759 tDot11fIEVHTOperation *roam_ops)
760{
761 ieee_ops->center_freq_seg0_idx = roam_ops->chanCenterFreqSeg1;
762 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg2;
763}
764#else
765static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
766 tDot11fIEVHTOperation *roam_ops)
767{
768 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg1;
769 ieee_ops->center_freq_seg2_idx = roam_ops->chanCenterFreqSeg2;
770}
771#endif /* KERNEL_VERSION(4, 12, 0) */
772
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530773/**
774 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
775 * hdd station context.
776 * @hdd_sta_ctx: pointer to hdd station context
777 * @roam_info: pointer to roam info
778 *
779 * Return: None
780 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700781static void hdd_copy_vht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530782 tCsrRoamInfo *roam_info)
783{
784 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
785 struct ieee80211_vht_operation *hdd_vht_ops =
786 &hdd_sta_ctx->conn_info.vht_operation;
787
788 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
789
790 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
Dustin Brown8aef46d2017-08-10 15:44:50 -0700791 hdd_copy_vht_center_freq(hdd_vht_ops, roam_vht_ops);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530792 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
793}
794
795
796/**
797 * hdd_save_bss_info() - save connection info in hdd sta ctx
798 * @adapter: Pointer to adapter
799 * @roam_info: pointer to roam info
800 *
801 * Return: None
802 */
803static void hdd_save_bss_info(hdd_adapter_t *adapter,
804 tCsrRoamInfo *roam_info)
805{
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700806 struct hdd_station_ctx *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530807
808 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
809 hdd_sta_ctx->conn_info.operationChannel);
810 if (roam_info->vht_caps.present) {
811 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
812 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
813 } else {
814 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
815 }
816 if (roam_info->ht_caps.present) {
817 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
818 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
819 } else {
820 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
821 }
822 if (roam_info->reassoc)
823 hdd_sta_ctx->conn_info.roam_count++;
824 if (roam_info->hs20vendor_ie.present) {
825 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
826 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
827 &roam_info->hs20vendor_ie,
828 sizeof(roam_info->hs20vendor_ie));
829 } else {
830 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
831 }
832 if (roam_info->ht_operation.present) {
833 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
834 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
835 } else {
836 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
837 }
838 if (roam_info->vht_operation.present) {
839 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
840 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
841 } else {
842 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
843 }
844}
845
846/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 * hdd_conn_save_connect_info() - save current connection information
848 * @pAdapter: pointer to adapter
849 * @pRoamInfo: pointer to roam info
850 * @eBssType: bss type
851 *
852 * Return: none
853 */
854static void
855hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
856 eCsrRoamBssType eBssType)
857{
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700858 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
860
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530861 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862
863 if (pRoamInfo) {
864 /* Save the BSSID for the connection */
865 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530866 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530867 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 &pRoamInfo->bssid);
869
870 /*
871 * Save the Station ID for this station from
872 * the 'Roam Info'. For IBSS mode, staId is
873 * assigned in NEW_PEER_IND. For reassoc,
874 * the staID doesn't change and it may be invalid
875 * in this structure so no change here.
876 */
877 if (!pRoamInfo->fReassocReq) {
878 pHddStaCtx->conn_info.staId[0] =
879 pRoamInfo->staId;
880 }
881 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530882 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 &pRoamInfo->bssid);
884 } else {
885 /*
886 * can't happen. We need a valid IBSS or Infra setting
887 * in the BSSDescription or we can't function.
888 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530889 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 }
891
892 /* notify WMM */
893 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
894
895 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530896 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 } else {
898 /* Get Multicast Encryption Type */
899 encryptType =
900 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
901 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
902 /* Get Unicast Encryption Type */
903 encryptType =
904 pRoamInfo->u.pConnectedProfile->EncryptionType;
905 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
906
907 pHddStaCtx->conn_info.authType =
908 pRoamInfo->u.pConnectedProfile->AuthType;
Zhang Qian32fd43e2017-08-24 18:36:28 +0800909 pHddStaCtx->conn_info.last_auth_type =
910 pHddStaCtx->conn_info.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911
912 pHddStaCtx->conn_info.operationChannel =
913 pRoamInfo->u.pConnectedProfile->operationChannel;
914
915 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530916 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 &pRoamInfo->u.pConnectedProfile->SSID,
918 sizeof(tSirMacSSid));
Zhang Qian32fd43e2017-08-24 18:36:28 +0800919 qdf_mem_copy(&pHddStaCtx->conn_info.last_ssid.SSID,
920 &pRoamInfo->u.pConnectedProfile->SSID,
921 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922
923 /* Save dot11mode in which STA associated to AP */
924 pHddStaCtx->conn_info.dot11Mode =
925 pRoamInfo->u.pConnectedProfile->dot11Mode;
926
927 pHddStaCtx->conn_info.proxyARPService =
928 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530929
930 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
931
932 pHddStaCtx->conn_info.rate_flags =
933 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530935 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937}
938
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939/**
940 * hdd_send_ft_assoc_response() - send fast transition assoc response
941 * @dev: pointer to net device
942 * @pAdapter: pointer to adapter
943 * @pCsrRoamInfo: pointer to roam info
944 *
945 * Send the 11R key information to the supplicant. Only then can the supplicant
946 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
947 * for the same purpose.)
948 *
949 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
950 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
951 * This is the Assoc Response.
952 *
953 * Return: none
954 */
955static void
956hdd_send_ft_assoc_response(struct net_device *dev,
957 hdd_adapter_t *pAdapter,
958 tCsrRoamInfo *pCsrRoamInfo)
959{
960 union iwreq_data wrqu;
961 char *buff;
962 unsigned int len = 0;
963 u8 *pFTAssocRsp = NULL;
964
965 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700966 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 return;
968 }
969
970 pFTAssocRsp =
971 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
972 pCsrRoamInfo->nAssocReqLength);
973 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700974 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 return;
976 }
977 /* pFTAssocRsp needs to point to the IEs */
978 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700979 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700980 (unsigned int)pFTAssocRsp[0],
981 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982
983 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700984 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700986 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 return;
988 }
989 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
990 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
991 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 memcpy(buff, pFTAssocRsp, len);
993 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
994
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700995 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998/**
999 * hdd_send_ft_event() - send fast transition event
1000 * @pAdapter: pointer to adapter
1001 *
1002 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
1003 * FT events to the supplicant. At the reception of Auth2 we send the RIC
1004 * followed by the auth response IEs to the supplicant.
1005 * Once both are received in the supplicant, an FT event is generated
1006 * to the supplicant.
1007 *
1008 * Return: none
1009 */
1010static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
1011{
1012 uint16_t auth_resp_len = 0;
1013 uint32_t ric_ies_length = 0;
Jeff Johnson49432062017-08-28 12:08:45 -07001014 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015
1016#if defined(KERNEL_SUPPORT_11R_CFG80211)
1017 struct cfg80211_ft_event_params ftEvent;
1018 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1019 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
1020 struct net_device *dev = pAdapter->dev;
1021#else
1022 char *buff;
1023 union iwreq_data wrqu;
1024 uint16_t str_len;
1025#endif
1026
1027#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301028 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1029 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030
1031 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
1032 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001033 if (ric_ies_length == 0)
1034 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035
1036 ftEvent.ric_ies = ricIe;
1037 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001038 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039
1040 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1041 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1042 &auth_resp_len);
1043
1044 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001045 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 return;
1047 }
1048
1049 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1050
1051 ftEvent.target_ap = ftIe;
1052
Anurag Chouhan6d760662016-02-20 16:05:43 +05301053 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1054 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001056 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1057 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1058 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 ftEvent.target_ap[0], ftEvent.target_ap[1],
1060 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1061 ftEvent.target_ap[5]);
1062
1063 (void)cfg80211_ft_event(dev, &ftEvent);
1064
1065#else
1066 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001067 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001069 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 return;
1071 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072
1073 /* Sme needs to send the RIC IEs first */
1074 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1075 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1076 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1077 &ric_ies_length);
1078 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001079 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 } else {
1081 wrqu.data.length = str_len + ric_ies_length;
1082 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1083 }
1084
1085 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301086 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1088 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1089 (u8 *) &buff[str_len],
1090 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1091
1092 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001093 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001094 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 return;
1096 }
1097
1098 wrqu.data.length = str_len + auth_resp_len;
1099 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1100
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001101 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102#endif
1103}
1104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105#ifdef FEATURE_WLAN_ESE
1106/**
1107 * hdd_send_new_ap_channel_info() - send new ap channel info
1108 * @dev: pointer to net device
1109 * @pAdapter: pointer to adapter
1110 * @pCsrRoamInfo: pointer to roam info
1111 *
1112 * Send the ESE required "new AP Channel info" to the supplicant.
1113 * (This keeps the supplicant "up to date" on the current channel.)
1114 *
1115 * The current (new AP) channel information is passed in.
1116 *
1117 * Return: none
1118 */
1119static void
1120hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1121 tCsrRoamInfo *pCsrRoamInfo)
1122{
1123 union iwreq_data wrqu;
1124 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1125
1126 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001127 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 return;
1129 }
1130 /*
1131 * Send the Channel event, the supplicant needs this to generate
1132 * the Adjacent AP report.
1133 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001134 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001135 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 memset(&wrqu, '\0', sizeof(wrqu));
1137 wrqu.freq.m = descriptor->channelId;
1138 wrqu.freq.e = 0;
1139 wrqu.freq.i = 0;
1140 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1141}
1142
1143#endif /* FEATURE_WLAN_ESE */
1144
1145/**
1146 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1147 * @pAdapter: pointer to adapter
1148 * @pCsrRoamInfo: pointer to roam info
1149 *
1150 * Return: none
1151 */
1152static void
1153hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1154 tCsrRoamInfo *pCsrRoamInfo)
1155{
1156 union iwreq_data wrqu;
1157 u8 *pBeaconIes;
1158 u8 currentLen = 0;
1159 char *buff;
1160 int totalIeLen = 0, currentOffset = 0, strLen;
1161
1162 memset(&wrqu, '\0', sizeof(wrqu));
1163
1164 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001165 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 return;
1167 }
1168 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1169 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001170 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171 return;
1172 }
1173 /* pBeaconIes needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001174 hdd_debug("Beacon IEs is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001175 (unsigned int)pBeaconIes[0],
1176 (unsigned int)pBeaconIes[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001177 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001178 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001179
1180 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001181 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001183 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184 return;
1185 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186
1187 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1188 currentLen = strLen + 1;
1189
1190 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1191 do {
1192 /*
1193 * If the beacon size exceeds max CUSTOM event size, break it
1194 * into chunks of CUSTOM event max size and send it to
1195 * supplicant. Changes are done in supplicant to handle this.
1196 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301197 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301199 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301200 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201 currentLen);
1202 currentOffset += currentLen;
1203 totalIeLen -= currentLen;
1204 wrqu.data.length = strLen + 1 + currentLen;
1205 if (totalIeLen)
1206 buff[strLen] = 1; /* more chunks pending */
1207 else
1208 buff[strLen] = 0; /* last chunk */
1209
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001210 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001211 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1213 } while (totalIeLen > 0);
1214
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001215 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216}
1217
1218/**
1219 * hdd_send_association_event() - send association event
1220 * @dev: pointer to net device
1221 * @pCsrRoamInfo: pointer to roam info
1222 *
1223 * Return: none
1224 */
1225static void hdd_send_association_event(struct net_device *dev,
1226 tCsrRoamInfo *pCsrRoamInfo)
1227{
Rajeev Kumar78427682017-01-13 16:13:11 -08001228 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson49432062017-08-28 12:08:45 -07001230 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001231 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 union iwreq_data wrqu;
1233 int we_event;
1234 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301235 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 /* Added to find the auth type on the fly at run time */
1238 /* rather than with cfg to see if FT is enabled */
1239 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1240 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241
1242 memset(&wrqu, '\0', sizeof(wrqu));
1243 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1244 we_event = SIOCGIWAP;
1245#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1246 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301247 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001249 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301250 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001251 hdd_notify_sta_disconnect(pAdapter->sessionId,
1252 true, pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301253 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301254 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255#endif
1256 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001257 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001260 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 return;
1262 }
1263
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001264 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001265 policy_mgr_incr_active_session(pHddCtx->hdd_psoc,
1266 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1268 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1269
1270#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001271 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272 if (global_p2p_connection_status ==
1273 P2P_CLIENT_CONNECTING_STATE_1) {
1274 global_p2p_connection_status =
1275 P2P_CLIENT_CONNECTED_STATE_1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001276 hdd_debug("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 } else if (global_p2p_connection_status ==
1278 P2P_CLIENT_CONNECTING_STATE_2) {
1279 global_p2p_connection_status =
1280 P2P_CLIENT_COMPLETED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001281 hdd_debug("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 }
1283 }
1284#endif
1285 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1286 MAC_ADDRESS_STR "\n",
1287 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1288 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1289 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1290
1291 /*
1292 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1293 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001294 * fFTEnable is true.
1295 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 if ((pRoamProfile->AuthType.authType[0] ==
1298 eCSR_AUTH_TYPE_FT_RSN_PSK)
1299 || (pRoamProfile->AuthType.authType[0] ==
1300 eCSR_AUTH_TYPE_FT_RSN)
1301#ifdef FEATURE_WLAN_ESE
1302 || (pRoamProfile->AuthType.authType[0] ==
1303 eCSR_AUTH_TYPE_CCKM_RSN)
1304 || (pRoamProfile->AuthType.authType[0] ==
1305 eCSR_AUTH_TYPE_CCKM_WPA)
1306#endif
1307 ) {
1308 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1309 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301310 qdf_copy_macaddr(&peerMacAddr,
1311 &pHddStaCtx->conn_info.bssId);
1312 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1313 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1314 chan_info.info = pCsrRoamInfo->chan_info.info;
1315 chan_info.band_center_freq1 =
1316 pCsrRoamInfo->chan_info.band_center_freq1;
1317 chan_info.band_center_freq2 =
1318 pCsrRoamInfo->chan_info.band_center_freq2;
1319 chan_info.reg_info_1 =
1320 pCsrRoamInfo->chan_info.reg_info_1;
1321 chan_info.reg_info_2 =
1322 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301323
Dustin Brown7d043f62017-03-27 12:07:36 -07001324 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1325 pAdapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301326 peerMacAddr.bytes,
1327 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001328 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301329 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1330 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001331 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1332 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301333 if (ret)
1334 hdd_err("Peer object %pM fail to set associated state",
1335 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301336
Abhishek Singh1c676222016-05-09 14:20:28 +05301337 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001338 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1339 ePeerConnected,
1340 pCsrRoamInfo->timingMeasCap,
1341 pAdapter->sessionId, &chan_info,
1342 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001343 /* Update tdls module about connection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001344 hdd_notify_sta_connect(pAdapter->sessionId,
1345 pCsrRoamInfo->tdls_chan_swit_prohibited,
1346 pCsrRoamInfo->tdls_prohibited,
1347 pAdapter->hdd_vdev);
1348
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001349 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001350
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001351
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001353#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 /* start timer in sta/p2p_cli */
1355 spin_lock_bh(&pHddCtx->bus_bw_lock);
1356 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1357 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001358 cdp_get_intra_bss_fwd_pkts_count(
1359 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301360 &pAdapter->prev_fwd_tx_packets,
1361 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001363 hdd_bus_bw_compute_timer_start(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364#endif
1365#endif
1366 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1367 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001368 policy_mgr_update_connection_info(pHddCtx->hdd_psoc,
1369 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001371 ETH_ALEN);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001372 hdd_info("wlan: new IBSS connection to " MAC_ADDRESS_STR,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001373 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301374
Dustin Brown7d043f62017-03-27 12:07:36 -07001375 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1376 QDF_IBSS_MODE,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301377 pCsrRoamInfo->bssid.bytes,
1378 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001379 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301380 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1381 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001382 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1383 WLAN_ASSOC_STATE);
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301384 if (ret)
1385 hdd_err("Peer object %pM fail to set associated state",
1386 peerMacAddr.bytes);
1387
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388 } else { /* Not Associated */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001389 hdd_info("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001391 policy_mgr_decr_session_set_pcl(pHddCtx->hdd_psoc,
1392 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393
1394#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1395 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1396#endif
1397
Abhishek Singh1c676222016-05-09 14:20:28 +05301398 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1399 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301400 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 &pHddStaCtx->conn_info.bssId);
1402
1403 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001404 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301405 ePeerDisconnected, 0,
1406 pAdapter->sessionId,
1407 NULL,
1408 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301410
Dustin Brown7d043f62017-03-27 12:07:36 -07001411 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
1412 peerMacAddr.bytes);
Rajeev Kumardfa37072017-01-13 16:27:22 -08001413 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301414 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1415 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1416
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001417 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001418 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001419 hdd_notify_sta_disconnect(pAdapter->sessionId,
1420 false,
1421 pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301422 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424#ifdef MSM_PLATFORM
1425 /* stop timer in sta/p2p_cli */
1426 spin_lock_bh(&pHddCtx->bus_bw_lock);
1427 pAdapter->prev_tx_packets = 0;
1428 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301429 pAdapter->prev_fwd_tx_packets = 0;
1430 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001432 hdd_bus_bw_compute_timer_try_stop(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433#endif
1434 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001435 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 /* Send SCC/MCC Switching event to IPA */
1437 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1438
1439 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001440 /* During the WLAN uninitialization,supplicant is stopped before the
1441 * driver so not sending the status of the connection to supplicant
1442 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001443 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 wireless_send_event(dev, we_event, &wrqu, msg);
1445#ifdef FEATURE_WLAN_ESE
1446 if (eConnectionState_Associated ==
1447 pHddStaCtx->conn_info.connState) {
1448 if ((pRoamProfile->AuthType.authType[0] ==
1449 eCSR_AUTH_TYPE_CCKM_RSN) ||
1450 (pRoamProfile->AuthType.authType[0] ==
1451 eCSR_AUTH_TYPE_CCKM_WPA))
1452 hdd_send_new_ap_channel_info(dev, pAdapter,
1453 pCsrRoamInfo);
1454 }
1455#endif
1456 }
1457}
1458
1459/**
1460 * hdd_conn_remove_connect_info() - remove connection info
1461 * @pHddStaCtx: pointer to global HDD station context
1462 * @pCsrRoamInfo: pointer to roam info
1463 *
1464 * Return: none
1465 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001466static void hdd_conn_remove_connect_info(struct hdd_station_ctx *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467{
1468 /* Remove staId, bssId and peerMacAddress */
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301469 pHddStaCtx->conn_info.staId[0] = HDD_WLAN_INVALID_STA_ID;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301470 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1471 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301472 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473
1474 /* Clear all security settings */
1475 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1476 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1477 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1478
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301479 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1480 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 pHddStaCtx->conn_info.proxyARPService = 0;
1483
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301484 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485}
1486
1487/**
1488 * hdd_roam_deregister_sta() - deregister station
1489 * @pAdapter: pointer to adapter
1490 * @staId: station identifier
1491 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301492 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 */
Abhishek Singh07c627e2017-03-20 17:56:34 +05301494QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301496 QDF_STATUS qdf_status;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001497 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301498 int ret = 0;
1499 uint8_t *peer_mac = NULL;
1500 struct qdf_mac_addr broadcastMacAddr =
1501 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 if (eConnectionState_IbssDisconnected ==
1503 pHddStaCtx->conn_info.connState) {
1504 /*
1505 * Do not set the carrier off when the last peer leaves.
1506 * We will set the carrier off while stopping the IBSS.
1507 */
1508 }
1509
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001510 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001511 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301512 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301513 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301514 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1515 staid, qdf_status, qdf_status);
1516 }
1517
1518 if (adapter->device_mode == QDF_STA_MODE) {
1519 peer_mac = pHddStaCtx->conn_info.bssId.bytes;
1520 } else if (adapter->device_mode == QDF_IBSS_MODE) {
1521 if (pHddStaCtx->broadcast_staid == staid)
1522 peer_mac = broadcastMacAddr.bytes;
1523 else
1524 peer_mac = pHddStaCtx->conn_info.
1525 peerMacAddress[staid].bytes;
1526 }
1527
Dustin Brown7d043f62017-03-27 12:07:36 -07001528 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301529 if (ret) {
1530 hdd_err("Peer obj %pM delete fails", peer_mac);
1531 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301533 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534}
1535
1536/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301537 * hdd_print_bss_info() - print bss info
1538 * @hdd_sta_ctx: pointer to hdd station context
1539 *
1540 * Return: None
1541 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001542static void hdd_print_bss_info(struct hdd_station_ctx *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301543{
1544 uint32_t *cap_info;
1545
1546 hdd_info("WIFI DATA LOGGER");
1547 hdd_info("channel: %d",
1548 hdd_sta_ctx->conn_info.freq);
1549 hdd_info("dot11mode: %d",
1550 hdd_sta_ctx->conn_info.dot11Mode);
1551 hdd_info("AKM: %d",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001552 hdd_sta_ctx->conn_info.last_auth_type);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301553 hdd_info("ssid: %.*s",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001554 hdd_sta_ctx->conn_info.last_ssid.SSID.length,
1555 hdd_sta_ctx->conn_info.last_ssid.SSID.ssId);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301556 hdd_info("roam count: %d",
1557 hdd_sta_ctx->conn_info.roam_count);
1558 hdd_info("ant_info: %d",
1559 hdd_sta_ctx->conn_info.txrate.nss);
1560 hdd_info("datarate legacy %d",
1561 hdd_sta_ctx->conn_info.txrate.legacy);
1562 hdd_info("datarate mcs: %d",
1563 hdd_sta_ctx->conn_info.txrate.mcs);
1564 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1565 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1566 hdd_info("ht caps: %x", *cap_info);
1567 }
1568 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1569 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1570 hdd_info("vht caps: %x", *cap_info);
1571 }
1572 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1573 hdd_info("hs20 info: %x",
1574 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1575 hdd_info("signal: %d",
1576 hdd_sta_ctx->conn_info.signal);
1577 hdd_info("noise: %d",
1578 hdd_sta_ctx->conn_info.noise);
1579}
1580
1581/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 * hdd_dis_connect_handler() - disconnect event handler
1583 * @pAdapter: pointer to adapter
1584 * @pRoamInfo: pointer to roam info
1585 * @roamId: roam identifier
1586 * @roamStatus: roam status
1587 * @roamResult: roam result
1588 *
1589 * This function handles disconnect event:
1590 * 1. Disable transmit queues;
1591 * 2. Clean up internal connection states and data structures;
1592 * 3. Send disconnect indication to supplicant.
1593 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301594 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301596static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 tCsrRoamInfo *pRoamInfo,
1598 uint32_t roamId,
1599 eRoamCmdStatus roamStatus,
1600 eCsrRoamResult roamResult)
1601{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301602 QDF_STATUS status = QDF_STATUS_SUCCESS;
1603 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 struct net_device *dev = pAdapter->dev;
Jeff Johnson49432062017-08-28 12:08:45 -07001605 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001606 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 uint8_t sta_id;
1608 bool sendDisconInd = true;
1609
1610 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001611 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301612 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 }
1614 /* notify apps that we can't pass traffic anymore */
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001615 hdd_debug("Disabling queues");
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301616 wlan_hdd_netif_queue_control(pAdapter,
1617 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1618 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619
1620 if (hdd_ipa_is_enabled(pHddCtx))
1621 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001622 HDD_IPA_STA_DISCONNECT,
1623 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624
1625#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1626 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1627#endif
1628
Nirav Shah1da77682016-05-03 20:16:39 +05301629 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1630 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001631 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301632 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633
1634 /* HDD has initiated disconnect, do not send disconnect indication
1635 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301636 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 * to cfg80211_disconnected.
1638 */
1639 if ((eConnectionState_Disconnecting ==
1640 pHddStaCtx->conn_info.connState) ||
1641 (eConnectionState_NotConnected ==
1642 pHddStaCtx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001643 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 sendDisconInd = false;
1645 }
1646
1647 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1648 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 hdd_conn_set_connection_state(pAdapter,
1650 eConnectionState_Disconnecting);
1651 }
1652
1653 hdd_clear_roam_profile_ie(pAdapter);
1654 hdd_wmm_init(pAdapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001655 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301656 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657
1658 /* indicate 'disconnect' status to wpa_supplicant... */
1659 hdd_send_association_event(dev, pRoamInfo);
1660 /* indicate disconnected event to nl80211 */
1661 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1662 /*
1663 * Only send indication to kernel if not initiated
1664 * by kernel
1665 */
1666 if (sendDisconInd) {
1667 /*
1668 * To avoid wpa_supplicant sending "HANGED" CMD
1669 * to ICS UI.
1670 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001671 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1672 if (pRoamInfo->reasonCode ==
1673 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1674 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301675 wlan_hdd_cfg80211_indicate_disconnect(
1676 dev, false,
1677 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001678 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301679 wlan_hdd_cfg80211_indicate_disconnect(
1680 dev, false,
1681 WLAN_REASON_UNSPECIFIED
1682 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001683 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301685 hdd_info("sent disconnected event to nl80211, reason code %d",
1686 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1687 pRoamInfo->reasonCode :
1688 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 }
1690 /*
1691 * During the WLAN uninitialization,supplicant is stopped
1692 * before the driver so not sending the status of the
1693 * connection to supplicant.
1694 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001695 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001697 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 if (global_p2p_connection_status ==
1699 P2P_CLIENT_CONNECTED_STATE_1) {
1700 global_p2p_connection_status =
1701 P2P_CLIENT_DISCONNECTED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001702 hdd_debug("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 } else if (global_p2p_connection_status ==
1704 P2P_CLIENT_COMPLETED_STATE) {
1705 global_p2p_connection_status =
1706 P2P_NOT_ACTIVE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001707 hdd_debug("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 }
1709 }
1710#endif
1711
1712 }
1713 }
1714
1715 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001717 if (hdd_remove_beacon_filter(pAdapter) != 0)
1718 hdd_err("hdd_remove_beacon_filter() failed");
1719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301721 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001722
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001723 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301725 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001726 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301727 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301728 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729 }
1730 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301731 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001732 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001733 if (HDD_WLAN_INVALID_STA_ID ==
1734 pHddStaCtx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301735 continue;
1736 sta_id = pHddStaCtx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001737 hdd_debug("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301738 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301739 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001740 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301741 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301742 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301743 }
1744 /* set the staid and peer mac as 0, all other
1745 * reset are done in hdd_connRemoveConnectInfo.
1746 */
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301747 pHddStaCtx->conn_info.staId[i] =
1748 HDD_WLAN_INVALID_STA_ID;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301749 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301750 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301751 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1752 pHddCtx->sta_to_adapter[sta_id] = NULL;
1753 }
1754 } else {
1755 sta_id = pHddStaCtx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001756 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301757
1758 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001759 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1760 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301761 eCSR_ROAM_LOSTLINK == roamStatus) {
Abhishek Singhc9941602016-08-09 16:06:22 +05301762 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1763 pHddStaCtx->conn_info.bssId.bytes);
1764 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1765 pHddStaCtx->conn_info.bssId.bytes);
1766 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301767 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 /* Clear saved connection information in HDD */
1770 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301772 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773
1774#ifdef FEATURE_WLAN_TDLS
1775 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1776 wlan_hdd_tdls_disconnection_callback(pAdapter);
1777#endif
1778
Krunal Sonibe766b02016-03-10 13:00:44 -08001779 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1780 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1782 (pAdapter),
1783 pAdapter->sessionId);
1784 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301785 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 /* Unblock anyone waiting for disconnect to complete */
1787 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301788 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 return status;
1790}
1791
1792/**
1793 * hdd_set_peer_authorized_event() - set peer_authorized_event
1794 * @vdev_id: vdevid
1795 *
1796 * Return: None
1797 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001798static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799{
Jeff Johnson49432062017-08-28 12:08:45 -07001800 struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 hdd_adapter_t *adapter = NULL;
1802
1803 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1804 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001805 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001806 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 }
1808 complete(&adapter->sta_authorized_event);
1809}
1810
1811/**
1812 * hdd_change_peer_state() - change peer state
1813 * @pAdapter: HDD adapter
1814 * @sta_state: peer state
1815 * @roam_synch_in_progress: roam synch in progress
1816 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301817 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301819QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 uint8_t sta_id,
1821 enum ol_txrx_peer_state sta_state,
1822 bool roam_synch_in_progress)
1823{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301824 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001825 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001826 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1827 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1828 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
1830 if (!pdev) {
1831 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301832 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 }
1834
1835 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001836 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301837 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838 }
1839
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001840 peer = cdp_peer_find_by_local_id(soc,
1841 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301843 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844
Leo Changfdb45c32016-10-28 11:09:23 -07001845 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001846 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001847 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001848 return QDF_STATUS_E_FAULT;
1849 }
1850
Leo Changfdb45c32016-10-28 11:09:23 -07001851 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301852 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001853 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301854 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 }
1856#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1857 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301858 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859#endif
1860
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001861 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1863 /* make sure event is reset */
1864 INIT_COMPLETION(pAdapter->sta_authorized_event);
1865#endif
1866
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001867 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 hdd_set_peer_authorized_event,
1869 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301870 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001871 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301872 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 }
1874
Krunal Sonibe766b02016-03-10 13:00:44 -08001875 if (pAdapter->device_mode == QDF_STA_MODE ||
1876 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001878 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 unsigned long rc;
1880
1881 /* wait for event from firmware to set the event */
1882 rc = wait_for_completion_timeout(
1883 &pAdapter->sta_authorized_event,
1884 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001885 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001886 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001887
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001888 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1889 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001890 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891#endif
1892 }
1893 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301894 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895}
1896
1897/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001898 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1899 * @cbk_data: callback data
1900 * @sta_id: station id
1901 * @vdev_param: vdev parameter
1902 * @is_link_up: link state up or down
1903 *
1904 * Return: QDF status
1905 */
1906QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1907 uint8_t sta_id,
1908 uint32_t vdev_param,
1909 bool is_link_up)
1910{
1911 struct cdp_vdev *data_vdev;
1912 QDF_STATUS status = QDF_STATUS_SUCCESS;
1913 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Jeff Johnson49432062017-08-28 12:08:45 -07001914 struct hdd_context *hdd_ctx;
Kabilan Kannan256e3182017-05-02 16:02:37 -07001915 struct wlan_objmgr_psoc **psoc;
1916
1917 if (!cbk_data)
1918 return status;
1919
1920 psoc = cbk_data;
Jeff Johnson49432062017-08-28 12:08:45 -07001921 hdd_ctx = container_of(psoc, struct hdd_context, hdd_psoc);
Kabilan Kannan256e3182017-05-02 16:02:37 -07001922
1923 if (!hdd_ctx->tdls_nap_active)
1924 return status;
1925
1926 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, sta_id);
1927 if (NULL == data_vdev) {
1928 status = QDF_STATUS_E_FAILURE;
1929 return status;
1930 }
1931
1932 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1933
1934 return status;
1935}
1936
1937/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 * hdd_roam_register_sta() - register station
1939 * @pAdapter: pointer to adapter
1940 * @pRoamInfo: pointer to roam info
1941 * @staId: station identifier
1942 * @pPeerMacAddress: peer MAC address
1943 * @pBssDesc: pointer to BSS description
1944 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301945 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001947QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 tCsrRoamInfo *pRoamInfo,
1949 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301950 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 tSirBssDescription *pBssDesc)
1952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301953 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001955 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001956 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001957 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1958 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959
1960 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301961 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962
1963 /* Get the Station ID from the one saved during the association */
1964 staDesc.sta_id = staId;
1965
1966 /* set the QoS field appropriately */
1967 if (hdd_wmm_is_active(pAdapter))
1968 staDesc.is_qos_enabled = 1;
1969 else
1970 staDesc.is_qos_enabled = 0;
1971
1972#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07001973 hdd_debug("WAPI STA Registered: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001974 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 if (pAdapter->wapi_info.fIsWapiSta)
1976 staDesc.is_wapi_supported = 1;
1977 else
1978 staDesc.is_wapi_supported = 0;
1979#endif /* FEATURE_WLAN_WAPI */
1980
Dhanashri Atre50141c52016-04-07 13:15:29 -07001981 /* Register the vdev transmit and receive functions */
1982 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1983 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001984
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001985 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1986 (struct cdp_pdev *)pdev,
1987 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001988 if (!pAdapter->txrx_vdev) {
1989 hdd_err("%s find vdev fail", __func__);
1990 return QDF_STATUS_E_FAILURE;
1991 }
1992
1993 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001994 cdp_vdev_register(soc,
1995 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001996 if (!txrx_ops.tx.tx) {
1997 hdd_err("%s vdev register fail", __func__);
1998 return QDF_STATUS_E_FAILURE;
1999 }
2000
Dhanashri Atre50141c52016-04-07 13:15:29 -07002001 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002002 qdf_status = cdp_peer_register(soc,
2003 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302004 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002005 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002006 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302007 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 }
2009
2010 if (!pRoamInfo->fAuthRequired) {
2011 /*
2012 * Connections that do not need Upper layer auth, transition
2013 * TLSHIM directly to 'Authenticated' state
2014 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302015 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002017 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2019 pRoamInfo->roamSynchInProgress
2020#else
2021 false
2022#endif
2023 );
2024
2025 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002026 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002028 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302030 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002032 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2034 pRoamInfo->roamSynchInProgress
2035#else
2036 false
2037#endif
2038 );
2039 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002040 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302042 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043}
2044
2045/**
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302046 * hdd_send_roamed_ind() - send roamed indication to cfg80211
2047 * @dev: network device
2048 * @bss: cfg80211 roamed bss pointer
2049 * @req_ie: IEs used in reassociation request
2050 * @req_ie_len: Length of the @req_ie
2051 * @resp_ie: IEs received in successful reassociation response
2052 * @resp_ie_len: Length of @resp_ie
2053 *
2054 * Return: none
2055 */
2056#if defined CFG80211_ROAMED_API_UNIFIED || \
2057 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
2058static void hdd_send_roamed_ind(struct net_device *dev,
2059 struct cfg80211_bss *bss, const uint8_t *req_ie,
2060 size_t req_ie_len, const uint8_t *resp_ie,
2061 size_t resp_ie_len)
2062{
2063 struct cfg80211_roam_info info = {0};
2064
2065 info.bss = bss;
2066 info.req_ie = req_ie;
2067 info.req_ie_len = req_ie_len;
2068 info.resp_ie = resp_ie;
2069 info.resp_ie_len = resp_ie_len;
2070 cfg80211_roamed(dev, &info, GFP_KERNEL);
2071}
2072#else
2073static inline void hdd_send_roamed_ind(struct net_device *dev,
2074 struct cfg80211_bss *bss,
2075 const uint8_t *req_ie, size_t req_ie_len,
2076 const uint8_t *resp_ie,
2077 size_t resp_ie_len)
2078{
2079 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
2080 GFP_KERNEL);
2081}
2082#endif
2083
2084/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 * hdd_send_re_assoc_event() - send reassoc event
2086 * @dev: pointer to net device
2087 * @pAdapter: pointer to adapter
2088 * @pCsrRoamInfo: pointer to roam info
2089 * @reqRsnIe: pointer to RSN Information element
2090 * @reqRsnLength: length of RSN IE
2091 *
2092 * Return: none
2093 */
2094static void hdd_send_re_assoc_event(struct net_device *dev,
2095 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
2096 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2097{
2098 unsigned int len = 0;
2099 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002100 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2101 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 uint32_t rspRsnLength = 0;
2103 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2105 uint8_t *buf_ptr, ssid_ie_len;
2106 struct cfg80211_bss *bss = NULL;
2107 uint8_t *final_req_ie = NULL;
2108 tCsrRoamConnectedProfile roam_profile;
2109 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson49432062017-08-28 12:08:45 -07002110 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002112 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2113
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002115 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002116 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 }
2118
Naveen Rawat14298b92015-11-25 16:27:41 -08002119 if (!assoc_req_ies) {
2120 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002121 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002122 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002124 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 goto done;
2126 }
2127
2128 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002129 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 goto done;
2131 }
2132
2133 pFTAssocRsp =
2134 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2135 pCsrRoamInfo->nAssocReqLength);
2136 if (pFTAssocRsp == NULL)
2137 goto done;
2138
2139 /* pFTAssocRsp needs to point to the IEs */
2140 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002141 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002142 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143
2144 /*
2145 * Active session count is decremented upon disconnection, but during
2146 * roaming, there is no disconnect indication and hence active session
2147 * count is not decremented.
2148 * After roaming is completed, active session count is incremented
2149 * as a part of connect indication but effectively after roaming the
2150 * active session count should still be the same and hence upon
2151 * successful reassoc decrement the active session count here.
2152 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002153 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002154 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
2155 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156
2157 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2158 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2159 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302160 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2161 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162
2163 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302164 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2166 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302167
2168 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2169 chan, pCsrRoamInfo->bssid.bytes,
2170 &roam_profile.SSID.ssId[0],
2171 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172
2173 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002174 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 buf_ptr = buf_ssid_ie;
2176 *buf_ptr = SIR_MAC_SSID_EID;
2177 buf_ptr++;
2178 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2179 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302180 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 roam_profile.SSID.length);
2182 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002183 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302184 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002185 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002186 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Kapil Gupta8731e812017-07-11 18:42:39 +05302187 if (final_req_ie == NULL) {
2188 if (bss)
2189 cfg80211_put_bss(pAdapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302191 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302193 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302195 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2196 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2197 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002199 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302200 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002201 final_req_ie, (ssid_ie_len + reqRsnLength));
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302202 hdd_send_roamed_ind(dev, bss, final_req_ie,
2203 (ssid_ie_len + reqRsnLength), rspRsnIe,
2204 rspRsnLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302206 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002207 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2208 pCsrRoamInfo->nAssocReqLength);
2209
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002210 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302211 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002212 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2213
Prakash Dhavali989127d2016-11-29 14:56:44 +05302214 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002215 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2216 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002217 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002219 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002221 qdf_mem_free(final_req_ie);
2222 qdf_mem_free(rspRsnIe);
2223 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224}
2225
2226/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302227 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002228 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302229 *
2230 * Return: roam sync status if roaming offloaded else false
2231 */
2232#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002233bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302234{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002235 if (roaminfo)
2236 return roaminfo->roamSynchInProgress;
2237 else
2238 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302239}
2240#endif
2241
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002242/**
2243 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2244 * @hddstactx: pointer to HDD sta context
2245 * @roaminfo: pointer to roaminfo structure
2246 *
2247 * This function returns staid for IBSS peer. If peer is broadcast
2248 * MAC address return self staid(0) else find the peer sta id of
2249 * the peer.
2250 *
2251 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2252 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002253static uint8_t hdd_get_ibss_peer_staid(struct hdd_station_ctx *hddstactx,
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002254 tCsrRoamInfo *roaminfo)
2255{
2256 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2257 QDF_STATUS status;
2258
2259 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2260 staid = 0;
2261 } else {
2262 status = hdd_get_peer_sta_id(hddstactx,
2263 &roaminfo->peerMac, &staid);
2264 if (status != QDF_STATUS_SUCCESS) {
2265 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2266 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2267 }
2268 }
2269
2270 return staid;
2271}
Govind Singhedc5cda2015-10-23 17:11:35 +05302272
2273/**
2274 * hdd_change_sta_state_authenticated()-
2275 * This function changes STA state to authenticated
2276 * @adapter: pointer to the adapter structure.
2277 * @roaminfo: pointer to the RoamInfo structure.
2278 *
2279 * This is called from hdd_RoamSetKeyCompleteHandler
2280 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2281 *
2282 * Return: 0 on success and errno on failure
2283 */
2284static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2285 tCsrRoamInfo *roaminfo)
2286{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002287 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002288 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002289 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002290 struct hdd_station_ctx *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson49432062017-08-28 12:08:45 -07002291 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302292
Dustin Brownf660fb42016-09-09 12:04:00 -07002293 timeout = hddstactx->hdd_ReassocScenario ?
2294 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002295 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002296
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002297 if (QDF_IBSS_MODE == adapter->device_mode)
2298 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2299 else
2300 staid = hddstactx->conn_info.staId[0];
2301
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002302 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302303
2304 /* Connections that do not need Upper layer authentication,
2305 * transition TL to 'Authenticated' state after the keys are set
2306 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002307 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302308 hdd_is_roam_sync_in_progress(roaminfo));
2309 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002310 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2311
Krunal Sonibe766b02016-03-10 13:00:44 -08002312 if ((QDF_STA_MODE == adapter->device_mode) ||
2313 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302314 sme_ps_enable_auto_ps_timer(
2315 WLAN_HDD_GET_HAL_CTX(adapter),
2316 adapter->sessionId,
Dustin Brown84411b02017-07-21 16:44:44 -07002317 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302318 }
2319
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002320 return qdf_status_to_os_return(status);
2321}
2322
2323/**
2324 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2325 * if key installation is required
2326 * @encr_type: encryption type
2327 *
2328 * Return: true if key installation is required and false otherwise.
2329 */
2330static inline bool hdd_is_key_install_required_for_ibss(
2331 eCsrEncryptionType encr_type)
2332{
2333 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2334 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2335 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05302336 eCSR_ENCRYPT_TYPE_AES_GCMP == encr_type ||
2337 eCSR_ENCRYPT_TYPE_AES_GCMP_256 == encr_type ||
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002338 eCSR_ENCRYPT_TYPE_AES == encr_type)
2339 return true;
2340 else
2341 return false;
2342}
2343
2344/**
2345 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2346 * complete
2347 * @adapter: pointer to HDD adapter
2348 * @roaminfo: pointer to roam info
2349 * @roam_result: roam result
2350 *
2351 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2352 * This function checks for the successful set key completion and update
2353 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2354 *
2355 * Return: None
2356 */
2357static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2358 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2359{
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002360 struct hdd_station_ctx *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002361 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2362
2363 /*
2364 * If the security mode is one of the following, IBSS peer will be
2365 * waiting in CONN state and we will move the peer state to AUTH
2366 * here. For non-secure connection, no need to wait for set-key complete
2367 * peer will be moved to AUTH in hdd_roam_register_sta.
2368 */
2369 if (QDF_IBSS_MODE == adapter->device_mode) {
2370 if (hdd_is_key_install_required_for_ibss(encr_type))
2371 hdd_change_sta_state_authenticated(adapter, roaminfo);
2372
2373 return;
2374 }
2375
2376 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2377 hdd_sta_ctx->conn_info.gtk_installed = true;
2378 /*
2379 * PTK exchange happens in preauthentication itself if key_mgmt
2380 * is FT-PSK, ptk_installed was false as there is no set PTK
2381 * after roaming. STA TL state moves to authenticated only if
2382 * ptk_installed is true. So, make ptk_installed to true in
2383 * case of 11R roaming.
2384 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302385 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
2386 adapter->sessionId))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002387 hdd_sta_ctx->conn_info.ptk_installed = true;
2388 } else {
2389 hdd_sta_ctx->conn_info.ptk_installed = true;
2390 }
2391
2392 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2393 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2394 * unicast key and it was resulting in sending few un-encrypted packet.
2395 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2396 * set the unicast and broadcast key.
2397 */
2398 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2399 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2400 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2401 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2402 if (hdd_sta_ctx->conn_info.gtk_installed &&
2403 hdd_sta_ctx->conn_info.ptk_installed)
2404 hdd_change_sta_state_authenticated(adapter, roaminfo);
2405 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2406 hdd_change_sta_state_authenticated(adapter, roaminfo);
2407 }
2408
2409 if (hdd_sta_ctx->conn_info.gtk_installed &&
2410 hdd_sta_ctx->conn_info.ptk_installed) {
2411 hdd_sta_ctx->conn_info.gtk_installed = false;
2412 hdd_sta_ctx->conn_info.ptk_installed = false;
2413 }
2414
2415 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2416
2417 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302418}
2419
2420/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 * hdd_roam_set_key_complete_handler() - Update the security parameters
2422 * @pAdapter: pointer to adapter
2423 * @pRoamInfo: pointer to roam info
2424 * @roamId: roam id
2425 * @roamStatus: roam status
2426 * @roamResult: roam result
2427 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302428 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302430static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 tCsrRoamInfo *pRoamInfo,
2432 uint32_t roamId,
2433 eRoamCmdStatus roamStatus,
2434 eCsrRoamResult roamResult)
2435{
2436 eCsrEncryptionType connectedCipherAlgo;
2437 bool fConnected = false;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002438 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302439
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 ENTER();
2441
2442 if (NULL == pRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002443 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302444 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002445 }
2446 /*
2447 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2448 * then go to 'authenticated'. For all other authentication types
2449 * (those that do not require upper layer authentication) we can put TL
2450 * directly into 'authenticated' state.
2451 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002452 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 MAC_ADDRESS_STR, roamStatus, roamResult,
2454 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2455
2456 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2457 &connectedCipherAlgo);
2458 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002459 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2460 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 } else {
2462 /*
2463 * possible disassoc after issuing set key and waiting
2464 * set key complete.
2465 */
2466 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2467 }
2468
2469 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302470 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471}
2472
2473/**
2474 * hdd_perform_roam_set_key_complete() - perform set key complete
2475 * @pAdapter: pointer to adapter
2476 *
2477 * Return: none
2478 */
2479void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2480{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302481 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002482 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 tCsrRoamInfo roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302486 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302487 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302488 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302489 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302491 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 hdd_roam_set_key_complete_handler(pAdapter,
2493 &roamInfo,
2494 pHddStaCtx->roam_info.roamId,
2495 pHddStaCtx->roam_info.roamStatus,
2496 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302497 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002498 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499
2500 pHddStaCtx->roam_info.deferKeyComplete = false;
2501}
2502
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302503#if defined(WLAN_FEATURE_FILS_SK) && defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT)
2504void hdd_clear_fils_connection_info(hdd_adapter_t *adapter)
2505{
2506 hdd_wext_state_t *wext_state;
2507
2508 if ((adapter->device_mode == QDF_SAP_MODE) ||
2509 (adapter->device_mode == QDF_P2P_GO_MODE))
2510 return;
2511
2512 wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
2513 if (wext_state->roamProfile.fils_con_info) {
2514 qdf_mem_free(wext_state->roamProfile.fils_con_info);
2515 wext_state->roamProfile.fils_con_info = NULL;
2516 }
2517}
2518#endif
2519
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520/**
2521 * hdd_association_completion_handler() - association completion handler
2522 * @pAdapter: pointer to adapter
2523 * @pRoamInfo: pointer to roam info
2524 * @roamId: roam id
2525 * @roamStatus: roam status
2526 * @roamResult: roam result
2527 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302528 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302530static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531 tCsrRoamInfo *pRoamInfo,
2532 uint32_t roamId,
2533 eRoamCmdStatus roamStatus,
2534 eCsrRoamResult roamResult)
2535{
2536 struct net_device *dev = pAdapter->dev;
Jeff Johnson49432062017-08-28 12:08:45 -07002537 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002538 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302539 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002541 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 bool hddDisconInProgress = false;
2544 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302545 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302546 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547
2548 if (!pHddCtx) {
2549 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302550 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551 }
2552
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302553 /* validate config */
2554 if (!pHddCtx->config) {
2555 hdd_err("config is NULL");
2556 return QDF_STATUS_E_NULL_VALUE;
2557 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 /* HDD has initiated disconnect, do not send connect result indication
2559 * to kernel as it will be handled by __cfg80211_disconnect.
2560 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302561 if (((eConnectionState_Disconnecting ==
2562 pHddStaCtx->conn_info.connState) ||
2563 (eConnectionState_NotConnected ==
2564 pHddStaCtx->conn_info.connState)) &&
2565 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2566 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002567 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
2568 pHddStaCtx->conn_info.connState,
2569 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570 hddDisconInProgress = true;
2571 }
2572
2573 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2574 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002575 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302576 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 }
2578 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 hdd_conn_set_connection_state(pAdapter,
2580 eConnectionState_Associated);
2581 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 /* Save the connection info from CSR... */
2584 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2585 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002586
2587 if (hdd_add_beacon_filter(pAdapter) != 0)
2588 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589#ifdef FEATURE_WLAN_WAPI
2590 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2591 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2592 || pRoamInfo->u.pConnectedProfile->AuthType ==
2593 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2594 pAdapter->wapi_info.fIsWapiSta = 1;
2595 } else {
2596 pAdapter->wapi_info.fIsWapiSta = 0;
2597 }
2598#endif /* FEATURE_WLAN_WAPI */
Krunal Soni364e0872017-05-10 21:24:34 -07002599 hdd_debug("bss_descr[%d] devicemode[%d]", !!pRoamInfo->pBssDesc,
2600 pAdapter->device_mode);
2601 if ((QDF_STA_MODE == pAdapter->device_mode) &&
2602 pRoamInfo->pBssDesc) {
2603 ie_len = GET_IE_LEN_IN_BSS(pRoamInfo->pBssDesc->length);
2604 pHddStaCtx->ap_supports_immediate_power_save =
2605 wlan_hdd_is_ap_supports_immediate_power_save(
2606 (uint8_t *) pRoamInfo->pBssDesc->ieFields,
2607 ie_len);
2608 hdd_debug("ap_supports_immediate_power_save flag [%d]",
2609 pHddStaCtx->ap_supports_immediate_power_save);
2610 }
2611
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 /* Indicate 'connect' status to user space */
2613 hdd_send_association_event(dev, pRoamInfo);
2614
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002615 if (policy_mgr_is_mcc_in_24G(pHddCtx->hdd_psoc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 if (pHddCtx->miracast_value)
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002617 wlan_hdd_set_mas(pAdapter,
2618 pHddCtx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 }
2620
2621 /* Initialize the Linkup event completion variable */
2622 INIT_COMPLETION(pAdapter->linkup_event_var);
2623
2624 /*
2625 * Sometimes Switching ON the Carrier is taking time to activate
2626 * the device properly. Before allowing any packet to go up to
2627 * the application, device activation has to be ensured for
2628 * proper queue mapping by the kernel. we have registered net
2629 * device notifier for device change notification. With this we
2630 * will come to know that the device is getting
2631 * activated properly.
2632 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002634 /*
2635 * Enable Linkup Event Servicing which allows the net
2636 * device notifier to set the linkup event variable.
2637 */
2638 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002640 /* Switch on the Carrier to activate the device */
2641 wlan_hdd_netif_queue_control(pAdapter,
2642 WLAN_NETIF_CARRIER_ON,
2643 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002645 /*
2646 * Wait for the Link to up to ensure all the queues
2647 * are set properly by the kernel.
2648 */
2649 rc = wait_for_completion_timeout(
2650 &pAdapter->linkup_event_var,
2651 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2652 );
2653 if (!rc)
2654 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002656 /*
2657 * Disable Linkup Event Servicing - no more service
2658 * required from the net device notifier call.
2659 */
2660 pAdapter->isLinkUpSvcNeeded = false;
2661 } else {
2662 pHddStaCtx->ft_carrier_on = false;
2663 ft_carrier_on = true;
2664 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2666 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2667 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002668 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669
2670 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2671
2672 if (hdd_ipa_is_enabled(pHddCtx))
2673 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002674 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 pRoamInfo->bssid.bytes);
2676
2677#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2678 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2679#endif
2680
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302681 hdd_debug("check if STA chan ok for DNBS");
2682 if (policy_mgr_is_chan_ok_for_dnbs(pHddCtx->hdd_psoc,
2683 pHddStaCtx->conn_info.operationChannel,
2684 &ok)) {
2685 hdd_err("Unable to check DNBS eligibility for chan:%d",
2686 pHddStaCtx->conn_info.operationChannel);
2687 return QDF_STATUS_E_FAILURE;
2688 }
2689
2690 if (!ok) {
2691 hdd_err("Chan:%d not suitable for DNBS",
2692 pHddStaCtx->conn_info.operationChannel);
2693 wlan_hdd_netif_queue_control(pAdapter,
2694 WLAN_NETIF_CARRIER_OFF,
2695 WLAN_CONTROL_PATH);
2696 if (!hddDisconInProgress) {
2697 hdd_err("Disconnecting...");
2698 sme_roam_disconnect(
2699 WLAN_HDD_GET_HAL_CTX(pAdapter),
2700 pAdapter->sessionId,
2701 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2702 }
2703 return QDF_STATUS_E_FAILURE;
2704 }
2705
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002706 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002707 policy_mgr_check_concurrent_intf_and_restart_sap(
2708 pHddCtx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709
Nirav Shah1da77682016-05-03 20:16:39 +05302710 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2711 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002712 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302713 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 /*
2716 * For reassoc, the station is already registered, all we need
2717 * is to change the state of the STA in TL.
2718 * If authentication is required (WPA/WPA2/DWEP), change TL to
2719 * CONNECTED instead of AUTHENTICATED.
2720 */
2721 if (!pRoamInfo->fReassocReq) {
2722 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 u8 *pFTAssocRsp = NULL;
2724 unsigned int assocRsplen = 0;
2725 u8 *pFTAssocReq = NULL;
2726 unsigned int assocReqlen = 0;
2727 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2729 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2730
2731 /* add bss_id to cfg80211 data base */
2732 bss =
2733 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2734 pRoamInfo);
2735 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302736 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 wlan_hdd_netif_queue_control(pAdapter,
2738 WLAN_NETIF_CARRIER_OFF,
2739 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302740 if (!hddDisconInProgress) {
2741 /*
2742 * Here driver was not able to add bss
2743 * in cfg80211 database this can happen
2744 * if connected channel is not valid,
2745 * i.e reg domain was changed during
2746 * connection. Queue disconnect for the
2747 * session if disconnect is not in
2748 * progress.
2749 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002750 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302751 sme_roam_disconnect(
2752 WLAN_HDD_GET_HAL_CTX(pAdapter),
2753 pAdapter->sessionId,
2754 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2755 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302756 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2759 eCSR_AUTH_TYPE_FT_RSN
2760 || pRoamInfo->u.pConnectedProfile->AuthType ==
2761 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2762
2763 /* Association Response */
2764 pFTAssocRsp =
2765 (u8 *) (pRoamInfo->pbFrames +
2766 pRoamInfo->nBeaconLength +
2767 pRoamInfo->nAssocReqLength);
2768 if (pFTAssocRsp != NULL) {
2769 /*
2770 * pFTAssocRsp needs to point to the IEs
2771 */
2772 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002773 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002774 (unsigned int)pFTAssocRsp[0],
2775 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 assocRsplen =
2777 pRoamInfo->nAssocRspLength -
2778 FT_ASSOC_RSP_IES_OFFSET;
2779 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002780 hdd_debug("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 assocRsplen = 0;
2782 }
2783
2784 /* Association Request */
2785 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2786 pRoamInfo->nBeaconLength);
2787 if (pFTAssocReq != NULL) {
2788 if (!ft_carrier_on) {
2789 /*
2790 * pFTAssocReq needs to point to
2791 * the IEs
2792 */
2793 pFTAssocReq +=
2794 FT_ASSOC_REQ_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002795 hdd_debug("pFTAssocReq is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002796 (unsigned int)
2797 pFTAssocReq[0],
2798 (unsigned int)
2799 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 assocReqlen =
2801 pRoamInfo->nAssocReqLength -
2802 FT_ASSOC_REQ_IES_OFFSET;
2803 } else {
2804 /*
2805 * This should contain only the
2806 * FTIEs
2807 */
2808 assocReqlen =
2809 pRoamInfo->nAssocReqLength;
2810 }
2811 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002812 hdd_debug("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 assocReqlen = 0;
2814 }
2815
2816 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08002817 if (!hddDisconInProgress &&
2818 pRoamInfo->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302819 struct cfg80211_bss *roam_bss;
2820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 /*
2822 * After roaming is completed,
2823 * active session count is
2824 * incremented as a part of
2825 * connect indication but
2826 * effectively the active
2827 * session count should still
2828 * be the same and hence upon
2829 * successful reassoc
2830 * decrement the active session
2831 * count here.
2832 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002833 if (!hdd_is_roam_sync_in_progress
2834 (pRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002835 policy_mgr_decr_session_set_pcl(
2836 pHddCtx->hdd_psoc,
2837 pAdapter->device_mode,
2838 pAdapter->sessionId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002839 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002840 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 chan =
2842 ieee80211_get_channel
2843 (pAdapter->wdev.wiphy,
2844 (int)pRoamInfo->pBssDesc->
2845 channelId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002846 hdd_debug(
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002847 "assocReqlen %d assocRsplen %d",
2848 assocReqlen,
2849 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002850
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002851 hdd_debug(
Naveen Rawat14298b92015-11-25 16:27:41 -08002852 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302853 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302854 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302855 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002856 pFTAssocReq,
2857 assocReqlen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302858 roam_bss =
2859 hdd_cfg80211_get_bss(
2860 pAdapter->wdev.wiphy,
2861 chan,
2862 pRoamInfo->bssid.bytes,
2863 pRoamInfo->u.
2864 pConnectedProfile->SSID.ssId,
2865 pRoamInfo->u.
2866 pConnectedProfile->SSID.length);
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302867 hdd_send_roamed_ind(
2868 dev,
2869 roam_bss,
2870 pFTAssocReq,
2871 assocReqlen,
2872 pFTAssocRsp,
2873 assocRsplen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302874 wlan_hdd_send_roam_auth_event(
2875 pAdapter,
2876 pRoamInfo->bssid.bytes,
2877 pFTAssocReq,
2878 assocReqlen,
2879 pFTAssocRsp,
2880 assocRsplen,
2881 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882 }
2883 if (sme_get_ftptk_state
2884 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2885 pAdapter->sessionId)) {
2886 sme_set_ftptk_state
2887 (WLAN_HDD_GET_HAL_CTX
2888 (pAdapter),
2889 pAdapter->sessionId,
2890 false);
2891 pRoamInfo->fAuthRequired =
2892 false;
2893
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302894 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 roam_info.bssid,
2896 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302897 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302898 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 roam_info.peerMac,
2900 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302901 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 pHddStaCtx->roam_info.roamId =
2903 roamId;
2904 pHddStaCtx->roam_info.
2905 roamStatus = roamStatus;
2906 pHddStaCtx->roam_info.
2907 deferKeyComplete = true;
2908 }
2909 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002910 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002911 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302912 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302913 pRoamInfo->
2914 bssid.bytes,
2915 pRoamInfo,
2916 pFTAssocReq,
2917 assocReqlen,
2918 pFTAssocRsp,
2919 assocRsplen,
2920 WLAN_STATUS_SUCCESS,
2921 GFP_KERNEL,
2922 false,
2923 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002925 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926 /*
2927 * wpa supplicant expecting WPA/RSN IE in
2928 * connect result.
2929 */
2930 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2931 (pAdapter),
2932 pAdapter->sessionId,
2933 &reqRsnLength,
2934 reqRsnIe);
2935
2936 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2937 (pAdapter),
2938 pAdapter->sessionId,
2939 &rspRsnLength,
2940 rspRsnIe);
2941 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 if (ft_carrier_on)
2943 hdd_send_re_assoc_event(dev,
2944 pAdapter,
2945 pRoamInfo,
2946 reqRsnIe,
2947 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002948 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002949 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002950 MAC_ADDRESS_STR
2951 " result:%d and Status:%d",
2952 MAC_ADDR_ARRAY
2953 (pRoamInfo->bssid.bytes),
2954 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955
2956 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302957 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302958 pRoamInfo->
2959 bssid.bytes,
2960 pRoamInfo,
2961 reqRsnIe,
2962 reqRsnLength,
2963 rspRsnIe,
2964 rspRsnLength,
2965 WLAN_STATUS_SUCCESS,
2966 GFP_KERNEL,
2967 false,
2968 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 }
2970 }
2971 }
2972 if (!hddDisconInProgress) {
2973 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 bss);
2976
2977 /*
2978 * Perform any WMM-related association
2979 * processing.
2980 */
2981 hdd_wmm_assoc(pAdapter, pRoamInfo,
2982 eCSR_BSS_TYPE_INFRASTRUCTURE);
2983
2984 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002985 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002987 qdf_status = hdd_roam_register_sta(pAdapter,
2988 pRoamInfo,
2989 pHddStaCtx->conn_info.staId[0],
2990 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002991 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 wlan_hdd_netif_queue_control(pAdapter,
2993 WLAN_WAKE_ALL_NETIF_QUEUE,
2994 WLAN_CONTROL_PATH);
2995
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996 }
2997 } else {
2998 /*
2999 * wpa supplicant expecting WPA/RSN IE in connect result
3000 * in case of reassociation also need to indicate it to
3001 * supplicant.
3002 */
3003 csr_roam_get_wpa_rsn_req_ie(
3004 WLAN_HDD_GET_HAL_CTX(pAdapter),
3005 pAdapter->sessionId,
3006 &reqRsnLength, reqRsnIe);
3007
3008 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
3009 reqRsnIe, reqRsnLength);
3010 /* Reassoc successfully */
3011 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303012 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 hdd_change_peer_state(pAdapter,
3014 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003015 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3017 pRoamInfo->roamSynchInProgress
3018#else
3019 false
3020#endif
3021 );
3022 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003023 hdd_objmgr_set_peer_mlme_auth_state(
3024 pAdapter->hdd_vdev,
3025 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003027 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003028 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303029 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 hdd_change_peer_state(pAdapter,
3031 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003032 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3034 pRoamInfo->roamSynchInProgress
3035#else
3036 false
3037#endif
3038 );
3039 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003040 hdd_objmgr_set_peer_mlme_auth_state(
3041 pAdapter->hdd_vdev,
3042 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 }
3044
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303045 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 /*
3047 * Perform any WMM-related association
3048 * processing
3049 */
3050 hdd_wmm_assoc(pAdapter, pRoamInfo,
3051 eCSR_BSS_TYPE_INFRASTRUCTURE);
3052 }
3053
3054 /* Start the tx queues */
3055#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3056 if (pRoamInfo->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003057 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003059 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 wlan_hdd_netif_queue_control(pAdapter,
3061 WLAN_WAKE_ALL_NETIF_QUEUE,
3062 WLAN_CONTROL_PATH);
3063 }
3064
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05303065#ifdef FEATURE_WLAN_TDLS
3066 wlan_hdd_tdls_connection_callback(pAdapter);
3067#endif
3068
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303069 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003070 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303071 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 }
3073#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303074 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003075 sizeof(pAdapter->hdd_stats.hddPmfStats));
3076#endif
3077 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05303078 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 hdd_wext_state_t *pWextState =
3080 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3081 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303082 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003083 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303084 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3085 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303087 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003088 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303089 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3090 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05303091
3092 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
3093 (pRoamInfo &&
3094 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
3095 pRoamInfo->statusCode) ||
3096 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
3097 pRoamInfo->statusCode) ||
3098 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
3099 pRoamInfo->statusCode)))) {
3100 wlan_hdd_cfg80211_update_bss_list(pAdapter,
3101 pRoamInfo ?
3102 pRoamInfo->bssid.bytes :
3103 pWextState->req_bssId.bytes);
3104 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
3105 pRoamInfo ?
3106 pRoamInfo->bssid.bytes :
3107 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303108 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303109 }
3110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 /*
3112 * CR465478: Only send up a connection failure result when CSR
3113 * has completed operation - with a ASSOCIATION_FAILURE status.
3114 */
3115 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3116 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303117 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003118 hdd_err("send connect failure to nl80211: for bssid "
3119 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003120 " result: %d and Status: %d reasoncode: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003121 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3122 roamResult, roamStatus,
3123 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303124 pHddStaCtx->conn_info.assoc_status_code =
3125 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003126 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003127 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003129 " result: %d and status: %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3131 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003132 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003133 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303134 wlan_deregister_txrx_packetdump();
3135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 /* inform association failure event to nl80211 */
3137 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3138 roamResult) {
3139 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303140 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 pRoamInfo->bssid.bytes,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05303142 pRoamInfo, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303144 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303145 connect_timeout,
3146 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303148 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303150 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303152 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303153 connect_timeout,
3154 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 } else {
Wu Gao77d28352016-11-23 17:50:56 +08003156 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303157 hdd_connect_result(dev,
3158 pRoamInfo->bssid.bytes,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05303159 pRoamInfo, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08003160 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05303161 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303163 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303164 connect_timeout,
3165 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003166 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303167 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303169 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303171 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303172 connect_timeout,
3173 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 }
Abhishek Singhac2be142015-12-03 16:16:25 +05303175 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003176 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3177 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05303178 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003179 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05303180 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003181 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303182 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303183 connect_timeout,
3184 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 }
3186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 /*
3188 * Set connection state to eConnectionState_NotConnected only
3189 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003190 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003192 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3193 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 hdd_conn_set_connection_state(pAdapter,
3196 eConnectionState_NotConnected);
3197 }
3198 hdd_wmm_init(pAdapter);
3199
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003200 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303202 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 WLAN_CONTROL_PATH);
3204 }
3205
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303206 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207}
3208
3209/**
3210 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
3211 * @pAdapter: pointer to adapter
3212 * @pRoamInfo: pointer to roam info
3213 * @roamId: roam id
3214 * @roamStatus: roam status
3215 * @roamResult: roam result
3216 *
3217 * Here we update the status of the Ibss when we receive information that we
3218 * have started/joined an ibss session.
3219 *
3220 * Return: none
3221 */
3222static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3223 tCsrRoamInfo *pRoamInfo,
3224 uint32_t roamId,
3225 eRoamCmdStatus roamStatus,
3226 eCsrRoamResult roamResult)
3227{
Jeff Johnson49432062017-08-28 12:08:45 -07003228 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003229
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003230 hdd_debug("%s: id %d, status %d, result %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003231 pAdapter->dev->name, roamId,
3232 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233
3234 switch (roamResult) {
3235 /* both IBSS Started and IBSS Join should come in here. */
3236 case eCSR_ROAM_RESULT_IBSS_STARTED:
3237 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3238 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3239 {
Jeff Johnson49432062017-08-28 12:08:45 -07003240 struct hdd_context *pHddCtx =
3241 (struct hdd_context *) pAdapter->pHddCtx;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003242 struct hdd_station_ctx *hdd_sta_ctx =
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303243 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303244 struct qdf_mac_addr broadcastMacAddr =
3245 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246
3247 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303248 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 return;
3250 }
3251
3252 /* When IBSS Started comes from CSR, we need to move
3253 * connection state to IBSS Disconnected (meaning no peers
3254 * are in the IBSS).
3255 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 hdd_conn_set_connection_state(pAdapter,
3257 eConnectionState_IbssDisconnected);
3258 /* notify wmm */
3259 hdd_wmm_connect(pAdapter, pRoamInfo,
3260 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303261
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003262 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303263
3264 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 pAdapter;
3266 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303267 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 &broadcastMacAddr,
3269 pRoamInfo->pBssDesc);
3270
3271 if (pRoamInfo->pBssDesc) {
3272 struct cfg80211_bss *bss;
3273#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3274 struct ieee80211_channel *chan;
3275 int chan_no;
3276 unsigned int freq;
3277#endif
3278 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003279 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3280 pAdapter->dev->name,
3281 MAC_ADDR_ARRAY(
3282 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283
3284 /* we must first give cfg80211 the BSS information */
3285 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3286 pRoamInfo);
3287 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003288 hdd_err("%s: unable to create IBSS entry",
3289 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 return;
3291 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003292 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 wlan_hdd_netif_queue_control(pAdapter,
3294 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3295 WLAN_CONTROL_PATH);
3296
3297#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3298 chan_no = pRoamInfo->pBssDesc->channelId;
3299
3300 if (chan_no <= 14)
3301 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003302 HDD_NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 else
3304 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003305 HDD_NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306
3307 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3308
3309 if (chan)
3310 cfg80211_ibss_joined(pAdapter->dev,
3311 bss->bssid, chan,
3312 GFP_KERNEL);
3313 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003314 hdd_warn("%s: chanId: %d, can't find channel",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003315 pAdapter->dev->name,
3316 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317#else
3318 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3319 GFP_KERNEL);
3320#endif
3321 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 bss);
3324 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003325 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003326 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
3327 pAdapter->device_mode, pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003328 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3329 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003330 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
3331 pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003332 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 break;
3334 }
3335
3336 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3337 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003338 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 break;
3340 }
3341
3342 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003343 hdd_err("%s: unexpected result %d",
3344 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 break;
3346 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347}
3348
3349/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003350 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3351 * @sta_ctx: pointer to hdd station context
3352 * @sta_id: station ID
3353 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354 *
3355 * This information is passed to iwconfig later. The peer that joined
3356 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003357
3358 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003360bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003361 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003363 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003365 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303366 if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003367 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003368 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003369 sta_ctx->conn_info.staId[idx] = sta_id;
3370 qdf_copy_macaddr(
3371 &sta_ctx->conn_info.peerMacAddress[idx],
3372 peer_mac_addr);
3373 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 }
3375 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003376 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377}
3378
3379/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003380 * hdd_delete_peer() - removes peer from hdd station context peer table
3381 * @sta_ctx: pointer to hdd station context
3382 * @sta_id: station ID
3383 *
3384 * Return: None
3385 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003386void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id)
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003387{
3388 int i;
3389
3390 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3391 if (sta_id == sta_ctx->conn_info.staId[i]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303392 sta_ctx->conn_info.staId[i] = HDD_WLAN_INVALID_STA_ID;
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003393 return;
3394 }
3395 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003396}
3397
3398/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3400 * @pAdapter: pointer to adapter
3401 * @staId: station id
3402 *
3403 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003404 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 * false otherwise.
3406 */
3407static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3408{
3409 bool fSuccess = false;
3410 int idx = 0;
3411 uint8_t valid_idx = 0;
3412 uint8_t del_idx = 0;
3413 uint8_t empty_slots = 0;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003414 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415
Naveen Rawatc45d1622016-07-05 12:20:09 -07003416 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 if (staId == pHddStaCtx->conn_info.staId[idx]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303418 pHddStaCtx->conn_info.staId[idx] =
3419 HDD_WLAN_INVALID_STA_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420
Anurag Chouhanc5548422016-02-24 18:33:27 +05303421 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 peerMacAddress[idx]);
3423
3424 fSuccess = true;
3425
3426 /*
3427 * Note the deleted Index, if its 0 we need special
3428 * handling.
3429 */
3430 del_idx = idx;
3431
3432 empty_slots++;
3433 } else {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003434 if (pHddStaCtx->conn_info.staId[idx] !=
3435 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 valid_idx = idx;
3437 } else {
3438 /* Found an empty slot */
3439 empty_slots++;
3440 }
3441 }
3442 }
3443
Naveen Rawatc45d1622016-07-05 12:20:09 -07003444 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 /* Last peer departed, set the IBSS state appropriately */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003446 hdd_conn_set_connection_state(pAdapter,
3447 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003448 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 }
3450 /* Find next active staId, to have a valid sta trigger for TL. */
3451 if (fSuccess == true) {
3452 if (del_idx == 0) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003453 if (pHddStaCtx->conn_info.staId[valid_idx] !=
3454 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 pHddStaCtx->conn_info.staId[0] =
3456 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303457 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 peerMacAddress[0],
3459 &pHddStaCtx->conn_info.
3460 peerMacAddress[valid_idx]);
3461
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303462 pHddStaCtx->conn_info.staId[valid_idx] =
3463 HDD_WLAN_INVALID_STA_ID;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303464 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 peerMacAddress[valid_idx]);
3466 }
3467 }
3468 }
3469 return fSuccess;
3470}
3471
3472/**
3473 * roam_ibss_connect_handler() - IBSS connection handler
3474 * @pAdapter: pointer to adapter
3475 * @pRoamInfo: pointer to roam info
3476 *
3477 * We update the status of the IBSS to connected in this function.
3478 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303479 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303481static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 tCsrRoamInfo *pRoamInfo)
3483{
3484 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 /*
3486 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3487 * a partner stations).
3488 */
3489 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3490
3491 /* Save the connection info from CSR... */
3492 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3493
3494 /* Send the bssid address to the wext. */
3495 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3496 /* add bss_id to cfg80211 data base */
3497 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3498 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003499 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303501 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502 }
3503 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 bss);
3506
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303507 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508}
3509
3510/**
3511 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3512 * @pAdapter: pointer to adapter
3513 * @pRoamInfo: pointer to roam info
3514 * @roamId: roam id
3515 * @roamStatus: roam status
3516 * @roamResult: roam result
3517 *
3518 * This function indicates the Mic failure to the supplicant
3519 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303520 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303522static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3524 tCsrRoamInfo *pRoamInfo,
3525 uint32_t roamId,
3526 eRoamCmdStatus roamStatus,
3527 eCsrRoamResult roamResult)
3528{
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003529 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530
3531 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3532 TKIP_COUNTER_MEASURE_STOPED ==
3533 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3534 struct iw_michaelmicfailure msg;
3535 union iwreq_data wreq;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 memset(&msg, '\0', sizeof(msg));
3538 msg.src_addr.sa_family = ARPHRD_ETHER;
3539 memcpy(msg.src_addr.sa_data,
3540 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3541 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003542 hdd_debug("MIC MAC " MAC_ADDRESS_STR,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003543 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07003545 if (pRoamInfo->u.pMICFailureInfo->multicast == true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 msg.flags = IW_MICFAILURE_GROUP;
3547 else
3548 msg.flags = IW_MICFAILURE_PAIRWISE;
3549 memset(&wreq, 0, sizeof(wreq));
3550 wreq.data.length = sizeof(msg);
3551 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3552 (char *)&msg);
3553 /* inform mic failure to nl80211 */
3554 cfg80211_michael_mic_failure(pAdapter->dev,
3555 pRoamInfo->u.pMICFailureInfo->
3556 taMacAddr,
3557 ((pRoamInfo->u.pMICFailureInfo->
3558 multicast ==
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07003559 true) ?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 NL80211_KEYTYPE_GROUP :
3561 NL80211_KEYTYPE_PAIRWISE),
3562 pRoamInfo->u.pMICFailureInfo->
3563 keyId,
3564 pRoamInfo->u.pMICFailureInfo->TSC,
3565 GFP_KERNEL);
3566
3567 }
3568
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303569 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570}
3571
3572/**
3573 * roam_roam_connect_status_update_handler() - IBSS connect status update
3574 * @pAdapter: pointer to adapter
3575 * @pRoamInfo: pointer to roam info
3576 * @roamId: roam id
3577 * @roamStatus: roam status
3578 * @roamResult: roam result
3579 *
3580 * The Ibss connection status is updated regularly here in this function.
3581 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303582 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303584static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3586 tCsrRoamInfo *pRoamInfo,
3587 uint32_t roamId,
3588 eRoamCmdStatus roamStatus,
3589 eCsrRoamResult roamResult)
3590{
Jeff Johnson49432062017-08-28 12:08:45 -07003591 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003592 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 switch (roamResult) {
3595 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3596 {
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003597 struct hdd_station_ctx *pHddStaCtx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003599 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003600 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003602 hdd_info("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303603 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3604 MAC_ADDRESS_STR " and stationID= %d",
3605 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3606 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3607 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003609 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3611 pRoamInfo->staId,
3612 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003613 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 break;
3615 }
3616
3617 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3618
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003619 if (hdd_is_key_install_required_for_ibss(encr_type))
3620 pRoamInfo->fAuthRequired = true;
3621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303623 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624 pRoamInfo,
3625 pRoamInfo->staId,
3626 &pRoamInfo->peerMac,
3627 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303628 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003629 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303630 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 }
3632 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003633 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3634 if (stainfo == NULL) {
3635 hdd_err("memory allocation for station_info failed");
3636 return QDF_STATUS_E_NOMEM;
3637 }
3638 stainfo->filled = 0;
3639 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640
3641 cfg80211_new_sta(pAdapter->dev,
3642 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003643 stainfo, GFP_KERNEL);
3644 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003646 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 pHddStaCtx->ibss_enc_key.keyDirection =
3648 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303649 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 &pRoamInfo->peerMac);
3651
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003652 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003653 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303655 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3657 (pAdapter),
3658 pAdapter->sessionId,
3659 &pHddStaCtx->ibss_enc_key,
3660 &roamId);
3661
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303662 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003663 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003664 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303665 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 }
3667 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003668 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 wlan_hdd_netif_queue_control(pAdapter,
3670 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3671 WLAN_CONTROL_PATH);
3672 break;
3673 }
3674
3675 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3676 {
3677
3678 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3679
3680 break;
3681 }
3682 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3683 {
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003684 struct hdd_station_ctx *pHddStaCtx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3686
3687 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003688 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003690 hdd_info("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303691 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3692 MAC_ADDRESS_STR " and stationID= %d",
3693 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3694 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3695 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696
3697 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3698
3699 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3700 pHddStaCtx->ibss_sta_generation++;
3701
3702 cfg80211_del_sta(pAdapter->dev,
3703 (const u8 *)&pRoamInfo->peerMac.bytes,
3704 GFP_KERNEL);
3705 break;
3706 }
3707 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3708 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003709 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003711 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303713 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715 hdd_conn_set_connection_state(pAdapter,
3716 eConnectionState_NotConnected);
3717
3718 /* Send the bssid address to the wext. */
3719 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3720 break;
3721 }
3722 default:
3723 break;
3724
3725 }
3726
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303727 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728}
3729
3730#ifdef FEATURE_WLAN_TDLS
3731/**
3732 * hdd_roam_register_tdlssta() - register new TDLS station
3733 * @pAdapter: pointer to adapter
3734 * @peerMac: pointer to peer MAC address
3735 * @staId: station identifier
3736 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303737 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738 *
3739 * Construct the staDesc and register with TL the new STA.
3740 * This is called as part of ADD_STA in the TDLS setup.
3741 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303742 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303744QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303746 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303748 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003750 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003751 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3752 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753
3754 /*
3755 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3756 * be peer MAC, here we are working on direct Link
3757 */
3758 staDesc.sta_id = staId;
3759
3760 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303761 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762
Dhanashri Atre50141c52016-04-07 13:15:29 -07003763 /* Register the vdev transmit and receive functions */
3764 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3765 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003766 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003767 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3768 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003769 pAdapter, &txrx_ops);
3770 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771
3772 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003773 qdf_status = cdp_peer_register(soc,
3774 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303775 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003776 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303777 qdf_status, qdf_status);
3778 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779 }
3780
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782}
3783
3784/**
3785 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3786 * @pAdapter: pointer to adapter
3787 * @staId: station identifier
3788 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 */
Nitesh Shah99dd9552017-03-20 19:27:47 +05303791QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303793 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003794 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003795 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3796 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303797 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003798 hdd_err("cdp_clear_peer() failed for staID: %d Status: %d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003799 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303801 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802}
3803
3804/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003805 * hdd_tdls_connection_tracker_update() - update connection tracker state
3806 * @adapter: pointer to adapter
3807 * @roam_info: pointer to roam info
3808 * @hdd_tdls_ctx: tdls context
3809 *
3810 * Return: QDF_STATUS enumeration
3811 */
3812static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3813 tCsrRoamInfo *roam_info,
3814 tdlsCtx_t *hdd_tdls_ctx)
3815{
3816 hddTdlsPeer_t *curr_peer;
Jeff Johnson49432062017-08-28 12:08:45 -07003817 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003818
3819 curr_peer = wlan_hdd_tdls_find_peer(adapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303820 roam_info->peerMac.bytes);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003821
3822 if (!curr_peer) {
3823 hdd_err("curr_peer is null");
3824 return QDF_STATUS_E_FAILURE;
3825 }
3826
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003827 if (eTDLS_LINK_CONNECTED ==
3828 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003829 hdd_debug("Received CONNECTION_TRACKER_NOTIFICATION "
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003830 MAC_ADDRESS_STR
3831 " staId: %d, reason: %d",
3832 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3833 roam_info->staId,
3834 roam_info->reasonCode);
3835
3836 if (roam_info->reasonCode ==
3837 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3838 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003839 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3840 roam_info->reasonCode ==
3841 eWMI_TDLS_SCAN_STARTED_EVENT)
3842 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003843 else if (roam_info->reasonCode ==
3844 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3845 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003846 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3847 roam_info->reasonCode ==
3848 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3849 hdd_ctx->enable_tdls_connection_tracker = true;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003850 hdd_debug("hdd_ctx->enable_tdls_connection_tracker %d",
Nitesh Shahc549dd52017-02-23 16:45:44 +05303851 hdd_ctx->enable_tdls_connection_tracker);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003852 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003853 hdd_debug("TDLS not connected, ignore notification, reason: %d",
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003854 roam_info->reasonCode);
3855 }
3856
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003857 return QDF_STATUS_SUCCESS;
3858}
3859
3860
3861
3862
3863/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3865 * @pAdapter: pointer to adapter
3866 * @pRoamInfo: pointer to roam info
3867 * @roamId: roam id
3868 * @roamStatus: roam status
3869 * @roamResult: roam result
3870 *
3871 * HDD interface between SME and TL to ensure TDLS client registration with
3872 * TL in case of new TDLS client is added and deregistration at the time
3873 * TDLS client is deleted.
3874 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303875 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303877static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3879 tCsrRoamInfo *pRoamInfo,
3880 uint32_t roamId,
3881 eRoamCmdStatus roamStatus,
3882 eCsrRoamResult roamResult)
3883{
Jeff Johnson49432062017-08-28 12:08:45 -07003884 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303885 tdlsCtx_t *pHddTdlsCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303887 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 uint8_t staIdx;
3889 hddTdlsPeer_t *curr_peer;
3890 uint32_t reason;
3891
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003892 hdd_debug("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003893 roamResult ==
3894 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3895 ==
3896 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3897 roamResult ==
3898 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3899 : roamResult ==
3900 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3901 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3902 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3903 roamResult ==
3904 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3905 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3906 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3907 : roamResult ==
3908 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3909 : roamResult ==
3910 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3911 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3912 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 switch (roamResult) {
3915 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3916 {
3917 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003918 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303920 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921 } else {
3922 /*
3923 * Check if there is available index for this new TDLS
3924 * STA.
3925 */
3926 for (staIdx = 0;
3927 staIdx < pHddCtx->max_num_tdls_sta;
3928 staIdx++) {
3929 if (0 ==
3930 pHddCtx->tdlsConnInfo[staIdx].
3931 staId) {
3932 pHddCtx->tdlsConnInfo[staIdx].
3933 sessionId =
3934 pRoamInfo->sessionId;
3935 pHddCtx->tdlsConnInfo[staIdx].
3936 staId = pRoamInfo->staId;
3937
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003938 hdd_debug("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003940 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 staIdx,
3942 pHddCtx->
3943 tdlsConnInfo[staIdx].
3944 staId,
3945 MAC_ADDR_ARRAY
3946 (pRoamInfo->peerMac.bytes));
3947
Anurag Chouhanc5548422016-02-24 18:33:27 +05303948 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 tdlsConnInfo
3950 [staIdx].
3951 peerMac,
3952 &pRoamInfo->
3953 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303954 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955 break;
3956 }
3957 }
3958 if (staIdx < pHddCtx->max_num_tdls_sta) {
3959 if (-1 ==
3960 wlan_hdd_tdls_set_sta_id(pAdapter,
3961 pRoamInfo->
3962 peerMac.bytes,
3963 pRoamInfo->
3964 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003965 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303966 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 }
3968
3969 (WLAN_HDD_GET_CTX(pAdapter))->
3970 sta_to_adapter[pRoamInfo->staId] =
3971 pAdapter;
3972 /*
3973 * store the ucast signature,
3974 * if required for further reference.
3975 */
3976
3977 wlan_hdd_tdls_set_signature(pAdapter,
3978 pRoamInfo->
3979 peerMac.bytes,
3980 pRoamInfo->
3981 ucastSig);
3982 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303983 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003984 hdd_debug("no available slot in conn_info. staId: %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 pRoamInfo->staId);
3986 }
3987 pAdapter->tdlsAddStaStatus = status;
3988 }
3989 complete(&pAdapter->tdls_add_station_comp);
3990 break;
3991 }
3992 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3993 {
3994 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003995 hdd_err("Add Sta failed. status code: %d",
Varun Reddy Yeturued1215e2017-07-07 16:40:28 -07003996 pRoamInfo->statusCode);
3997 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3998 } else {
3999 pAdapter->tdlsAddStaStatus = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 complete(&pAdapter->tdls_add_station_comp);
4002 break;
4003 }
4004 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
4005 {
4006 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004007 hdd_err("Link Establish Request failed. status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 pRoamInfo->statusCode);
4009 }
4010 complete(&pAdapter->tdls_link_establish_req_comp);
4011 break;
4012 }
4013 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
4014 {
4015 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
4016 staIdx++) {
4017 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
4018 pRoamInfo->sessionId)
4019 && pRoamInfo->staId ==
4020 pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004021 hdd_debug("HDD: del STA IDX = %x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004022 pRoamInfo->staId);
Nitesh Shah3dea6722017-02-01 14:35:57 +05304023 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024 curr_peer =
4025 wlan_hdd_tdls_find_peer(pAdapter,
4026 pRoamInfo->
Nitesh Shah90a02e92017-02-01 15:28:03 +05304027 peerMac.bytes);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304028 if (NULL != curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004029 hdd_debug("Current status for peer " MAC_ADDRESS_STR " is %d",
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304030 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4031 curr_peer->link_status);
4032 if (TDLS_IS_CONNECTED(curr_peer)) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05304033 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 hdd_roam_deregister_tdlssta
4035 (pAdapter,
4036 pRoamInfo->staId);
4037 wlan_hdd_tdls_decrement_peer_count
4038 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304039 } else if (eTDLS_LINK_CONNECTING ==
4040 curr_peer->link_status) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05304041 mutex_unlock(&pHddCtx->tdls_lock);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304042 hdd_roam_deregister_tdlssta
4043 (pAdapter,
4044 pRoamInfo->staId);
Nitesh Shah0bf768f2017-03-31 15:01:37 +05304045 } else
4046 mutex_unlock(&pHddCtx->tdls_lock);
Nitesh Shah3dea6722017-02-01 14:35:57 +05304047 } else
4048 mutex_unlock(&pHddCtx->tdls_lock);
4049
Nitesh Shah99dd9552017-03-20 19:27:47 +05304050 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 wlan_hdd_tdls_reset_peer(pAdapter,
4052 pRoamInfo->
4053 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304054 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055
4056 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4057 pHddCtx->tdlsConnInfo[staIdx].
4058 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304059 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 tdlsConnInfo[staIdx].
4061 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304062 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304063 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 break;
4065 }
4066 }
4067 complete(&pAdapter->tdls_del_station_comp);
4068 }
4069 break;
4070 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
4071 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004072 hdd_debug("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 pRoamInfo->reasonCode);
4074
Nitesh Shahf1f38992017-01-31 16:40:16 +05304075 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 curr_peer =
4077 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304078 pRoamInfo->peerMac.bytes);
Ganesh Kondabattini9c8dc462017-04-19 10:52:54 +05304079
4080 if (!curr_peer) {
4081 mutex_unlock(&pHddCtx->tdls_lock);
4082 hdd_debug("peer doesn't exists");
4083 status = QDF_STATUS_SUCCESS;
4084 break;
4085 }
4086
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304088 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304089 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
4090 curr_peer->peerMac);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304091 mutex_unlock(&pHddCtx->tdls_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304092 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 break;
4094 }
4095 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
4096 {
4097 /* 0 staIdx is assigned to AP we dont want to touch that */
4098 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
4099 staIdx++) {
4100 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
4101 pRoamInfo->sessionId)
4102 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004103 hdd_debug("hdd_tdlsStatusUpdate: staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004104 MAC_ADDRESS_STR,
4105 pHddCtx->tdlsConnInfo[staIdx].
4106 staId,
4107 MAC_ADDR_ARRAY(pHddCtx->
4108 tdlsConnInfo
4109 [staIdx].
4110 peerMac.
4111 bytes));
Nitesh Shah99dd9552017-03-20 19:27:47 +05304112 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 wlan_hdd_tdls_reset_peer(pAdapter,
4114 pHddCtx->
4115 tdlsConnInfo
4116 [staIdx].
4117 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304118 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 hdd_roam_deregister_tdlssta(pAdapter,
4120 pHddCtx->
4121 tdlsConnInfo
4122 [staIdx].
4123 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304124 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 sizeof
4126 (smeTdlsPeerStateParams));
4127 smeTdlsPeerStateParams.vdevId =
4128 pHddCtx->tdlsConnInfo[staIdx].
4129 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304130 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 peerMacAddr,
4132 &pHddCtx->
4133 tdlsConnInfo[staIdx].
4134 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304135 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 smeTdlsPeerStateParams.peerState =
4137 eSME_TDLS_PEER_STATE_TEARDOWN;
4138
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004139 hdd_debug("calling sme_update_tdls_peer_state for staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004140 MAC_ADDRESS_STR,
4141 pHddCtx->tdlsConnInfo[staIdx].
4142 staId,
4143 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 tdlsConnInfo
4145 [staIdx].
4146 peerMac.
4147 bytes));
4148 status =
4149 sme_update_tdls_peer_state(
4150 pHddCtx->hHal,
4151 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304152 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004153 hdd_err("sme_update_tdls_peer_state failed for "
4154 MAC_ADDRESS_STR,
4155 MAC_ADDR_ARRAY
4156 (pHddCtx->
4157 tdlsConnInfo[staIdx].
4158 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 }
4160 wlan_hdd_tdls_decrement_peer_count
4161 (pAdapter);
4162
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304163 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 tdlsConnInfo[staIdx].
4165 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304166 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4168 pHddCtx->tdlsConnInfo[staIdx].
4169 sessionId = 255;
4170
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304171 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 }
4173 }
4174 break;
4175 }
4176 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
4177 {
4178 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07004179 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
4180 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304181 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 break;
4183 }
4184
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004185 if (pHddCtx->tdls_nss_switch_in_progress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004186 hdd_debug("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004187 status = QDF_STATUS_SUCCESS;
4188 break;
4189 }
4190
Nitesh Shah8e866642017-01-31 15:43:31 +05304191 mutex_lock(&pHddCtx->tdls_lock);
4192 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4193 if (!pHddTdlsCtx) {
4194 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004195 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shah8e866642017-01-31 15:43:31 +05304196 roamResult);
4197 status = QDF_STATUS_E_FAILURE;
4198 break;
4199 }
4200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 curr_peer =
4202 wlan_hdd_tdls_get_peer(pAdapter,
Nitesh Shah379449e2017-01-31 19:11:29 +05304203 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004205 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304206 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207 } else {
4208 if (eTDLS_LINK_CONNECTED ==
4209 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004210 hdd_debug("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 } else {
4212 /*
4213 * If external control is enabled then initiate
4214 * TDLS only if forced peer is set otherwise
4215 * ignore should Discover trigger from fw.
4216 */
4217 if (pHddCtx->config->
4218 fTDLSExternalControl
4219 && (false ==
4220 curr_peer->isForcedPeer)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004221 hdd_debug("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304222 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004225 hdd_debug("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Jeff Johnson68755312017-02-10 11:46:55 -08004226 pHddCtx->config->
4227 fTDLSExternalControl,
4228 curr_peer->isForcedPeer,
4229 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05304230 pHddTdlsCtx->curr_candidate = curr_peer;
4231 wlan_hdd_tdls_implicit_send_discovery_request(
4232 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304234 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 }
Nitesh Shah8e866642017-01-31 15:43:31 +05304236 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 break;
4238 }
4239
4240 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4241 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304242 mutex_lock(&pHddCtx->tdls_lock);
4243 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4244 if (!pHddTdlsCtx) {
4245 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004246 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304247 roamResult);
4248 status = QDF_STATUS_E_FAILURE;
4249 break;
4250 }
4251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 curr_peer =
4253 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304254 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004256 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304257 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 } else {
4259 if (eTDLS_LINK_CONNECTED ==
4260 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004261 hdd_debug("Received SHOULD_TEARDOWN for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004262 MAC_ADDRESS_STR
4263 " staId: %d, reason: %d",
4264 MAC_ADDR_ARRAY(pRoamInfo->
4265 peerMac.bytes),
4266 pRoamInfo->staId,
4267 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268
4269 if (pRoamInfo->reasonCode ==
4270 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4271 pRoamInfo->reasonCode ==
4272 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4273 pRoamInfo->reasonCode ==
4274 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4275 pRoamInfo->reasonCode ==
4276 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4277 reason =
4278 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4279 } else
4280 reason =
4281 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4282
4283 wlan_hdd_tdls_indicate_teardown
4284 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304285 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304286 hdd_send_wlan_tdls_teardown_event(
4287 eTDLS_TEARDOWN_BSS_DISCONNECT,
4288 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004290 hdd_debug("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004291 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304293 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304295 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 break;
4297 }
4298
4299 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4300 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304301 mutex_lock(&pHddCtx->tdls_lock);
4302 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4303 if (!pHddTdlsCtx) {
4304 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004305 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304306 roamResult);
4307 status = QDF_STATUS_E_FAILURE;
4308 break;
4309 }
4310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 curr_peer =
4312 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304313 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004315 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304316 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317 } else {
4318 if (eTDLS_LINK_CONNECTED ==
4319 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004320 hdd_debug("Received SHOULD_PEER_DISCONNECTED for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004321 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004322 " staId: %d reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004323 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4324 pRoamInfo->staId,
4325 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326
4327 if (pRoamInfo->reasonCode ==
4328 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4329 pRoamInfo->reasonCode ==
4330 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4331 pRoamInfo->reasonCode ==
4332 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4333 pRoamInfo->reasonCode ==
4334 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4335 reason =
4336 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4337 } else
4338 reason =
4339 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4340
4341 wlan_hdd_tdls_indicate_teardown
4342 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304343 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304344 hdd_send_wlan_tdls_teardown_event(
4345 eTDLS_TEARDOWN_BSS_DISCONNECT,
4346 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004348 hdd_debug("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004349 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004350 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304351 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304353 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354 break;
4355 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004356
4357 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
Nitesh Shahf1f38992017-01-31 16:40:16 +05304358 mutex_lock(&pHddCtx->tdls_lock);
4359 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4360 if (!pHddTdlsCtx) {
4361 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004362 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304363 roamResult);
4364 status = QDF_STATUS_E_FAILURE;
4365 break;
4366 }
4367
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004368 status = hdd_tdls_connection_tracker_update(pAdapter,
4369 pRoamInfo,
4370 pHddTdlsCtx);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304371 mutex_unlock(&pHddCtx->tdls_lock);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004372 break;
4373
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 default:
4375 {
4376 break;
4377 }
4378 }
4379
4380 return status;
4381}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004382#else
4383
Nitesh Shah99dd9552017-03-20 19:27:47 +05304384inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004385 uint8_t staId)
4386{
4387 return QDF_STATUS_SUCCESS;
4388}
4389
4390static inline QDF_STATUS
4391hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4392 tCsrRoamInfo *pRoamInfo,
4393 uint32_t roamId,
4394 eRoamCmdStatus roamStatus,
4395 eCsrRoamResult roamResult)
4396{
4397 return QDF_STATUS_SUCCESS;
4398}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399#endif
4400
4401#ifdef WLAN_FEATURE_11W
4402/**
4403 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4404 * @pAdapter: pointer to the adapter
4405 * @nFrameLength: Length of the unprotected frame being passed
4406 * @pbFrames: Pointer to the frame buffer
4407 * @frameType: 802.11 frame type
4408 *
4409 * This function forwards the unprotected management frame to the supplicant.
4410 *
4411 * Return: nothing
4412 */
4413static void
4414hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4415 uint8_t *pbFrames, uint8_t frameType)
4416{
4417 uint8_t type = 0;
4418 uint8_t subType = 0;
4419
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004420 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004421 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422
4423 /* Sanity Checks */
4424 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004425 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 return;
4427 }
4428
4429 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004430 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 return;
4432 }
4433
4434 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004435 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 return;
4437 }
4438
4439 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004440 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 return;
4442 }
4443
4444 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004445 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 return;
4447 }
4448
4449 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4450 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4451
4452 /* Get pAdapter from Destination mac address of the frame */
4453 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4454#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4455 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4456 nFrameLength);
4457#else
4458 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4459 nFrameLength);
4460#endif
4461 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4462 } else if (type == SIR_MAC_MGMT_FRAME &&
4463 subType == SIR_MAC_MGMT_DEAUTH) {
4464#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4465 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4466 nFrameLength);
4467#else
4468 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4469 nFrameLength);
4470#endif
4471 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4472 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004473 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004474 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 return;
4476 }
4477}
4478#endif
4479
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004480#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481/**
4482 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4483 * @pAdapter: pointer to adapter
4484 * @tid: traffic identifier
4485 * @state: state
4486 * @measInterval: measurement interval
4487 *
4488 * This function sends traffic stream metrics IE information to
4489 * the supplicant via wireless event.
4490 *
4491 * Return: none
4492 */
4493static void
4494hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4495 uint8_t state, uint16_t measInterval)
4496{
4497 union iwreq_data wrqu;
4498 char buf[IW_CUSTOM_MAX + 1];
4499 int nBytes = 0;
4500
4501 if (NULL == pAdapter)
4502 return;
4503
4504 /* create the event */
4505 memset(&wrqu, '\0', sizeof(wrqu));
4506 memset(buf, '\0', sizeof(buf));
4507
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004508 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004509 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510
4511 nBytes =
4512 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4513 measInterval);
4514
4515 wrqu.data.pointer = buf;
4516 wrqu.data.length = nBytes;
4517 /* send the event */
4518 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4519}
4520
4521/**
4522 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4523 * @pAdapter: pointer to adapter
4524 * @pRoamInfo: pointer to roam info
4525 *
4526 * This function sends cckm preauth indication to the supplicant
4527 * via wireless custom event.
4528 *
4529 * Return: none
4530 */
4531static void
4532hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4533{
4534 union iwreq_data wrqu;
4535 char buf[IW_CUSTOM_MAX + 1];
4536 char *pos = buf;
4537 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4538
4539 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4540 return;
4541
4542 /* create the event */
4543 memset(&wrqu, '\0', sizeof(wrqu));
4544 memset(buf, '\0', sizeof(buf));
4545
4546 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004547 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004548 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4549 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550
4551 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4552 pos += nBytes;
4553 freeBytes -= nBytes;
4554
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304555 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304556 pos += QDF_MAC_ADDR_SIZE;
4557 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558
4559 nBytes = snprintf(pos, freeBytes, " %u:%u",
4560 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4561 freeBytes -= nBytes;
4562
4563 wrqu.data.pointer = buf;
4564 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4565
4566 /* send the event */
4567 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4568}
4569
4570/**
4571 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4572 * @pAdapter: pointer to adapter
4573 * @pRoamInfo: pointer to roam info
4574 *
4575 * Return: none
4576 */
4577static void
4578hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4579 tCsrRoamInfo *pRoamInfo)
4580{
4581 union iwreq_data wrqu;
4582 char buf[IW_CUSTOM_MAX + 1];
4583 int nBytes = 0;
4584
4585 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4586 return;
4587
4588 /* create the event */
4589 memset(&wrqu, '\0', sizeof(wrqu));
4590 memset(buf, '\0', sizeof(buf));
4591
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004592 hdd_debug("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593
4594 nBytes =
4595 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4596 pRoamInfo->tsmRoamDelay);
4597
4598 wrqu.data.pointer = buf;
4599 wrqu.data.length = nBytes;
4600
4601 /* send the event */
4602 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4603}
4604
4605/**
4606 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4607 * @pAdapter: pointer to adapter
4608 * @measurementToken: measurement token
4609 * @flag: flag
4610 * @numBss: number of bss
4611 *
4612 * If the measurement is none and no scan results found,
4613 * indicate the supplicant about measurement done.
4614 *
4615 * Return: none
4616 */
4617void
4618hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4619 const uint16_t measurementToken,
4620 const bool flag, const uint8_t numBss)
4621{
4622 union iwreq_data wrqu;
4623 char buf[IW_CUSTOM_MAX];
4624 char *pos = buf;
4625 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4626
4627 memset(&wrqu, '\0', sizeof(wrqu));
4628 memset(buf, '\0', sizeof(buf));
4629
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004630 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004631 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632
4633 nBytes =
4634 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4635 flag, numBss);
4636
4637 wrqu.data.pointer = buf;
4638 wrqu.data.length = nBytes;
4639 /* send the event */
4640 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4641}
4642
4643/**
4644 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4645 * @pAdapter: pointer to adapter
4646 * @pRoamInfo: pointer to roam info
4647 *
4648 * If the measurement is none and no scan results found,
4649 * indicate the supplicant about measurement done.
4650 *
4651 * Return: none
4652 */
4653static void
4654hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4655 const tCsrRoamInfo *pRoamInfo)
4656{
4657 union iwreq_data wrqu;
4658 char buf[IW_CUSTOM_MAX];
4659 char *pos = buf;
4660 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4661 uint8_t i = 0, len = 0;
4662 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4663 uint8_t lastSent = 0, sendBss = 0;
4664 int bcnRepFieldSize =
4665 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4666 bcnReportFields);
4667 uint8_t ieLenByte = 1;
4668 /*
4669 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4670 */
4671#define ESEBCNREPHEADER_LEN (18)
4672
4673 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4674 return;
4675
4676 /*
4677 * Custom event can pass maximum of 256 bytes of data,
4678 * based on the IE len we need to identify how many BSS info can
4679 * be filled in to custom event data.
4680 */
4681 /*
4682 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4683 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4684 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4685 */
4686
4687 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4688 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004689 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004691 * indicate the supplicant about measurement done
4692 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 hdd_indicate_ese_bcn_report_no_results(
4694 pAdapter,
4695 pRoamInfo->pEseBcnReportRsp->
4696 measurementToken,
4697 pRoamInfo->pEseBcnReportRsp->flag,
4698 pRoamInfo->pEseBcnReportRsp->numBss);
4699 } else {
4700 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4701 memset(&wrqu, '\0', sizeof(wrqu));
4702 memset(buf, '\0', sizeof(buf));
4703 tot_bcn_ieLen = 0;
4704 sendBss = 0;
4705 pos = buf;
4706 freeBytes = IW_CUSTOM_MAX;
4707
4708 for (i = lastSent;
4709 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4710 len =
4711 bcnRepFieldSize + ieLenByte +
4712 pRoamInfo->pEseBcnReportRsp->
4713 bcnRepBssInfo[i].ieLen;
4714 if ((len + tot_bcn_ieLen) >
4715 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4716 break;
4717 }
4718 tot_bcn_ieLen += len;
4719 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004720 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004721 i, bcnRepFieldSize, 1,
4722 pRoamInfo->pEseBcnReportRsp->
4723 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 }
4725
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004726 hdd_debug("Sending %d BSS Info", sendBss);
4727 hdd_debug("CCXBCNREP=%d %d %d %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004728 pRoamInfo->pEseBcnReportRsp->measurementToken,
4729 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4730 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731
4732 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4733 pRoamInfo->pEseBcnReportRsp->
4734 measurementToken,
4735 pRoamInfo->pEseBcnReportRsp->flag,
4736 sendBss);
4737 pos += nBytes;
4738 freeBytes -= nBytes;
4739
4740 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304741 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 sizeof(tot_bcn_ieLen));
4743 pos += sizeof(tot_bcn_ieLen);
4744 freeBytes -= sizeof(tot_bcn_ieLen);
4745
4746 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004747 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4749 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4750 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4751 pRoamInfo->pEseBcnReportRsp->
4752 bcnRepBssInfo[i +
4753 lastSent].bcnReportFields.
4754 ChanNum,
4755 pRoamInfo->pEseBcnReportRsp->
4756 bcnRepBssInfo[i +
4757 lastSent].bcnReportFields.
4758 Spare,
4759 pRoamInfo->pEseBcnReportRsp->
4760 bcnRepBssInfo[i +
4761 lastSent].bcnReportFields.
4762 MeasDuration,
4763 pRoamInfo->pEseBcnReportRsp->
4764 bcnRepBssInfo[i +
4765 lastSent].bcnReportFields.
4766 PhyType,
4767 pRoamInfo->pEseBcnReportRsp->
4768 bcnRepBssInfo[i +
4769 lastSent].bcnReportFields.
4770 RecvSigPower,
4771 pRoamInfo->pEseBcnReportRsp->
4772 bcnRepBssInfo[i +
4773 lastSent].bcnReportFields.
4774 ParentTsf,
4775 pRoamInfo->pEseBcnReportRsp->
4776 bcnRepBssInfo[i +
4777 lastSent].bcnReportFields.
4778 TargetTsf[0],
4779 pRoamInfo->pEseBcnReportRsp->
4780 bcnRepBssInfo[i +
4781 lastSent].bcnReportFields.
4782 TargetTsf[1],
4783 pRoamInfo->pEseBcnReportRsp->
4784 bcnRepBssInfo[i +
4785 lastSent].bcnReportFields.
4786 BcnInterval,
4787 pRoamInfo->pEseBcnReportRsp->
4788 bcnRepBssInfo[i +
4789 lastSent].bcnReportFields.
4790 CapabilityInfo,
4791 pRoamInfo->pEseBcnReportRsp->
4792 bcnRepBssInfo[i +
4793 lastSent].bcnReportFields.
4794 Bssid[0],
4795 pRoamInfo->pEseBcnReportRsp->
4796 bcnRepBssInfo[i +
4797 lastSent].bcnReportFields.
4798 Bssid[1],
4799 pRoamInfo->pEseBcnReportRsp->
4800 bcnRepBssInfo[i +
4801 lastSent].bcnReportFields.
4802 Bssid[2],
4803 pRoamInfo->pEseBcnReportRsp->
4804 bcnRepBssInfo[i +
4805 lastSent].bcnReportFields.
4806 Bssid[3],
4807 pRoamInfo->pEseBcnReportRsp->
4808 bcnRepBssInfo[i +
4809 lastSent].bcnReportFields.
4810 Bssid[4],
4811 pRoamInfo->pEseBcnReportRsp->
4812 bcnRepBssInfo[i +
4813 lastSent].bcnReportFields.
4814 Bssid[5]);
4815
4816 /* bcn report fields are copied */
4817 len =
4818 sizeof(pRoamInfo->pEseBcnReportRsp->
4819 bcnRepBssInfo[i +
4820 lastSent].
4821 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304822 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823 (char *)&pRoamInfo->
4824 pEseBcnReportRsp->bcnRepBssInfo[i +
4825 lastSent].
4826 bcnReportFields, len);
4827 pos += len;
4828 freeBytes -= len;
4829
4830 /* Add 1 byte of ie len */
4831 len =
4832 pRoamInfo->pEseBcnReportRsp->
4833 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304834 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 pos += sizeof(len);
4836 freeBytes -= sizeof(len);
4837
4838 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304839 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840 (char *)pRoamInfo->
4841 pEseBcnReportRsp->bcnRepBssInfo[i +
4842 lastSent].
4843 pBuf, len);
4844 pos += len;
4845 freeBytes -= len;
4846 }
4847
4848 wrqu.data.pointer = buf;
4849 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4850
4851 /* send the event */
4852 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4853 buf);
4854 lastSent += sendBss;
4855 }
4856 }
4857}
4858
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004859#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860
4861/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304862 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4863 * @pHddStaCtx: Station Context
4864 *
4865 * API to check if the connection authentication type is 8021x_sha256.
4866 *
4867 * Return: bool
4868 */
4869#ifdef WLAN_FEATURE_11W
Jeff Johnson40dae4e2017-08-29 14:00:25 -07004870static inline bool hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *pHddStaCtx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304871{
4872 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4873 pHddStaCtx->conn_info.authType;
4874}
4875#else
Jeff Johnson40dae4e2017-08-29 14:00:25 -07004876static inline bool hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *pHddStaCtx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304877{
4878 return false;
4879}
4880#endif
4881
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304882/*
4883 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4884 * @adapter: Pointer to adapter context
4885 * @roam_info: Pointer to roam info
4886 *
4887 * Return: None
4888 */
4889static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4890 tCsrRoamInfo *roam_info)
4891{
4892 struct hdd_chan_change_params chan_change;
4893 struct cfg80211_bss *bss;
4894 struct net_device *dev = adapter->dev;
4895 struct wireless_dev *wdev = dev->ieee80211_ptr;
4896 struct wiphy *wiphy = wdev->wiphy;
4897 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -07004898 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304899
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004900 hdd_debug("channel switch for session:%d to channel:%d",
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304901 adapter->sessionId, roam_info->chan_info.chan_id);
4902
4903 chan_change.chan = roam_info->chan_info.chan_id;
4904 chan_change.chan_params.ch_width =
4905 roam_info->chan_info.ch_width;
4906 chan_change.chan_params.sec_ch_offset =
4907 roam_info->chan_info.sec_ch_offset;
4908 chan_change.chan_params.center_freq_seg0 =
4909 roam_info->chan_info.band_center_freq1;
4910 chan_change.chan_params.center_freq_seg1 =
4911 roam_info->chan_info.band_center_freq2;
4912
4913 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4914 if (NULL == bss)
4915 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4916 else
4917 cfg80211_put_bss(wiphy, bss);
4918
bings58ce8622017-07-10 15:55:36 +08004919 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4920 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304921 if (QDF_IS_STATUS_ERROR(status))
4922 hdd_err("channel change notification failed");
4923
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004924 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
4925 adapter->sessionId);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304926 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004927 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304928}
4929
Komal Seelam98760ba2015-12-15 11:05:18 +05304930/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 * hdd_sme_roam_callback() - hdd sme roam callback
4932 * @pContext: pointer to adapter context
4933 * @pRoamInfo: pointer to roam info
4934 * @roamId: roam id
4935 * @roamStatus: roam status
4936 * @roamResult: roam result
4937 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304938 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304940QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4942 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4943{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304944 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4946 hdd_wext_state_t *pWextState = NULL;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07004947 struct hdd_station_ctx *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304948 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304949 struct cfg80211_bss *bss_status;
Jeff Johnson49432062017-08-28 12:08:45 -07004950 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004952 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004953 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954
4955 /* Sanity check */
4956 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004957 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304958 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959 }
4960
4961 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4962 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004963 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004964
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304965 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4966 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4967 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4968 pAdapter->sessionId, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 switch (roamStatus) {
4971 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304972 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4973 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004974 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 break;
4976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977 /*
4978 * We did pre-auth,then we attempted a 11r or ese reassoc.
4979 * reassoc failed due to failure, timeout, reject from ap
4980 * in any case tell the OS, our carrier is off and mark
4981 * interface down.
4982 */
4983 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004984 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4985 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304986 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4988 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989 pHddStaCtx->ft_carrier_on = false;
4990 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004991 hdd_debug("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004992 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 break;
4994
4995 case eCSR_ROAM_FT_START:
4996 /*
4997 * When we roam for ESE and 11r, we dont want the OS to be
4998 * informed that the link is down. So mark the link ready for
4999 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
5000 * be received. Where in we will not mark the link down
5001 * Also we want to stop tx at this point when we will be
5002 * doing disassoc at this time. This saves 30-60 msec
5003 * after reassoc.
5004 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005005 hdd_info("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005006 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005007 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07005008 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305009 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07005010 WLAN_CONTROL_PATH);
5011 status = hdd_roam_deregister_sta(pAdapter,
5012 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305013 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305014 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 pHddStaCtx->ft_carrier_on = true;
5016 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005017 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
5018 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005020 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005021 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005022 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005023 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305024 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
5025 pAdapter->roam_ho_fail = true;
5026 else
5027 pAdapter->roam_ho_fail = false;
5028 complete(&pAdapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005029 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005031 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6598eea2017-07-06 19:26:19 -07005032 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305034 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037 wlan_hdd_netif_queue_control(pAdapter,
5038 WLAN_NETIF_CARRIER_OFF,
5039 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005041 break;
5042 case eCSR_ROAM_LOSTLINK:
5043 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005044 hdd_debug("Roaming started due to connection lost");
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005045 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305047 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048 WLAN_CONTROL_PATH);
5049 break;
5050 }
5051 case eCSR_ROAM_DISASSOCIATED:
5052 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005053 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305054 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07005055 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305056 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305057 pAdapter->roam_ho_fail = false;
5058 complete(&pAdapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 /* Call to clear any MC Addr List filter applied after
5061 * successful connection.
5062 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05305063 hdd_disable_and_flush_mc_addr_list(pAdapter,
5064 pmo_peer_disconnect);
5065 qdf_ret_status =
5066 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
5067 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068 }
5069 break;
5070 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005071 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305072 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
5074 roamStatus, roamResult);
5075 break;
5076 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005077 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078 /*
5079 * To Do - address probable memory leak with WEP encryption upon
5080 * successful association.
5081 */
5082 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
5083 /* Clear saved connection information in HDD */
5084 hdd_conn_remove_connect_info(
5085 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
5086 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305087 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005088 hdd_association_completion_handler(pAdapter, pRoamInfo,
5089 roamId, roamStatus,
5090 roamResult);
5091#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5092 if (pRoamInfo)
5093 pRoamInfo->roamSynchInProgress = false;
5094#endif
5095 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07005096 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005097 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305099 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100 pRoamInfo,
5101 roamId,
5102 roamStatus,
5103 roamResult);
5104 break;
5105 case eCSR_ROAM_IBSS_IND:
5106 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
5107 roamStatus, roamResult);
5108 break;
5109
5110 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305111 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 roam_roam_connect_status_update_handler(pAdapter,
5113 pRoamInfo,
5114 roamId,
5115 roamStatus,
5116 roamResult);
5117 break;
5118
5119 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305120 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 hdd_roam_mic_error_indication_handler(pAdapter,
5122 pRoamInfo,
5123 roamId,
5124 roamStatus,
5125 roamResult);
5126 break;
5127
5128 case eCSR_ROAM_SET_KEY_COMPLETE:
5129 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305130 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
5132 roamId, roamStatus,
5133 roamResult);
5134 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
5135 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005136 hdd_debug("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005137 pHddStaCtx->hdd_ReassocScenario,
5138 pAdapter->sessionId);
5139 }
5140 }
5141#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5142 if (pRoamInfo != NULL)
5143 pRoamInfo->roamSynchInProgress = false;
5144#endif
5145 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 case eCSR_ROAM_FT_RESPONSE:
5148 hdd_send_ft_event(pAdapter);
5149 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05305152 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
5153 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305155 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 wlan_hdd_cfg80211_pmksa_candidate_notify(
5157 pAdapter, pRoamInfo, 1, false);
5158 }
5159 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160
5161#ifdef FEATURE_WLAN_LFR_METRICS
5162 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
5163 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305164 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
5166 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305167 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168 }
5169 break;
5170 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
5171 /*
5172 * This event will notify pre-auth completion in case of success
5173 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305174 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5176 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305177 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005178 }
5179 break;
5180 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
5181 /*
5182 * This event will notify pre-auth completion incase of failure.
5183 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305184 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005185 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5186 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305187 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188 }
5189 break;
5190 case eCSR_ROAM_HANDOVER_SUCCESS:
5191 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08005192 * It will be only invoked on success
5193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305194 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
5196 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305197 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198 }
5199 break;
5200#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 case eCSR_ROAM_REMAIN_CHAN_READY:
5202 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
5203 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005204#ifdef FEATURE_WLAN_TDLS
5205 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305206 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
5208 roamId,
5209 roamStatus,
5210 roamResult);
5211 break;
5212 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
5213 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
5214 pRoamInfo->reasonCode);
5215 break;
5216#endif
5217#ifdef WLAN_FEATURE_11W
5218 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
5219 hdd_indicate_unprot_mgmt_frame(pAdapter,
5220 pRoamInfo->nFrameLength,
5221 pRoamInfo->pbFrames,
5222 pRoamInfo->frameType);
5223 break;
5224#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005225#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 case eCSR_ROAM_TSM_IE_IND:
5227 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
5228 pRoamInfo->tsmIe.state,
5229 pRoamInfo->tsmIe.msmt_interval);
5230 break;
5231
5232 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
5233 {
5234 if (eCSR_AUTH_TYPE_CCKM_WPA ==
5235 pHddStaCtx->conn_info.authType
5236 || eCSR_AUTH_TYPE_CCKM_RSN ==
5237 pHddStaCtx->conn_info.authType) {
5238 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
5239 }
5240 break;
5241 }
5242
5243 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
5244 {
5245 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
5246 break;
5247 }
5248
5249 case eCSR_ROAM_ESE_BCN_REPORT_IND:
5250 {
5251 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
5252 break;
5253 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005254#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305255 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305256 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305257 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305258
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305259 case eCSR_ROAM_UPDATE_SCAN_RESULT:
5260 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
5261 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
5262 pAdapter, pRoamInfo->pBssDesc);
5263 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005264 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305265 else
5266 cfg80211_put_bss(
5267#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5268 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5269#endif
5270 bss_status);
5271 }
5272 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005273 case eCSR_ROAM_NDP_STATUS_UPDATE:
5274 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5275 roamResult);
5276 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005277 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005278 hdd_debug("Process ROAM_START from firmware");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005279 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305280 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005281 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005282 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005283 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005284 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08005285 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005286 break;
5287 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005288 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005289 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005290 wlan_hdd_netif_queue_control(pAdapter,
5291 WLAN_WAKE_ALL_NETIF_QUEUE,
5292 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005293 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005294 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305295 pAdapter->roam_ho_fail = false;
5296 complete(&pAdapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005297 break;
5298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 default:
5300 break;
5301 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305302 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303}
5304
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305305#ifdef WLAN_FEATURE_FILS_SK
5306/**
5307 * hdd_translate_fils_rsn_to_csr_auth() - Translate FILS RSN to CSR auth type
5308 * @auth_suite: auth suite
5309 * @auth_type: pointer to eCsrAuthType
5310 *
5311 * Return: None
5312 */
5313static void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
5314 eCsrAuthType *auth_type)
5315{
5316 if (!memcmp(auth_suite, ccp_rsn_oui_0e, 4))
5317 *auth_type = eCSR_AUTH_TYPE_FILS_SHA256;
5318 else if (!memcmp(auth_suite, ccp_rsn_oui_0f, 4))
5319 *auth_type = eCSR_AUTH_TYPE_FILS_SHA384;
5320 else if (!memcmp(auth_suite, ccp_rsn_oui_10, 4))
5321 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA256;
5322 else if (!memcmp(auth_suite, ccp_rsn_oui_11, 4))
5323 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA384;
5324}
5325#else
5326static inline void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
5327 eCsrAuthType *auth_type)
5328{
5329}
5330#endif
5331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332/**
5333 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5334 * @auth_suite: auth suite
5335 *
5336 * Return: eCsrAuthType enumeration
5337 */
5338eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5339{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305340 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 /* is the auth type supported? */
5342 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5343 auth_type = eCSR_AUTH_TYPE_RSN;
5344 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5345 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005346 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 /* Check for 11r FT Authentication with PSK */
5348 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5349 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5350 /* Check for 11R FT Authentication with 802.1X */
5351 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5352 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353#ifdef FEATURE_WLAN_ESE
5354 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5355 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5356 } else
5357#endif /* FEATURE_WLAN_ESE */
5358#ifdef WLAN_FEATURE_11W
5359 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5360 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5361 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5362 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5363 } else
5364#endif
5365 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305366 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005367 }
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305368 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 return auth_type;
5370}
5371
5372/**
5373 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5374 * @auth_suite: auth suite
5375 *
5376 * Return: eCsrAuthType enumeration
5377 */
5378eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5379{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305380 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 /* is the auth type supported? */
5382 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5383 auth_type = eCSR_AUTH_TYPE_WPA;
5384 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5385 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5386 } else
5387#ifdef FEATURE_WLAN_ESE
5388 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5389 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5390 } else
5391#endif /* FEATURE_WLAN_ESE */
5392 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305393 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005395 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005396 return auth_type;
5397}
5398
5399/**
5400 * hdd_translate_rsn_to_csr_encryption_type() -
5401 * Translate RSN to CSR encryption type
5402 * @cipher_suite: cipher suite
5403 *
5404 * Return: eCsrEncryptionType enumeration
5405 */
5406eCsrEncryptionType
5407hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5408{
5409 eCsrEncryptionType cipher_type;
5410
5411 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5412 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Mukul Sharma05504ac2017-06-08 12:35:53 +05305413 else if (memcmp(cipher_suite, ccp_rsn_oui09, 4) == 0)
5414 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP;
5415 else if (memcmp(cipher_suite, ccp_rsn_oui0a, 4) == 0)
5416 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP_256;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5418 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5419 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5420 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5421 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5422 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5423 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5424 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5425 else
5426 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5427
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005428 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429 return cipher_type;
5430}
5431
5432/**
5433 * hdd_translate_wpa_to_csr_encryption_type() -
5434 * Translate WPA to CSR encryption type
5435 * @cipher_suite: cipher suite
5436 *
5437 * Return: eCsrEncryptionType enumeration
5438 */
5439eCsrEncryptionType
5440hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5441{
5442 eCsrEncryptionType cipher_type;
5443
5444 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5445 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5446 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5447 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5448 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5449 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5450 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5451 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5452 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5453 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5454 else
5455 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5456
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005457 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 return cipher_type;
5459}
5460
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305461#ifdef WLAN_FEATURE_FILS_SK
5462/*
5463 * hdd_is_fils_connection: API to determine if connection is FILS
5464 * @adapter: hdd adapter
5465 *
5466 * Return: true if fils connection else false
5467 */
5468static inline bool hdd_is_fils_connection(hdd_adapter_t *adapter)
5469{
5470 hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
5471
5472 if (wext_state->roamProfile.fils_con_info)
5473 return wext_state->roamProfile.
5474 fils_con_info->is_fils_connection;
5475}
5476#else
5477static inline bool hdd_is_fils_connection(hdd_adapter_t *adapter)
5478{
5479 return false;
5480}
5481#endif
5482
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483/**
5484 * hdd_process_genie() - process gen ie
5485 * @pAdapter: pointer to adapter
5486 * @bssid: pointer to mac address
5487 * @pEncryptType: pointer to encryption type
5488 * @mcEncryptType: pointer to multicast encryption type
5489 * @pAuthType: pointer to auth type
5490 *
5491 * Return: 0 on success, error number otherwise
5492 */
5493static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5494 u8 *bssid,
5495 eCsrEncryptionType *pEncryptType,
5496 eCsrEncryptionType *mcEncryptType,
5497 eCsrAuthType *pAuthType,
5498#ifdef WLAN_FEATURE_11W
5499 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5500#endif
5501 uint16_t gen_ie_len, uint8_t *gen_ie)
5502{
5503 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 tDot11fIERSN dot11RSNIE;
5505 tDot11fIEWPA dot11WPAIE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 uint8_t *pRsnIe;
5507 uint16_t RSNIeLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508
5509 /*
5510 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5511 * setting present flag to 0.
5512 */
5513 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5514 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5515
5516 /* Type check */
5517 if (gen_ie[0] == DOT11F_EID_RSN) {
5518 /* Validity checks */
5519 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5520 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005521 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005522 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523 return -EINVAL;
5524 }
5525 /* Skip past the EID byte and length byte */
5526 pRsnIe = gen_ie + 2;
5527 RSNIeLen = gen_ie_len - 2;
5528 /* Unpack the RSN IE */
5529 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305530 pRsnIe, RSNIeLen, &dot11RSNIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005532 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005533 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005534 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005535 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005536 /* dot11RSNIE.akm_suite_count */
5537 /* Just translate the FIRST one */
5538 *pAuthType =
5539 hdd_translate_rsn_to_csr_auth_type(
5540 dot11RSNIE.akm_suites[0]);
5541 /* dot11RSNIE.pwise_cipher_suite_count */
5542 *pEncryptType =
5543 hdd_translate_rsn_to_csr_encryption_type(
5544 dot11RSNIE.pwise_cipher_suites[0]);
5545 /* dot11RSNIE.gp_cipher_suite_count */
5546 *mcEncryptType =
5547 hdd_translate_rsn_to_csr_encryption_type(
5548 dot11RSNIE.gp_cipher_suite);
5549#ifdef WLAN_FEATURE_11W
5550 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
Srinivas Girigowda6519b932017-08-03 14:10:57 -07005551 *pMfpCapable = csr_is_mfpc_capable(&dot11RSNIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5554 /* Validity checks */
5555 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5556 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005557 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005558 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 return -EINVAL;
5560 }
5561 /* Skip past the EID and length byte - and four byte WiFi OUI */
5562 pRsnIe = gen_ie + 2 + 4;
5563 RSNIeLen = gen_ie_len - (2 + 4);
5564 /* Unpack the WPA IE */
5565 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305566 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005568 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005569 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005570 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005571 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 /* dot11WPAIE.auth_suite_count */
5573 /* Just translate the FIRST one */
5574 *pAuthType =
5575 hdd_translate_wpa_to_csr_auth_type(
5576 dot11WPAIE.auth_suites[0]);
5577 /* dot11WPAIE.unicast_cipher_count */
5578 *pEncryptType =
5579 hdd_translate_wpa_to_csr_encryption_type(
5580 dot11WPAIE.unicast_ciphers[0]);
5581 /* dot11WPAIE.unicast_cipher_count */
5582 *mcEncryptType =
5583 hdd_translate_wpa_to_csr_encryption_type(
5584 dot11WPAIE.multicast_cipher);
5585 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005586 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 return -EINVAL;
5588 }
5589 return 0;
5590}
5591
5592/**
5593 * hdd_set_genie_to_csr() - set genie to csr
5594 * @pAdapter: pointer to adapter
5595 * @RSNAuthType: pointer to auth type
5596 *
5597 * Return: 0 on success, error number otherwise
5598 */
5599int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5600{
5601 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5602 uint32_t status = 0;
5603 eCsrEncryptionType RSNEncryptType;
5604 eCsrEncryptionType mcRSNEncryptType;
5605#ifdef WLAN_FEATURE_11W
5606 uint8_t RSNMfpRequired = 0;
5607 uint8_t RSNMfpCapable = 0;
5608#endif
5609 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5610 /* MAC address of assoc peer */
5611 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305612 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 pWextState->roamProfile.BSSIDs.bssid,
5614 sizeof(bssid));
5615 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5616 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5617 /* continue */
5618 } else {
5619 return 0;
5620 }
5621 /* The actual processing may eventually be more extensive than this. */
5622 /* Right now, just consume any PMKIDs that are sent in by the app. */
5623 status = hdd_process_genie(pAdapter, bssid,
5624 &RSNEncryptType,
5625 &mcRSNEncryptType, RSNAuthType,
5626#ifdef WLAN_FEATURE_11W
5627 &RSNMfpRequired, &RSNMfpCapable,
5628#endif
5629 pWextState->WPARSNIE[1] + 2,
5630 pWextState->WPARSNIE);
5631 if (status == 0) {
5632 /*
5633 * Now copy over all the security attributes
5634 * you have parsed out.
5635 */
5636 pWextState->roamProfile.EncryptionType.numEntries = 1;
5637 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5638
5639 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5640 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5641 mcRSNEncryptType;
5642
Krunal Sonibe766b02016-03-10 13:00:44 -08005643 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05305645 (eCSR_ENCRYPT_TYPE_AES_GCMP == mcRSNEncryptType) ||
5646 (eCSR_ENCRYPT_TYPE_AES_GCMP_256 == mcRSNEncryptType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5648 /*
5649 * For wpa none supplicant sends the WPA IE with unicast
5650 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5651 * multicast cipher as either AES/TKIP based on group
5652 * cipher configuration mentioned in the
5653 * wpa_supplicant.conf.
5654 */
5655
5656 /* Set the unicast cipher same as multicast cipher */
5657 pWextState->roamProfile.EncryptionType.encryptionType[0]
5658 = mcRSNEncryptType;
5659 }
5660#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005661 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005662 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5664 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5665#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005666 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005667 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005668 }
5669 return 0;
5670}
5671
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305672#ifdef WLAN_FEATURE_FILS_SK
5673/**
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305674 * hdd_check_fils_rsn_n_set_auth_type() - This API checks whether a give
5675 * auth type is fils if yes, sets it in profile.
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305676 * @rsn_auth_type: auth type
5677 *
5678 * Return: true if FILS auth else false
5679 */
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305680static bool hdd_check_fils_rsn_n_set_auth_type(tCsrRoamProfile *roam_profile,
5681 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305682{
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305683 bool is_fils_rsn = false;
5684
5685 if (!roam_profile->fils_con_info)
5686 return false;
5687
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305688 if ((rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA256) ||
5689 (rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA384) ||
5690 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA256) ||
5691 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA384))
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305692 is_fils_rsn = true;
5693 if (is_fils_rsn)
5694 roam_profile->fils_con_info->akm_type = rsn_auth_type;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305695
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305696 return is_fils_rsn;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305697}
5698#else
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305699static bool hdd_check_fils_rsn_n_set_auth_type(tCsrRoamProfile *roam_profile,
5700 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305701{
5702 return false;
5703}
5704#endif
5705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706/**
5707 * hdd_set_csr_auth_type() - set csr auth type
5708 * @pAdapter: pointer to adapter
5709 * @RSNAuthType: auth type
5710 *
5711 * Return: 0 on success, error number otherwise
5712 */
5713int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5714{
5715 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5716 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07005717 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718
5719 pRoamProfile->AuthType.numEntries = 1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005720 hdd_debug("pHddStaCtx->conn_info.authType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005721 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722
5723 switch (pHddStaCtx->conn_info.authType) {
5724 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5725#ifdef FEATURE_WLAN_ESE
5726 case eCSR_AUTH_TYPE_CCKM_WPA:
5727 case eCSR_AUTH_TYPE_CCKM_RSN:
5728#endif
5729 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5730
5731 pRoamProfile->AuthType.authType[0] =
5732 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5733 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5734
5735#ifdef FEATURE_WLAN_ESE
5736 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5737 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5738 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005739 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005740 pRoamProfile->AuthType.authType[0] =
5741 eCSR_AUTH_TYPE_CCKM_WPA;
5742 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005743 hdd_debug("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005744 pRoamProfile->AuthType.authType[0] =
5745 eCSR_AUTH_TYPE_CCKM_WPA;
5746 } else
5747#endif
5748 if ((pWextState->
5749 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5750 == IW_AUTH_KEY_MGMT_802_1X) {
5751 pRoamProfile->AuthType.authType[0] =
5752 eCSR_AUTH_TYPE_WPA;
5753 } else
5754 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5755 == IW_AUTH_KEY_MGMT_PSK) {
5756 pRoamProfile->AuthType.authType[0] =
5757 eCSR_AUTH_TYPE_WPA_PSK;
5758 } else {
5759 pRoamProfile->AuthType.authType[0] =
5760 eCSR_AUTH_TYPE_WPA_NONE;
5761 }
5762 }
5763 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5764#ifdef FEATURE_WLAN_ESE
5765 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5766 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5767 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005768 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005769 pRoamProfile->AuthType.authType[0] =
5770 eCSR_AUTH_TYPE_CCKM_RSN;
5771 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005772 hdd_debug("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773 pRoamProfile->AuthType.authType[0] =
5774 eCSR_AUTH_TYPE_CCKM_RSN;
5775 } else
5776#endif
5777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5779 ((pWextState->
5780 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5781 == IW_AUTH_KEY_MGMT_802_1X)) {
5782 pRoamProfile->AuthType.authType[0] =
5783 eCSR_AUTH_TYPE_FT_RSN;
5784 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5785 &&
5786 ((pWextState->
5787 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5788 == IW_AUTH_KEY_MGMT_PSK)) {
5789 pRoamProfile->AuthType.authType[0] =
5790 eCSR_AUTH_TYPE_FT_RSN_PSK;
5791 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005792
5793#ifdef WLAN_FEATURE_11W
5794 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5795 pRoamProfile->AuthType.authType[0] =
5796 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5797 } else if (RSNAuthType ==
5798 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5799 pRoamProfile->AuthType.authType[0] =
5800 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5801 } else
5802#endif
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305803 if (hdd_check_fils_rsn_n_set_auth_type(pRoamProfile,
5804 RSNAuthType)) {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305805 pRoamProfile->AuthType.authType[0] =
5806 RSNAuthType;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305807 hdd_info("updated profile authtype as %d",
5808 RSNAuthType);
5809
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305810 } else if ((pWextState->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5812 == IW_AUTH_KEY_MGMT_802_1X) {
5813 pRoamProfile->AuthType.authType[0] =
5814 eCSR_AUTH_TYPE_RSN;
5815 } else
5816 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5817 == IW_AUTH_KEY_MGMT_PSK) {
5818 pRoamProfile->AuthType.authType[0] =
5819 eCSR_AUTH_TYPE_RSN_PSK;
5820 } else {
5821 pRoamProfile->AuthType.authType[0] =
5822 eCSR_AUTH_TYPE_UNKNOWN;
5823 }
5824 }
5825 break;
5826
5827 case eCSR_AUTH_TYPE_SHARED_KEY:
5828
5829 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5830 break;
5831 default:
5832
5833#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005834 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835#endif /* FEATURE_WLAN_ESE */
5836 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5837 break;
5838 }
5839
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005840 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005841 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005842
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005843 return 0;
5844}
5845
5846/**
5847 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5848 * to the CSR roam profile.
5849 *
5850 * @dev: Pointer to the net device.
5851 * @info: Pointer to the iw_request_info.
5852 * @wrqu: Pointer to the iwreq_data.
5853 * @extra: Pointer to the data.
5854 *
5855 * Return: 0 for success, error number on failure
5856 */
5857static int __iw_set_essid(struct net_device *dev,
5858 struct iw_request_info *info,
5859 union iwreq_data *wrqu, char *extra)
5860{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861 uint32_t status = 0;
5862 hdd_wext_state_t *pWextState;
5863 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson49432062017-08-28 12:08:45 -07005864 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865 uint32_t roamId;
5866 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 eCsrAuthType RSNAuthType;
5868 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005869 int ret;
5870
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005871 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005872
5873 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5874 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305875 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005876 return ret;
5877
Jeff Johnson441e1f72017-02-07 08:50:49 -08005878 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5879 if (0 != ret)
5880 return ret;
5881
Krunal Sonibe766b02016-03-10 13:00:44 -08005882 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005883 pAdapter->device_mode != QDF_IBSS_MODE &&
5884 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005885 hdd_warn("device mode %s(%d) is not allowed",
5886 hdd_device_mode_to_string(pAdapter->device_mode),
5887 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 return -EINVAL;
5889 }
5890
5891 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5892
5893 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005894 hdd_warn("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 return -EBUSY;
5896 }
5897 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5898 return -EINVAL;
5899
5900 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305901 /*Try disconnecting if already in connected state*/
5902 status = wlan_hdd_try_disconnect(pAdapter);
5903 if (0 > status) {
Srinivas Girigowda576b2352017-08-25 14:44:26 -07005904 hdd_err("Failed to disconnect the existing connection");
5905 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906 }
5907
5908 /*
5909 * when cfg80211 defined, wpa_supplicant wext driver uses
5910 * zero-length, null-string ssid for force disconnection.
5911 * after disconnection (if previously connected) and cleaning ssid,
5912 * driver MUST return success.
5913 */
5914 if (0 == wrqu->essid.length)
5915 return 0;
5916
5917 status = hdd_wmm_get_uapsd_mask(pAdapter,
5918 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305919 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920 pWextState->roamProfile.uapsd_mask = 0;
5921
5922 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5923
5924 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5925 wrqu->essid.length;
5926
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305927 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305929 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005930 ssId), extra, wrqu->essid.length);
5931 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5932 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5933
5934 /* set gen ie */
5935 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5936
5937 /* set auth */
5938 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5939 }
5940#ifdef FEATURE_WLAN_WAPI
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005941 hdd_debug("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 if (pAdapter->wapi_info.nWapiMode) {
5943 switch (pAdapter->wapi_info.wapiAuthMode) {
5944 case WAPI_AUTH_MODE_PSK:
5945 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005946 hdd_debug("WAPI AUTH TYPE: PSK: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005947 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 pRoamProfile->AuthType.numEntries = 1;
5949 pRoamProfile->AuthType.authType[0] =
5950 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5951 break;
5952 }
5953 case WAPI_AUTH_MODE_CERT:
5954 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005955 hdd_debug("WAPI AUTH TYPE: CERT: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005956 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957 pRoamProfile->AuthType.numEntries = 1;
5958 pRoamProfile->AuthType.authType[0] =
5959 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5960 break;
5961 }
5962 } /* End of switch */
5963 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5964 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005965 hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 pRoamProfile->EncryptionType.numEntries = 1;
5967 pRoamProfile->EncryptionType.encryptionType[0] =
5968 eCSR_ENCRYPT_TYPE_WPI;
5969 pRoamProfile->mcEncryptionType.numEntries = 1;
5970 pRoamProfile->mcEncryptionType.encryptionType[0] =
5971 eCSR_ENCRYPT_TYPE_WPI;
5972 }
5973 }
5974#endif /* FEATURE_WLAN_WAPI */
5975 /* if previous genIE is not NULL, update AssocIE */
5976 if (0 != pWextState->genIE.length) {
5977 memset(&pWextState->assocAddIE, 0,
5978 sizeof(pWextState->assocAddIE));
5979 memcpy(pWextState->assocAddIE.addIEdata,
5980 pWextState->genIE.addIEdata, pWextState->genIE.length);
5981 pWextState->assocAddIE.length = pWextState->genIE.length;
5982 pWextState->roamProfile.pAddIEAssoc =
5983 pWextState->assocAddIE.addIEdata;
5984 pWextState->roamProfile.nAddIEAssocLength =
5985 pWextState->assocAddIE.length;
5986
5987 /* clear previous genIE after use it */
5988 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5989 }
5990
5991 /*
5992 * Assumes it is not WPS Association by default, except when
5993 * pAddIEAssoc has WPS IE.
5994 */
5995 pWextState->roamProfile.bWPSAssociation = false;
5996
5997 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5998 pWextState->roamProfile.
5999 nAddIEAssocLength))
6000 pWextState->roamProfile.bWPSAssociation = true;
6001
6002 /* Disable auto BMPS entry by PMC until DHCP is done */
6003 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
6004 true);
6005
6006 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
6007
6008 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07006009 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07006011 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
6012 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07006014
Agrawal Ashish6b015762016-05-05 11:22:18 +05306015 /*
6016 * Change conn_state to connecting before sme_roam_connect(),
6017 * because sme_roam_connect() has a direct path to call
6018 * hdd_sme_roam_callback(), which will change the conn_state
6019 * If direct path, conn_state will be accordingly changed to
6020 * NotConnected or Associated by either
6021 * hdd_association_completion_handler() or hdd_dis_connect_handler()
6022 * in sme_RoamCallback()if sme_RomConnect is to be queued,
6023 * Connecting state will remain until it is completed.
6024 *
6025 * If connection state is not changed,
6026 * connection state will remain in eConnectionState_NotConnected state.
6027 * In hdd_association_completion_handler, "hddDisconInProgress" is
6028 * set to true if conn state is eConnectionState_NotConnected.
6029 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
6030 * informed of connect result indication which is an issue.
6031 */
6032 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306033 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05306034 hdd_conn_set_connection_state(pAdapter,
6035 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05306036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 status = sme_roam_connect(hHal, pAdapter->sessionId,
6038 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05306039 if ((QDF_STATUS_SUCCESS != status) &&
6040 (QDF_STA_MODE == pAdapter->device_mode ||
6041 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006042 hdd_err("sme_roam_connect failed session_id: %d status %d -> NotConnected",
Agrawal Ashish6b015762016-05-05 11:22:18 +05306043 pAdapter->sessionId, status);
6044 /* change back to NotAssociated */
6045 hdd_conn_set_connection_state(pAdapter,
6046 eConnectionState_NotConnected);
6047 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048 pRoamProfile->ChannelInfo.ChannelList = NULL;
6049 pRoamProfile->ChannelInfo.numOfChannels = 0;
6050
6051 EXIT();
6052 return status;
6053}
6054
6055/**
6056 * iw_set_essid() - set essid handler function
6057 * @dev: Pointer to the net device.
6058 * @info: Pointer to the iw_request_info.
6059 * @wrqu: Pointer to the iwreq_data.
6060 * @extra: Pointer to the data.
6061 *
6062 * Return: 0 for success, error number on failure
6063 */
6064int iw_set_essid(struct net_device *dev,
6065 struct iw_request_info *info,
6066 union iwreq_data *wrqu, char *extra)
6067{
6068 int ret;
6069
6070 cds_ssr_protect(__func__);
6071 ret = __iw_set_essid(dev, info, wrqu, extra);
6072 cds_ssr_unprotect(__func__);
6073
6074 return ret;
6075}
6076
6077/**
6078 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
6079 * @dev: pointer to the net device
6080 * @info: pointer to the iw request info
6081 * @dwrq: pointer to iw_point
6082 * @extra: pointer to the data
6083 *
6084 * Return: 0 on success, error number otherwise
6085 */
6086static int __iw_get_essid(struct net_device *dev,
6087 struct iw_request_info *info,
6088 struct iw_point *dwrq, char *extra)
6089{
6090 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson49432062017-08-28 12:08:45 -07006091 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07006093 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006094 int ret;
6095
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006096 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097
6098 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6099 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306100 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006101 return ret;
6102
Jeff Johnson441e1f72017-02-07 08:50:49 -08006103 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6104 if (0 != ret)
6105 return ret;
6106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006107 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
6108 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
6109 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
6110 || pHddStaCtx->conn_info.connState ==
6111 eConnectionState_IbssDisconnected)
6112 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
6113 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
6114 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
6115 dwrq->length);
6116 dwrq->flags = 1;
6117 } else {
6118 memset(extra, 0, dwrq->length);
6119 dwrq->length = 0;
6120 dwrq->flags = 0;
6121 }
6122 EXIT();
6123 return 0;
6124}
6125
6126/**
6127 * iw_get_essid() - get essid handler function
6128 * @dev: Pointer to the net device.
6129 * @info: Pointer to the iw_request_info.
6130 * @wrqu: Pointer to the iwreq_data.
6131 * @extra: Pointer to the data.
6132 *
6133 * Return: 0 for success, error number on failure
6134 */
6135int iw_get_essid(struct net_device *dev,
6136 struct iw_request_info *info,
6137 struct iw_point *wrqu, char *extra)
6138{
6139 int ret;
6140
6141 cds_ssr_protect(__func__);
6142 ret = __iw_get_essid(dev, info, wrqu, extra);
6143 cds_ssr_unprotect(__func__);
6144
6145 return ret;
6146}
6147
6148/**
6149 * __iw_set_auth() -
6150 * This function sets the auth type received from the wpa_supplicant
6151 * @dev: pointer to the net device
6152 * @info: pointer to the iw request info
6153 * @wrqu: pointer to iwreq_data
6154 * @extra: pointer to the data
6155 *
6156 * Return: 0 on success, error number otherwise
6157 */
6158static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6159 union iwreq_data *wrqu, char *extra)
6160{
6161 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson49432062017-08-28 12:08:45 -07006162 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07006164 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006165 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6166 eCsrEncryptionType mcEncryptionType;
6167 eCsrEncryptionType ucEncryptionType;
6168 int ret;
6169
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006170 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006171
6172 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6173 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306174 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 return ret;
6176
Jeff Johnson441e1f72017-02-07 08:50:49 -08006177 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6178 if (0 != ret)
6179 return ret;
6180
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181 switch (wrqu->param.flags & IW_AUTH_INDEX) {
6182 case IW_AUTH_WPA_VERSION:
6183 pWextState->wpaVersion = wrqu->param.value;
6184 break;
6185
6186 case IW_AUTH_CIPHER_PAIRWISE:
6187 {
6188 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6189 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6190 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6191 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6192 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6193 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6194 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6195 if ((IW_AUTH_KEY_MGMT_802_1X
6196 ==
6197 (pWextState->
6198 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6199 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6200 pHddStaCtx->conn_info.authType))
6201 /*Dynamic WEP key */
6202 ucEncryptionType =
6203 eCSR_ENCRYPT_TYPE_WEP40;
6204 else
6205 /*Static WEP key */
6206 ucEncryptionType =
6207 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6208 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6209 if ((IW_AUTH_KEY_MGMT_802_1X
6210 ==
6211 (pWextState->
6212 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6213 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6214 pHddStaCtx->conn_info.authType))
6215 /*Dynamic WEP key */
6216 ucEncryptionType =
6217 eCSR_ENCRYPT_TYPE_WEP104;
6218 else
6219 /*Static WEP key */
6220 ucEncryptionType =
6221 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6222 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006223 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
6224 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006225 return -EINVAL;
6226 }
6227
6228 pRoamProfile->EncryptionType.numEntries = 1;
6229 pRoamProfile->EncryptionType.encryptionType[0] =
6230 ucEncryptionType;
6231 }
6232 break;
6233 case IW_AUTH_CIPHER_GROUP:
6234 {
6235 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6236 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6237 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6238 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6239 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6240 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6241 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6242 if ((IW_AUTH_KEY_MGMT_802_1X
6243 ==
6244 (pWextState->
6245 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6246 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6247 pHddStaCtx->conn_info.authType))
6248 mcEncryptionType =
6249 eCSR_ENCRYPT_TYPE_WEP40;
6250 else
6251 mcEncryptionType =
6252 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6253 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6254 /* Dynamic WEP keys won't work with shared keys */
6255 if ((IW_AUTH_KEY_MGMT_802_1X
6256 ==
6257 (pWextState->
6258 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6259 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6260 pHddStaCtx->conn_info.authType)) {
6261 mcEncryptionType =
6262 eCSR_ENCRYPT_TYPE_WEP104;
6263 } else {
6264 mcEncryptionType =
6265 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6266 }
6267 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006268 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006269 wrqu->param.value);
6270 return -EINVAL;
6271 }
6272
6273 pRoamProfile->mcEncryptionType.numEntries = 1;
6274 pRoamProfile->mcEncryptionType.encryptionType[0] =
6275 mcEncryptionType;
6276 }
6277 break;
6278
6279 case IW_AUTH_80211_AUTH_ALG:
6280 {
Jeff Johnson5a062372017-01-12 09:51:25 -08006281 /* Save the auth algo here and set auth type to SME
6282 * Roam profile in the iw_set_ap_address
6283 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
6285 pHddStaCtx->conn_info.authType =
6286 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6287
6288 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
6289 pHddStaCtx->conn_info.authType =
6290 eCSR_AUTH_TYPE_SHARED_KEY;
6291
6292 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
6293 /*Not supported */
6294 pHddStaCtx->conn_info.authType =
6295 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6296 pWextState->roamProfile.AuthType.authType[0] =
6297 pHddStaCtx->conn_info.authType;
6298 }
6299 break;
6300
6301 case IW_AUTH_KEY_MGMT:
6302 {
6303#ifdef FEATURE_WLAN_ESE
6304#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
6305 /*Check for CCKM AKM type */
6306 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006307 hdd_debug("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006308 /* Set the CCKM bit in authKeyMgmt */
6309 /*
6310 * Right now, this breaks all ref to authKeyMgmt because
6311 * our code doesn't realize it is a "bitfield"
6312 */
Jeff Johnsond084adb2017-08-16 11:19:52 -07006313 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006314 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
6315 /* Save the key management */
6316 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08006317 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006318 /* Save the key management anyway */
6319 pWextState->authKeyMgmt = wrqu->param.value;
6320 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6321 /* Save the key management */
6322 pWextState->authKeyMgmt |=
6323 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006324 }
6325#else
6326 /* Save the key management */
6327 pWextState->authKeyMgmt = wrqu->param.value;
6328#endif /* FEATURE_WLAN_ESE */
6329 }
6330 break;
6331
6332 case IW_AUTH_TKIP_COUNTERMEASURES:
6333 {
6334 if (wrqu->param.value) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006335 hdd_debug("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006336 wrqu->param.value);
6337 pWextState->mTKIPCounterMeasures =
6338 TKIP_COUNTER_MEASURE_STARTED;
6339 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006340 hdd_debug("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006341 wrqu->param.value);
6342 pWextState->mTKIPCounterMeasures =
6343 TKIP_COUNTER_MEASURE_STOPED;
6344 }
6345 }
6346 break;
6347 case IW_AUTH_DROP_UNENCRYPTED:
6348 case IW_AUTH_WPA_ENABLED:
6349 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6350 case IW_AUTH_ROAMING_CONTROL:
6351 case IW_AUTH_PRIVACY_INVOKED:
6352
6353 default:
6354
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006355 hdd_warn("called with unsupported auth type %d",
6356 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006357 break;
6358 }
6359
6360 EXIT();
6361 return 0;
6362}
6363
6364/**
6365 * iw_set_auth() - set auth callback function
6366 * @dev: Pointer to the net device.
6367 * @info: Pointer to the iw_request_info.
6368 * @wrqu: Pointer to the iwreq_data.
6369 * @extra: Pointer to the data.
6370 *
6371 * Return: 0 for success, error number on failure.
6372 */
6373int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6374 union iwreq_data *wrqu, char *extra)
6375{
6376 int ret;
6377
6378 cds_ssr_protect(__func__);
6379 ret = __iw_set_auth(dev, info, wrqu, extra);
6380 cds_ssr_unprotect(__func__);
6381
6382 return ret;
6383}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006384/**
6385 * __iw_get_auth() -
6386 * This function returns the auth type to the wpa_supplicant
6387 * @dev: pointer to the net device
6388 * @info: pointer to the iw request info
6389 * @wrqu: pointer to iwreq_data
6390 * @extra: pointer to the data
6391 *
6392 * Return: 0 on success, error number otherwise
6393 */
6394static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6395 union iwreq_data *wrqu, char *extra)
6396{
6397 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson49432062017-08-28 12:08:45 -07006398 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006399 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6400 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6401 int ret;
6402
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006403 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006404
6405 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6406 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306407 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006408 return ret;
6409
Jeff Johnson441e1f72017-02-07 08:50:49 -08006410 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6411 if (0 != ret)
6412 return ret;
6413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006414 switch (pRoamProfile->negotiatedAuthType) {
6415 case eCSR_AUTH_TYPE_WPA_NONE:
6416 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6417 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6418 break;
6419 case eCSR_AUTH_TYPE_WPA:
6420 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6421 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6422 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006425 case eCSR_AUTH_TYPE_RSN:
6426 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6427 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6428 break;
6429 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6430 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6431 break;
6432 case eCSR_AUTH_TYPE_SHARED_KEY:
6433 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6434 break;
6435 case eCSR_AUTH_TYPE_UNKNOWN:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006436 hdd_debug("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006437 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6438 break;
6439 case eCSR_AUTH_TYPE_AUTOSWITCH:
6440 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6441 break;
6442 case eCSR_AUTH_TYPE_WPA_PSK:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006443 hdd_debug("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006444 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6445 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006446
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006447 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006448 case eCSR_AUTH_TYPE_RSN_PSK:
6449#ifdef WLAN_FEATURE_11W
6450 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6451 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6452#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006453 hdd_debug("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006454 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6455 return -EIO;
6456 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006457 hdd_warn("Unknown auth type: %d",
6458 pRoamProfile->negotiatedAuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006459 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6460 return -EIO;
6461 }
6462 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6463 switch (pRoamProfile->negotiatedUCEncryptionType) {
6464 case eCSR_ENCRYPT_TYPE_NONE:
6465 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6466 break;
6467 case eCSR_ENCRYPT_TYPE_WEP40:
6468 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6469 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6470 break;
6471 case eCSR_ENCRYPT_TYPE_TKIP:
6472 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6473 break;
6474 case eCSR_ENCRYPT_TYPE_WEP104:
6475 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6476 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6477 break;
6478 case eCSR_ENCRYPT_TYPE_AES:
6479 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6480 break;
6481 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006482 hdd_warn("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006483 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006484 return -EIO;
6485 }
6486 }
6487
6488 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6489 switch (pRoamProfile->negotiatedMCEncryptionType) {
6490 case eCSR_ENCRYPT_TYPE_NONE:
6491 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6492 break;
6493 case eCSR_ENCRYPT_TYPE_WEP40:
6494 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6495 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6496 break;
6497 case eCSR_ENCRYPT_TYPE_TKIP:
6498 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6499 break;
6500 case eCSR_ENCRYPT_TYPE_WEP104:
6501 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6502 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6503 break;
6504 case eCSR_ENCRYPT_TYPE_AES:
6505 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6506 break;
6507 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006508 hdd_err("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006509 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006510 return -EIO;
6511 }
6512 }
6513
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006514 hdd_debug("called with auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006515 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006516 EXIT();
6517 return 0;
6518}
6519
6520/**
6521 * iw_get_auth() - get auth callback function
6522 * @dev: Pointer to the net device.
6523 * @info: Pointer to the iw_request_info.
6524 * @wrqu: Pointer to the iwreq_data.
6525 * @extra: Pointer to the data.
6526 *
6527 * Return: 0 for success, error number on failure.
6528 */
6529int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6530 union iwreq_data *wrqu, char *extra)
6531{
6532 int ret;
6533
6534 cds_ssr_protect(__func__);
6535 ret = __iw_get_auth(dev, info, wrqu, extra);
6536 cds_ssr_unprotect(__func__);
6537
6538 return ret;
6539}
6540
6541/**
6542 * __iw_set_ap_address() - set ap address
6543 * @dev: pointer to the net device
6544 * @info: pointer to the iw request info
6545 * @wrqu: pointer to iwreq_data
6546 * @extra: pointer to the data
6547 *
6548 * This function updates the HDD global station context connection info
6549 * BSSID with the MAC address received from the wpa_supplicant.
6550 *
6551 * Return: 0 on success, error number otherwise
6552 */
6553static int __iw_set_ap_address(struct net_device *dev,
6554 struct iw_request_info *info,
6555 union iwreq_data *wrqu, char *extra)
6556{
6557
6558 hdd_adapter_t *adapter;
Jeff Johnson49432062017-08-28 12:08:45 -07006559 struct hdd_context *hdd_ctx;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07006560 struct hdd_station_ctx *pHddStaCtx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006561 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6562 uint8_t *pMacAddress = NULL;
6563 int ret;
6564
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006565 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006566
6567 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6568
6569 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6570 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306571 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006572 return ret;
6573
Jeff Johnson441e1f72017-02-07 08:50:49 -08006574 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6575 if (0 != ret)
6576 return ret;
6577
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006578 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006579 hdd_debug(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306580 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306581 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582 EXIT();
6583
6584 return 0;
6585}
6586
6587/**
6588 * iw_set_ap_address() - set ap addresses callback function
6589 * @dev: Pointer to the net device.
6590 * @info: Pointer to the iw_request_info.
6591 * @wrqu: Pointer to the iwreq_data.
6592 * @extra: Pointer to the data.
6593 *
6594 * Return: 0 for success, error number on failure.
6595 */
6596int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6597 union iwreq_data *wrqu, char *extra)
6598{
6599 int ret;
6600
6601 cds_ssr_protect(__func__);
6602 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6603 cds_ssr_unprotect(__func__);
6604
6605 return ret;
6606}
6607
6608/**
6609 * __iw_get_ap_address() - get ap address
6610 * @dev: pointer to the net device
6611 * @info: pointer to the iw request info
6612 * @wrqu: pointer to iwreq_data
6613 * @extra: pointer to the data
6614 *
6615 * This function returns currently associated BSSID.
6616 *
6617 * Return: 0 on success, error number otherwise
6618 */
6619static int __iw_get_ap_address(struct net_device *dev,
6620 struct iw_request_info *info,
6621 union iwreq_data *wrqu, char *extra)
6622{
6623 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson49432062017-08-28 12:08:45 -07006624 struct hdd_context *hdd_ctx;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07006625 struct hdd_station_ctx *pHddStaCtx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006626 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6627 int ret;
6628
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006629 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006630
6631 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6632 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306633 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006634 return ret;
6635
Jeff Johnson441e1f72017-02-07 08:50:49 -08006636 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6637 if (0 != ret)
6638 return ret;
6639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006640 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6641 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306642 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006643 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306644 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006645 } else {
6646 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6647 }
6648 EXIT();
6649 return 0;
6650}
6651
6652/**
6653 * iw_get_ap_address() - get ap addresses callback function
6654 * @dev: Pointer to the net device.
6655 * @info: Pointer to the iw_request_info.
6656 * @wrqu: Pointer to the iwreq_data.
6657 * @extra: Pointer to the data.
6658 *
6659 * Return: 0 for success, error number on failure.
6660 */
6661int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6662 union iwreq_data *wrqu, char *extra)
6663{
6664 int ret;
6665
6666 cds_ssr_protect(__func__);
6667 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6668 cds_ssr_unprotect(__func__);
6669
6670 return ret;
6671}