blob: b8d5814d98163a7e2c4e0cddbb78352c156f12b2 [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
68/* These are needed to recognize WPA and RSN suite types */
69#define HDD_WPA_OUI_SIZE 4
70#define HDD_RSN_OUI_SIZE 4
71uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
72uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
73uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
74uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
75uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
76uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
77
78#ifdef FEATURE_WLAN_ESE
79/* CCKM */
80uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
81/* CCKM */
82uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
83#endif /* FEATURE_WLAN_ESE */
84
85/* group cipher */
86uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
87
88/* WEP-40 or RSN */
89uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
90
91/* TKIP or RSN-PSK */
92uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
93
94/* Reserved */
95uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
96
97/* AES-CCMP */
98uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
99
100/* WEP-104 */
101uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
102
103#ifdef WLAN_FEATURE_11W
104/* RSN-PSK-SHA256 */
105uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
106
107/* RSN-8021X-SHA256 */
108uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
109#endif
110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111/* Offset where the EID-Len-IE, start. */
112#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
113#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114
115#define BEACON_FRAME_IES_OFFSET 12
116#define HDD_PEER_AUTHORIZE_WAIT 10
117
118/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700119 * beacon_filter_table - table of IEs used for beacon filtering
120 */
121static const int beacon_filter_table[] = {
122 SIR_MAC_DS_PARAM_SET_EID,
123 SIR_MAC_ERP_INFO_EID,
124 SIR_MAC_EDCA_PARAM_SET_EID,
125 SIR_MAC_QOS_CAPABILITY_EID,
126 SIR_MAC_HT_INFO_EID,
127 SIR_MAC_VHT_OPMODE_EID,
128 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700129#ifdef WLAN_FEATURE_11AX_BSS_COLOR
130 /*
131 * EID: 221 vendor IE is being used temporarily by 11AX
132 * bss-color-change IE till it gets any fixed number. This
133 * vendor EID needs to be replaced with bss-color-change IE
134 * number.
135 */
136 SIR_MAC_EID_VENDOR,
137#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700138};
139
140/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800141 * hdd_conn_set_authenticated() - set authentication state
142 * @pAdapter: pointer to the adapter
143 * @authState: authentication state
144 *
145 * This function updates the global HDD station context
146 * authentication state.
147 *
148 * Return: none
149 */
150static void
151hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
152{
153 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
154 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
155
156 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700157 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700158 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 pHddStaCtx->conn_info.uIsAuthenticated = authState;
160
161 /* Check is pending ROC request or not when auth state changed */
162 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
163}
164
165/**
166 * hdd_conn_set_connection_state() - set connection state
167 * @pAdapter: pointer to the adapter
168 * @connState: connection state
169 *
170 * This function updates the global HDD station context connection state.
171 *
172 * Return: none
173 */
174void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
175 eConnectionState connState)
176{
177 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
178 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
179
180 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700181 hdd_debug("%pS Changed connectionState Changed from oldState:%d to State:%d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530182 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
183 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 pHddStaCtx->conn_info.connState = connState;
185
186 /* Check is pending ROC request or not when connection state changed */
187 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
188}
189
190/**
191 * hdd_conn_get_connection_state() - get connection state
192 * @pAdapter: pointer to the adapter
193 * @pConnState: pointer to connection state
194 *
195 * This function updates the global HDD station context connection state.
196 *
197 * Return: true if (Infra Associated or IBSS Connected)
198 * and sets output parameter pConnState;
199 * false otherwise
200 */
201static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
202 eConnectionState *pConnState)
203{
204 bool fConnected = false;
205 eConnectionState connState;
206
207 /* get the connection state. */
208 connState = pHddStaCtx->conn_info.connState;
209
210 if (eConnectionState_Associated == connState ||
211 eConnectionState_IbssConnected == connState ||
212 eConnectionState_IbssDisconnected == connState) {
213 fConnected = true;
214 }
215
216 if (pConnState)
217 *pConnState = connState;
218
219 return fConnected;
220}
221
222/**
223 * hdd_is_connecting() - Function to check connection progress
224 * @hdd_sta_ctx: pointer to global HDD Station context
225 *
226 * Return: true if connecting, false otherwise
227 */
228bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
229{
230 return hdd_sta_ctx->conn_info.connState ==
231 eConnectionState_Connecting;
232}
233
234/**
235 * hdd_conn_is_connected() - Function to check connection status
236 * @pHddStaCtx: pointer to global HDD Station context
237 *
238 * Return: false if any errors encountered, true otherwise
239 */
240bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
241{
242 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
243}
244
245/**
246 * hdd_conn_get_connected_band() - get current connection radio band
247 * @pHddStaCtx: pointer to global HDD Station context
248 *
249 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
250 * eCSR_BAND_ALL if not connected
251 */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700252enum band_info hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253{
254 uint8_t staChannel = 0;
255
256 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
257 staChannel = pHddStaCtx->conn_info.operationChannel;
258
259 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700260 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700262 return BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263 else /* If station is not connected return as eCSR_BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700264 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265}
266
267/**
268 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
269 * @pHddStaCtx: pointer to global HDD Station context
270 * @pConnectedCipherAlgo: pointer to connected cipher algo
271 *
272 * Return: false if any errors encountered, true otherwise
273 */
274static inline bool
275hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
276 eCsrEncryptionType *pConnectedCipherAlgo)
277{
278 bool fConnected = false;
279
280 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
281
282 if (pConnectedCipherAlgo)
283 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
284
285 return fConnected;
286}
287
288/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700289 * hdd_remove_beacon_filter() - remove beacon filter
290 * @adapter: Pointer to the hdd adapter
291 *
292 * Return: 0 on success and errno on failure
293 */
294static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
295{
296 QDF_STATUS status;
297 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
298
299 status = sme_remove_beacon_filter(hdd_ctx->hHal,
300 adapter->sessionId);
301 if (!QDF_IS_STATUS_SUCCESS(status)) {
302 hdd_err("sme_remove_beacon_filter() failed");
303 return -EFAULT;
304 }
305
306 return 0;
307}
308
309/**
310 * hdd_add_beacon_filter() - add beacon filter
311 * @adapter: Pointer to the hdd adapter
312 *
313 * Return: 0 on success and errno on failure
314 */
315static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
316{
317 int i;
318 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
319 QDF_STATUS status;
320 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
321
322 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530323 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700324 (unsigned long int *)ie_map);
325
326 status = sme_add_beacon_filter(hdd_ctx->hHal,
327 adapter->sessionId, ie_map);
328 if (!QDF_IS_STATUS_SUCCESS(status)) {
329 hdd_err("sme_add_beacon_filter() failed");
330 return -EFAULT;
331 }
332 return 0;
333}
334
335/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530336 * hdd_copy_vht_caps()- copy vht caps info from roam info to
337 * hdd station context.
338 * @hdd_sta_ctx: pointer to hdd station context
339 * @roam_info: pointer to roam info
340 *
341 * Return: None
342 */
343static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
344 tCsrRoamInfo *roam_info)
345{
346 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
347 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
348 uint32_t i, temp_ht_cap;
349
350 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
351
352 if (roam_ht_cap->advCodingCap)
353 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
354 if (roam_ht_cap->supportedChannelWidthSet)
355 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
356 temp_ht_cap = roam_ht_cap->mimoPowerSave &
357 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
358 if (temp_ht_cap)
359 hdd_ht_cap->cap_info |=
360 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
361 if (roam_ht_cap->greenField)
362 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
363 if (roam_ht_cap->shortGI20MHz)
364 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
365 if (roam_ht_cap->shortGI40MHz)
366 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
367 if (roam_ht_cap->txSTBC)
368 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
369 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
370 IEEE80211_HT_CAP_RX_STBC_SHIFT);
371 if (temp_ht_cap)
372 hdd_ht_cap->cap_info |=
373 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
374 if (roam_ht_cap->delayedBA)
375 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
376 if (roam_ht_cap->maximalAMSDUsize)
377 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
378 if (roam_ht_cap->dsssCckMode40MHz)
379 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
380 if (roam_ht_cap->psmp)
381 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
382 if (roam_ht_cap->stbcControlFrame)
383 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
384 if (roam_ht_cap->lsigTXOPProtection)
385 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
386
387 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
388 if (roam_ht_cap->maxRxAMPDUFactor)
389 hdd_ht_cap->ampdu_params_info |=
390 IEEE80211_HT_AMPDU_PARM_FACTOR;
391 temp_ht_cap = roam_ht_cap->mpduDensity &
392 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
393 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
394 if (temp_ht_cap)
395 hdd_ht_cap->ampdu_params_info |=
396 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
397
398 /* 802.11n HT extended capabilities masks */
399 if (roam_ht_cap->pco)
400 hdd_ht_cap->extended_ht_cap_info |=
401 IEEE80211_HT_EXT_CAP_PCO;
402 temp_ht_cap = roam_ht_cap->transitionTime &
403 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
404 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
405 if (temp_ht_cap)
406 hdd_ht_cap->extended_ht_cap_info |=
407 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
408 temp_ht_cap = roam_ht_cap->mcsFeedback &
409 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
410 if (temp_ht_cap)
411 hdd_ht_cap->extended_ht_cap_info |=
412 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
413
414 /* tx_bf_cap_info capabilities */
415 if (roam_ht_cap->txBF)
416 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
417 if (roam_ht_cap->rxStaggeredSounding)
418 hdd_ht_cap->tx_BF_cap_info |=
419 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
420 if (roam_ht_cap->txStaggeredSounding)
421 hdd_ht_cap->tx_BF_cap_info |=
422 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
423 if (roam_ht_cap->rxZLF)
424 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
425 if (roam_ht_cap->txZLF)
426 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
427 if (roam_ht_cap->implicitTxBF)
428 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
429 temp_ht_cap = roam_ht_cap->calibration &
430 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
431 if (temp_ht_cap)
432 hdd_ht_cap->tx_BF_cap_info |=
433 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
434 if (roam_ht_cap->explicitCSITxBF)
435 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
436 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
437 hdd_ht_cap->tx_BF_cap_info |=
438 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
439 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
440 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
441 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
442 if (temp_ht_cap)
443 hdd_ht_cap->tx_BF_cap_info |=
444 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
445 temp_ht_cap =
446 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
447 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
448 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
449 if (temp_ht_cap)
450 hdd_ht_cap->tx_BF_cap_info |=
451 temp_ht_cap <<
452 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
453 temp_ht_cap =
454 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
455 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
456 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
457 if (temp_ht_cap)
458 hdd_ht_cap->tx_BF_cap_info |=
459 temp_ht_cap <<
460 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
461 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
462 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
463 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
464 if (temp_ht_cap)
465 hdd_ht_cap->tx_BF_cap_info |=
466 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
467 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
468 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
469 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
470 if (temp_ht_cap)
471 hdd_ht_cap->tx_BF_cap_info |=
472 temp_ht_cap <<
473 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
474 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
475 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
476 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
477 if (temp_ht_cap)
478 hdd_ht_cap->tx_BF_cap_info |=
479 temp_ht_cap <<
480 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
481
482 /* antenna selection */
483 if (roam_ht_cap->antennaSelection)
484 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
485 if (roam_ht_cap->explicitCSIFeedbackTx)
486 hdd_ht_cap->antenna_selection_info |=
487 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
488 if (roam_ht_cap->antennaIndicesFeedbackTx)
489 hdd_ht_cap->antenna_selection_info |=
490 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
491 if (roam_ht_cap->explicitCSIFeedback)
492 hdd_ht_cap->antenna_selection_info |=
493 ANTENNA_SEL_INFO_EXP_CSI_FB;
494 if (roam_ht_cap->antennaIndicesFeedback)
495 hdd_ht_cap->antenna_selection_info |=
496 ANTENNA_SEL_INFO_ANT_ID_FB;
497 if (roam_ht_cap->rxAS)
498 hdd_ht_cap->antenna_selection_info |=
499 ANTENNA_SEL_INFO_RX_AS;
500 if (roam_ht_cap->txSoundingPPDUs)
501 hdd_ht_cap->antenna_selection_info |=
502 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
503
504 /* mcs data rate */
505 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
506 hdd_ht_cap->mcs.rx_mask[i] =
507 roam_ht_cap->supportedMCSSet[i];
508 hdd_ht_cap->mcs.rx_highest =
509 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
510 ((short) (roam_ht_cap->supportedMCSSet[10]));
511 hdd_ht_cap->mcs.tx_params =
512 roam_ht_cap->supportedMCSSet[12];
513}
514
515#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
516#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
517#define VHT_CAP_RXSTBC_MASK_SHIFT 8
518#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
519#define VHT_CAP_BEAMFORMEE_STS_MASK \
520 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
521#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
522#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
523 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
524#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
525#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
526 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
527#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
528
529/**
530 * hdd_copy_ht_caps()- copy ht caps info from roam info to
531 * hdd station context.
532 * @hdd_sta_ctx: pointer to hdd station context
533 * @roam_info: pointer to roam info
534 *
535 * Return: None
536 */
537static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
538 tCsrRoamInfo *roam_info)
539{
540 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
541 struct ieee80211_vht_cap *hdd_vht_cap =
542 &hdd_sta_ctx->conn_info.vht_caps;
543 uint32_t temp_vht_cap;
544
545 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
546
547 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
548 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
549 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
550 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
551 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
552 if (temp_vht_cap)
553 if (roam_vht_cap->supportedChannelWidthSet &
554 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
555 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
556 hdd_vht_cap->vht_cap_info |=
557 temp_vht_cap <<
558 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
559 if (roam_vht_cap->supportedChannelWidthSet &
560 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
561 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
562 hdd_vht_cap->vht_cap_info |=
563 temp_vht_cap <<
564 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
565 if (roam_vht_cap->ldpcCodingCap)
566 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
567 if (roam_vht_cap->shortGI80MHz)
568 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
569 if (roam_vht_cap->shortGI160and80plus80MHz)
570 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
571 if (roam_vht_cap->txSTBC)
572 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
573 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
574 VHT_CAP_RXSTBC_MASK_SHIFT);
575 if (temp_vht_cap)
576 hdd_vht_cap->vht_cap_info |=
577 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
578 if (roam_vht_cap->suBeamFormerCap)
579 hdd_vht_cap->vht_cap_info |=
580 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
581 if (roam_vht_cap->suBeamformeeCap)
582 hdd_vht_cap->vht_cap_info |=
583 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
584 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
585 (VHT_CAP_BEAMFORMEE_STS_MASK);
586 if (temp_vht_cap)
587 hdd_vht_cap->vht_cap_info |=
588 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
589 temp_vht_cap = roam_vht_cap->numSoundingDim &
590 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
591 if (temp_vht_cap)
592 hdd_vht_cap->vht_cap_info |=
593 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
594 if (roam_vht_cap->muBeamformerCap)
595 hdd_vht_cap->vht_cap_info |=
596 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
597 if (roam_vht_cap->muBeamformeeCap)
598 hdd_vht_cap->vht_cap_info |=
599 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
600 if (roam_vht_cap->vhtTXOPPS)
601 hdd_vht_cap->vht_cap_info |=
602 IEEE80211_VHT_CAP_VHT_TXOP_PS;
603 if (roam_vht_cap->htcVHTCap)
604 hdd_vht_cap->vht_cap_info |=
605 IEEE80211_VHT_CAP_HTC_VHT;
606 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
607 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
608 if (temp_vht_cap)
609 hdd_vht_cap->vht_cap_info |=
610 temp_vht_cap <<
611 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
612 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
613 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
614 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
615 if (temp_vht_cap)
616 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
617 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
618 if (roam_vht_cap->rxAntPattern)
619 hdd_vht_cap->vht_cap_info |=
620 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
621 if (roam_vht_cap->txAntPattern)
622 hdd_vht_cap->vht_cap_info |=
623 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
624 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
625 hdd_vht_cap->supp_mcs.rx_highest =
626 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
627 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
628 hdd_vht_cap->supp_mcs.tx_highest =
629 ((uint16_t)roam_vht_cap->txSupDataRate);
630}
631
632/* ht param */
633#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
634#define HT_PARAM_SERVICE_INT_GRAN 0xe0
635#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
636
637/* operatinon mode */
638#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
639
640/* stbc_param */
641#define HT_STBC_PARAM_MCS 0x007f
642
643/**
644 * hdd_copy_ht_operation()- copy HT operation element from roam info to
645 * hdd station context.
646 * @hdd_sta_ctx: pointer to hdd station context
647 * @roam_info: pointer to roam info
648 *
649 * Return: None
650 */
651static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
652 tCsrRoamInfo *roam_info)
653{
654 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
655 struct ieee80211_ht_operation *hdd_ht_ops =
656 &hdd_sta_ctx->conn_info.ht_operation;
657 uint32_t i, temp_ht_ops;
658
659 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
660
661 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
662
663 /* HT_PARAMS */
664 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
665 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
666 if (temp_ht_ops)
667 hdd_ht_ops->ht_param |= temp_ht_ops;
668 else
669 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
670 if (roam_ht_ops->recommendedTxWidthSet)
671 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
672 if (roam_ht_ops->rifsMode)
673 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
674 if (roam_ht_ops->controlledAccessOnly)
675 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
676 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
677 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
678 if (temp_ht_ops)
679 hdd_ht_ops->ht_param |= temp_ht_ops <<
680 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
681
682 /* operation mode */
683 temp_ht_ops = roam_ht_ops->opMode &
684 IEEE80211_HT_OP_MODE_PROTECTION;
685 switch (temp_ht_ops) {
686 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
687 hdd_ht_ops->operation_mode |=
688 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
689 break;
690 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
691 hdd_ht_ops->operation_mode |=
692 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
693 break;
694 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
695 hdd_ht_ops->operation_mode |=
696 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
697 break;
698 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
699 default:
700 hdd_ht_ops->operation_mode |=
701 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
702 }
703 if (roam_ht_ops->nonGFDevicesPresent)
704 hdd_ht_ops->operation_mode |=
705 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
706 if (roam_ht_ops->transmitBurstLimit)
707 hdd_ht_ops->operation_mode |=
708 HT_OP_MODE_TX_BURST_LIMIT;
709 if (roam_ht_ops->obssNonHTStaPresent)
710 hdd_ht_ops->operation_mode |=
711 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
712
713 /* stbc_param */
714 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
715 HT_STBC_PARAM_MCS;
716 if (temp_ht_ops)
717 hdd_ht_ops->stbc_param |= temp_ht_ops;
718 if (roam_ht_ops->dualCTSProtection)
719 hdd_ht_ops->stbc_param |=
720 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
721 if (roam_ht_ops->secondaryBeacon)
722 hdd_ht_ops->stbc_param |=
723 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
724 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
725 hdd_ht_ops->stbc_param |=
726 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
727 if (roam_ht_ops->pcoActive)
728 hdd_ht_ops->stbc_param |=
729 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
730 if (roam_ht_ops->pcoPhase)
731 hdd_ht_ops->stbc_param |=
732 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
733
734 /* basic MCs set */
735 for (i = 0; i < 16; ++i)
736 hdd_ht_ops->basic_set[i] =
737 roam_ht_ops->basicMCSSet[i];
738}
739
740/**
741 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
742 * hdd station context.
743 * @hdd_sta_ctx: pointer to hdd station context
744 * @roam_info: pointer to roam info
745 *
746 * Return: None
747 */
748static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
749 tCsrRoamInfo *roam_info)
750{
751 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
752 struct ieee80211_vht_operation *hdd_vht_ops =
753 &hdd_sta_ctx->conn_info.vht_operation;
754
755 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
756
757 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
758 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
759 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
760 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
761}
762
763
764/**
765 * hdd_save_bss_info() - save connection info in hdd sta ctx
766 * @adapter: Pointer to adapter
767 * @roam_info: pointer to roam info
768 *
769 * Return: None
770 */
771static void hdd_save_bss_info(hdd_adapter_t *adapter,
772 tCsrRoamInfo *roam_info)
773{
774 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
775
776 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
777 hdd_sta_ctx->conn_info.operationChannel);
778 if (roam_info->vht_caps.present) {
779 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
780 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
781 } else {
782 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
783 }
784 if (roam_info->ht_caps.present) {
785 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
786 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
787 } else {
788 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
789 }
790 if (roam_info->reassoc)
791 hdd_sta_ctx->conn_info.roam_count++;
792 if (roam_info->hs20vendor_ie.present) {
793 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
794 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
795 &roam_info->hs20vendor_ie,
796 sizeof(roam_info->hs20vendor_ie));
797 } else {
798 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
799 }
800 if (roam_info->ht_operation.present) {
801 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
802 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
803 } else {
804 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
805 }
806 if (roam_info->vht_operation.present) {
807 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
808 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
809 } else {
810 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
811 }
812}
813
814/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 * hdd_conn_save_connect_info() - save current connection information
816 * @pAdapter: pointer to adapter
817 * @pRoamInfo: pointer to roam info
818 * @eBssType: bss type
819 *
820 * Return: none
821 */
822static void
823hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
824 eCsrRoamBssType eBssType)
825{
826 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
827 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
828
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530829 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830
831 if (pRoamInfo) {
832 /* Save the BSSID for the connection */
833 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530834 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530835 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 &pRoamInfo->bssid);
837
838 /*
839 * Save the Station ID for this station from
840 * the 'Roam Info'. For IBSS mode, staId is
841 * assigned in NEW_PEER_IND. For reassoc,
842 * the staID doesn't change and it may be invalid
843 * in this structure so no change here.
844 */
845 if (!pRoamInfo->fReassocReq) {
846 pHddStaCtx->conn_info.staId[0] =
847 pRoamInfo->staId;
848 }
849 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530850 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851 &pRoamInfo->bssid);
852 } else {
853 /*
854 * can't happen. We need a valid IBSS or Infra setting
855 * in the BSSDescription or we can't function.
856 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530857 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 }
859
860 /* notify WMM */
861 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
862
863 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530864 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 } else {
866 /* Get Multicast Encryption Type */
867 encryptType =
868 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
869 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
870 /* Get Unicast Encryption Type */
871 encryptType =
872 pRoamInfo->u.pConnectedProfile->EncryptionType;
873 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
874
875 pHddStaCtx->conn_info.authType =
876 pRoamInfo->u.pConnectedProfile->AuthType;
877
878 pHddStaCtx->conn_info.operationChannel =
879 pRoamInfo->u.pConnectedProfile->operationChannel;
880
881 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530882 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 &pRoamInfo->u.pConnectedProfile->SSID,
884 sizeof(tSirMacSSid));
885
886 /* Save dot11mode in which STA associated to AP */
887 pHddStaCtx->conn_info.dot11Mode =
888 pRoamInfo->u.pConnectedProfile->dot11Mode;
889
890 pHddStaCtx->conn_info.proxyARPService =
891 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530892
893 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
894
895 pHddStaCtx->conn_info.rate_flags =
896 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530898 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900}
901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902/**
903 * hdd_send_ft_assoc_response() - send fast transition assoc response
904 * @dev: pointer to net device
905 * @pAdapter: pointer to adapter
906 * @pCsrRoamInfo: pointer to roam info
907 *
908 * Send the 11R key information to the supplicant. Only then can the supplicant
909 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
910 * for the same purpose.)
911 *
912 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
913 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
914 * This is the Assoc Response.
915 *
916 * Return: none
917 */
918static void
919hdd_send_ft_assoc_response(struct net_device *dev,
920 hdd_adapter_t *pAdapter,
921 tCsrRoamInfo *pCsrRoamInfo)
922{
923 union iwreq_data wrqu;
924 char *buff;
925 unsigned int len = 0;
926 u8 *pFTAssocRsp = NULL;
927
928 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700929 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 return;
931 }
932
933 pFTAssocRsp =
934 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
935 pCsrRoamInfo->nAssocReqLength);
936 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700937 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 return;
939 }
940 /* pFTAssocRsp needs to point to the IEs */
941 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700942 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700943 (unsigned int)pFTAssocRsp[0],
944 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945
946 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700947 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700949 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 return;
951 }
952 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
953 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
954 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 memcpy(buff, pFTAssocRsp, len);
956 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
957
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700958 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961/**
962 * hdd_send_ft_event() - send fast transition event
963 * @pAdapter: pointer to adapter
964 *
965 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
966 * FT events to the supplicant. At the reception of Auth2 we send the RIC
967 * followed by the auth response IEs to the supplicant.
968 * Once both are received in the supplicant, an FT event is generated
969 * to the supplicant.
970 *
971 * Return: none
972 */
973static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
974{
975 uint16_t auth_resp_len = 0;
976 uint32_t ric_ies_length = 0;
977 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
978
979#if defined(KERNEL_SUPPORT_11R_CFG80211)
980 struct cfg80211_ft_event_params ftEvent;
981 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
982 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
983 struct net_device *dev = pAdapter->dev;
984#else
985 char *buff;
986 union iwreq_data wrqu;
987 uint16_t str_len;
988#endif
989
990#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530991 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
992 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993
994 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
995 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700996 if (ric_ies_length == 0)
997 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998
999 ftEvent.ric_ies = ricIe;
1000 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001001 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002
1003 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1004 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1005 &auth_resp_len);
1006
1007 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001008 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 return;
1010 }
1011
1012 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1013
1014 ftEvent.target_ap = ftIe;
1015
Anurag Chouhan6d760662016-02-20 16:05:43 +05301016 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1017 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001019 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1020 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1021 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001022 ftEvent.target_ap[0], ftEvent.target_ap[1],
1023 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1024 ftEvent.target_ap[5]);
1025
1026 (void)cfg80211_ft_event(dev, &ftEvent);
1027
1028#else
1029 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001030 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001032 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 return;
1034 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035
1036 /* Sme needs to send the RIC IEs first */
1037 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1038 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1039 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1040 &ric_ies_length);
1041 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001042 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 } else {
1044 wrqu.data.length = str_len + ric_ies_length;
1045 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1046 }
1047
1048 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301049 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1051 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1052 (u8 *) &buff[str_len],
1053 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1054
1055 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001056 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001057 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 return;
1059 }
1060
1061 wrqu.data.length = str_len + auth_resp_len;
1062 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1063
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001064 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065#endif
1066}
1067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068#ifdef FEATURE_WLAN_ESE
1069/**
1070 * hdd_send_new_ap_channel_info() - send new ap channel info
1071 * @dev: pointer to net device
1072 * @pAdapter: pointer to adapter
1073 * @pCsrRoamInfo: pointer to roam info
1074 *
1075 * Send the ESE required "new AP Channel info" to the supplicant.
1076 * (This keeps the supplicant "up to date" on the current channel.)
1077 *
1078 * The current (new AP) channel information is passed in.
1079 *
1080 * Return: none
1081 */
1082static void
1083hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1084 tCsrRoamInfo *pCsrRoamInfo)
1085{
1086 union iwreq_data wrqu;
1087 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1088
1089 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001090 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 return;
1092 }
1093 /*
1094 * Send the Channel event, the supplicant needs this to generate
1095 * the Adjacent AP report.
1096 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001097 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001098 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099 memset(&wrqu, '\0', sizeof(wrqu));
1100 wrqu.freq.m = descriptor->channelId;
1101 wrqu.freq.e = 0;
1102 wrqu.freq.i = 0;
1103 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1104}
1105
1106#endif /* FEATURE_WLAN_ESE */
1107
1108/**
1109 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1110 * @pAdapter: pointer to adapter
1111 * @pCsrRoamInfo: pointer to roam info
1112 *
1113 * Return: none
1114 */
1115static void
1116hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1117 tCsrRoamInfo *pCsrRoamInfo)
1118{
1119 union iwreq_data wrqu;
1120 u8 *pBeaconIes;
1121 u8 currentLen = 0;
1122 char *buff;
1123 int totalIeLen = 0, currentOffset = 0, strLen;
1124
1125 memset(&wrqu, '\0', sizeof(wrqu));
1126
1127 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001128 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 return;
1130 }
1131 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1132 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001133 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 return;
1135 }
1136 /* pBeaconIes needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001137 hdd_debug("Beacon IEs is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001138 (unsigned int)pBeaconIes[0],
1139 (unsigned int)pBeaconIes[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001140 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001141 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142
1143 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001144 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001146 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 return;
1148 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149
1150 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1151 currentLen = strLen + 1;
1152
1153 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1154 do {
1155 /*
1156 * If the beacon size exceeds max CUSTOM event size, break it
1157 * into chunks of CUSTOM event max size and send it to
1158 * supplicant. Changes are done in supplicant to handle this.
1159 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301160 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001161 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301162 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301163 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 currentLen);
1165 currentOffset += currentLen;
1166 totalIeLen -= currentLen;
1167 wrqu.data.length = strLen + 1 + currentLen;
1168 if (totalIeLen)
1169 buff[strLen] = 1; /* more chunks pending */
1170 else
1171 buff[strLen] = 0; /* last chunk */
1172
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001173 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001174 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1176 } while (totalIeLen > 0);
1177
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001178 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001179}
1180
1181/**
1182 * hdd_send_association_event() - send association event
1183 * @dev: pointer to net device
1184 * @pCsrRoamInfo: pointer to roam info
1185 *
1186 * Return: none
1187 */
1188static void hdd_send_association_event(struct net_device *dev,
1189 tCsrRoamInfo *pCsrRoamInfo)
1190{
Rajeev Kumar78427682017-01-13 16:13:11 -08001191 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1193 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1194 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1195 union iwreq_data wrqu;
1196 int we_event;
1197 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301198 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200 /* Added to find the auth type on the fly at run time */
1201 /* rather than with cfg to see if FT is enabled */
1202 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1203 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204
1205 memset(&wrqu, '\0', sizeof(wrqu));
1206 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1207 we_event = SIOCGIWAP;
1208#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1209 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301210 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001212 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301213 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001214 hdd_notify_sta_disconnect(pAdapter->sessionId,
1215 true, pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301216 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301217 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218#endif
1219 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001220 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301221
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001223 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224 return;
1225 }
1226
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001227 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001228 policy_mgr_incr_active_session(pHddCtx->hdd_psoc,
1229 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1231 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1232
1233#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001234 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 if (global_p2p_connection_status ==
1236 P2P_CLIENT_CONNECTING_STATE_1) {
1237 global_p2p_connection_status =
1238 P2P_CLIENT_CONNECTED_STATE_1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001239 hdd_debug("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 } else if (global_p2p_connection_status ==
1241 P2P_CLIENT_CONNECTING_STATE_2) {
1242 global_p2p_connection_status =
1243 P2P_CLIENT_COMPLETED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001244 hdd_debug("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 }
1246 }
1247#endif
1248 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1249 MAC_ADDRESS_STR "\n",
1250 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1251 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1252 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1253
1254 /*
1255 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1256 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001257 * fFTEnable is true.
1258 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 if ((pRoamProfile->AuthType.authType[0] ==
1261 eCSR_AUTH_TYPE_FT_RSN_PSK)
1262 || (pRoamProfile->AuthType.authType[0] ==
1263 eCSR_AUTH_TYPE_FT_RSN)
1264#ifdef FEATURE_WLAN_ESE
1265 || (pRoamProfile->AuthType.authType[0] ==
1266 eCSR_AUTH_TYPE_CCKM_RSN)
1267 || (pRoamProfile->AuthType.authType[0] ==
1268 eCSR_AUTH_TYPE_CCKM_WPA)
1269#endif
1270 ) {
1271 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1272 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301273 qdf_copy_macaddr(&peerMacAddr,
1274 &pHddStaCtx->conn_info.bssId);
1275 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1276 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1277 chan_info.info = pCsrRoamInfo->chan_info.info;
1278 chan_info.band_center_freq1 =
1279 pCsrRoamInfo->chan_info.band_center_freq1;
1280 chan_info.band_center_freq2 =
1281 pCsrRoamInfo->chan_info.band_center_freq2;
1282 chan_info.reg_info_1 =
1283 pCsrRoamInfo->chan_info.reg_info_1;
1284 chan_info.reg_info_2 =
1285 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301286
Dustin Brown7d043f62017-03-27 12:07:36 -07001287 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1288 pAdapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301289 peerMacAddr.bytes,
1290 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001291 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301292 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1293 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001294 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1295 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301296 if (ret)
1297 hdd_err("Peer object %pM fail to set associated state",
1298 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301299
Abhishek Singh1c676222016-05-09 14:20:28 +05301300 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001301 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1302 ePeerConnected,
1303 pCsrRoamInfo->timingMeasCap,
1304 pAdapter->sessionId, &chan_info,
1305 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001306 /* Update tdls module about connection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001307 hdd_notify_sta_connect(pAdapter->sessionId,
1308 pCsrRoamInfo->tdls_chan_swit_prohibited,
1309 pCsrRoamInfo->tdls_prohibited,
1310 pAdapter->hdd_vdev);
1311
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001312 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001313
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001314
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001316#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 /* start timer in sta/p2p_cli */
1318 spin_lock_bh(&pHddCtx->bus_bw_lock);
1319 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1320 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001321 cdp_get_intra_bss_fwd_pkts_count(
1322 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301323 &pAdapter->prev_fwd_tx_packets,
1324 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001326 hdd_bus_bw_compute_timer_start(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327#endif
1328#endif
1329 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1330 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001331 policy_mgr_update_connection_info(pHddCtx->hdd_psoc,
1332 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001334 ETH_ALEN);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001335 hdd_info("wlan: new IBSS connection to " MAC_ADDRESS_STR,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001336 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301337
Dustin Brown7d043f62017-03-27 12:07:36 -07001338 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1339 QDF_IBSS_MODE,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301340 pCsrRoamInfo->bssid.bytes,
1341 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001342 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301343 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1344 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001345 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1346 WLAN_ASSOC_STATE);
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301347 if (ret)
1348 hdd_err("Peer object %pM fail to set associated state",
1349 peerMacAddr.bytes);
1350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 } else { /* Not Associated */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001352 hdd_info("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001354 policy_mgr_decr_session_set_pcl(pHddCtx->hdd_psoc,
1355 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356
1357#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1358 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1359#endif
1360
Abhishek Singh1c676222016-05-09 14:20:28 +05301361 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1362 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301363 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 &pHddStaCtx->conn_info.bssId);
1365
1366 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001367 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301368 ePeerDisconnected, 0,
1369 pAdapter->sessionId,
1370 NULL,
1371 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301373
Dustin Brown7d043f62017-03-27 12:07:36 -07001374 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
1375 peerMacAddr.bytes);
Rajeev Kumardfa37072017-01-13 16:27:22 -08001376 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301377 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1378 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1379
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001380 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001381 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001382 hdd_notify_sta_disconnect(pAdapter->sessionId,
1383 false,
1384 pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301385 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001386
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387#ifdef MSM_PLATFORM
1388 /* stop timer in sta/p2p_cli */
1389 spin_lock_bh(&pHddCtx->bus_bw_lock);
1390 pAdapter->prev_tx_packets = 0;
1391 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301392 pAdapter->prev_fwd_tx_packets = 0;
1393 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001395 hdd_bus_bw_compute_timer_try_stop(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396#endif
1397 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001398 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 /* Send SCC/MCC Switching event to IPA */
1400 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1401
1402 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001403 /* During the WLAN uninitialization,supplicant is stopped before the
1404 * driver so not sending the status of the connection to supplicant
1405 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001406 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 wireless_send_event(dev, we_event, &wrqu, msg);
1408#ifdef FEATURE_WLAN_ESE
1409 if (eConnectionState_Associated ==
1410 pHddStaCtx->conn_info.connState) {
1411 if ((pRoamProfile->AuthType.authType[0] ==
1412 eCSR_AUTH_TYPE_CCKM_RSN) ||
1413 (pRoamProfile->AuthType.authType[0] ==
1414 eCSR_AUTH_TYPE_CCKM_WPA))
1415 hdd_send_new_ap_channel_info(dev, pAdapter,
1416 pCsrRoamInfo);
1417 }
1418#endif
1419 }
1420}
1421
1422/**
1423 * hdd_conn_remove_connect_info() - remove connection info
1424 * @pHddStaCtx: pointer to global HDD station context
1425 * @pCsrRoamInfo: pointer to roam info
1426 *
1427 * Return: none
1428 */
1429static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1430{
1431 /* Remove staId, bssId and peerMacAddress */
1432 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301433 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1434 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301435 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436
1437 /* Clear all security settings */
1438 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1439 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1440 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1441
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301442 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1443 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 pHddStaCtx->conn_info.proxyARPService = 0;
1446
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301447 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448}
1449
1450/**
1451 * hdd_roam_deregister_sta() - deregister station
1452 * @pAdapter: pointer to adapter
1453 * @staId: station identifier
1454 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301455 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 */
Abhishek Singh07c627e2017-03-20 17:56:34 +05301457QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301459 QDF_STATUS qdf_status;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301460 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1461 int ret = 0;
1462 uint8_t *peer_mac = NULL;
1463 struct qdf_mac_addr broadcastMacAddr =
1464 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 if (eConnectionState_IbssDisconnected ==
1466 pHddStaCtx->conn_info.connState) {
1467 /*
1468 * Do not set the carrier off when the last peer leaves.
1469 * We will set the carrier off while stopping the IBSS.
1470 */
1471 }
1472
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001473 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001474 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301475 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301476 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301477 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1478 staid, qdf_status, qdf_status);
1479 }
1480
1481 if (adapter->device_mode == QDF_STA_MODE) {
1482 peer_mac = pHddStaCtx->conn_info.bssId.bytes;
1483 } else if (adapter->device_mode == QDF_IBSS_MODE) {
1484 if (pHddStaCtx->broadcast_staid == staid)
1485 peer_mac = broadcastMacAddr.bytes;
1486 else
1487 peer_mac = pHddStaCtx->conn_info.
1488 peerMacAddress[staid].bytes;
1489 }
1490
Dustin Brown7d043f62017-03-27 12:07:36 -07001491 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301492 if (ret) {
1493 hdd_err("Peer obj %pM delete fails", peer_mac);
1494 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301496 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497}
1498
1499/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301500 * hdd_print_bss_info() - print bss info
1501 * @hdd_sta_ctx: pointer to hdd station context
1502 *
1503 * Return: None
1504 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001505static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301506{
1507 uint32_t *cap_info;
1508
1509 hdd_info("WIFI DATA LOGGER");
1510 hdd_info("channel: %d",
1511 hdd_sta_ctx->conn_info.freq);
1512 hdd_info("dot11mode: %d",
1513 hdd_sta_ctx->conn_info.dot11Mode);
1514 hdd_info("AKM: %d",
1515 hdd_sta_ctx->conn_info.authType);
1516 hdd_info("ssid: %.*s",
1517 hdd_sta_ctx->conn_info.SSID.SSID.length,
1518 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1519 hdd_info("roam count: %d",
1520 hdd_sta_ctx->conn_info.roam_count);
1521 hdd_info("ant_info: %d",
1522 hdd_sta_ctx->conn_info.txrate.nss);
1523 hdd_info("datarate legacy %d",
1524 hdd_sta_ctx->conn_info.txrate.legacy);
1525 hdd_info("datarate mcs: %d",
1526 hdd_sta_ctx->conn_info.txrate.mcs);
1527 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1528 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1529 hdd_info("ht caps: %x", *cap_info);
1530 }
1531 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1532 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1533 hdd_info("vht caps: %x", *cap_info);
1534 }
1535 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1536 hdd_info("hs20 info: %x",
1537 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1538 hdd_info("signal: %d",
1539 hdd_sta_ctx->conn_info.signal);
1540 hdd_info("noise: %d",
1541 hdd_sta_ctx->conn_info.noise);
1542}
1543
1544/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 * hdd_dis_connect_handler() - disconnect event handler
1546 * @pAdapter: pointer to adapter
1547 * @pRoamInfo: pointer to roam info
1548 * @roamId: roam identifier
1549 * @roamStatus: roam status
1550 * @roamResult: roam result
1551 *
1552 * This function handles disconnect event:
1553 * 1. Disable transmit queues;
1554 * 2. Clean up internal connection states and data structures;
1555 * 3. Send disconnect indication to supplicant.
1556 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301557 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301559static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 tCsrRoamInfo *pRoamInfo,
1561 uint32_t roamId,
1562 eRoamCmdStatus roamStatus,
1563 eCsrRoamResult roamResult)
1564{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301565 QDF_STATUS status = QDF_STATUS_SUCCESS;
1566 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 struct net_device *dev = pAdapter->dev;
1568 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1569 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1570 uint8_t sta_id;
1571 bool sendDisconInd = true;
1572
1573 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001574 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301575 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 }
1577 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001578 hdd_notice("Disabling queues");
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301579 wlan_hdd_netif_queue_control(pAdapter,
1580 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1581 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582
1583 if (hdd_ipa_is_enabled(pHddCtx))
1584 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001585 HDD_IPA_STA_DISCONNECT,
1586 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587
1588#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1589 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1590#endif
1591
Nirav Shah1da77682016-05-03 20:16:39 +05301592 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1593 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001594 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301595 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596
1597 /* HDD has initiated disconnect, do not send disconnect indication
1598 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301599 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 * to cfg80211_disconnected.
1601 */
1602 if ((eConnectionState_Disconnecting ==
1603 pHddStaCtx->conn_info.connState) ||
1604 (eConnectionState_NotConnected ==
1605 pHddStaCtx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001606 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 sendDisconInd = false;
1608 }
1609
1610 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1611 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 hdd_conn_set_connection_state(pAdapter,
1613 eConnectionState_Disconnecting);
1614 }
1615
1616 hdd_clear_roam_profile_ie(pAdapter);
1617 hdd_wmm_init(pAdapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001618 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301619 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620
1621 /* indicate 'disconnect' status to wpa_supplicant... */
1622 hdd_send_association_event(dev, pRoamInfo);
1623 /* indicate disconnected event to nl80211 */
1624 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1625 /*
1626 * Only send indication to kernel if not initiated
1627 * by kernel
1628 */
1629 if (sendDisconInd) {
1630 /*
1631 * To avoid wpa_supplicant sending "HANGED" CMD
1632 * to ICS UI.
1633 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001634 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1635 if (pRoamInfo->reasonCode ==
1636 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1637 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301638 wlan_hdd_cfg80211_indicate_disconnect(
1639 dev, false,
1640 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001641 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301642 wlan_hdd_cfg80211_indicate_disconnect(
1643 dev, false,
1644 WLAN_REASON_UNSPECIFIED
1645 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001646 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301648 hdd_info("sent disconnected event to nl80211, reason code %d",
1649 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1650 pRoamInfo->reasonCode :
1651 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 }
1653 /*
1654 * During the WLAN uninitialization,supplicant is stopped
1655 * before the driver so not sending the status of the
1656 * connection to supplicant.
1657 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001658 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001660 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 if (global_p2p_connection_status ==
1662 P2P_CLIENT_CONNECTED_STATE_1) {
1663 global_p2p_connection_status =
1664 P2P_CLIENT_DISCONNECTED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001665 hdd_debug("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 } else if (global_p2p_connection_status ==
1667 P2P_CLIENT_COMPLETED_STATE) {
1668 global_p2p_connection_status =
1669 P2P_NOT_ACTIVE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001670 hdd_debug("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 }
1672 }
1673#endif
1674
1675 }
1676 }
1677
1678 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001680 if (hdd_remove_beacon_filter(pAdapter) != 0)
1681 hdd_err("hdd_remove_beacon_filter() failed");
1682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301684 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001685
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001686 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301688 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001689 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301690 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301691 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 }
1693 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301694 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001695 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001696 if (HDD_WLAN_INVALID_STA_ID ==
1697 pHddStaCtx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301698 continue;
1699 sta_id = pHddStaCtx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001700 hdd_debug("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301701 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301702 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001703 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301704 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301705 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301706 }
1707 /* set the staid and peer mac as 0, all other
1708 * reset are done in hdd_connRemoveConnectInfo.
1709 */
1710 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301711 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301712 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301713 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1714 pHddCtx->sta_to_adapter[sta_id] = NULL;
1715 }
1716 } else {
1717 sta_id = pHddStaCtx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001718 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301719
1720 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001721 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1722 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301723 eCSR_ROAM_LOSTLINK == roamStatus) {
Abhishek Singhc9941602016-08-09 16:06:22 +05301724 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1725 pHddStaCtx->conn_info.bssId.bytes);
1726 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1727 pHddStaCtx->conn_info.bssId.bytes);
1728 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301729 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 /* Clear saved connection information in HDD */
1732 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301734 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735
1736#ifdef FEATURE_WLAN_TDLS
1737 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1738 wlan_hdd_tdls_disconnection_callback(pAdapter);
1739#endif
1740
Krunal Sonibe766b02016-03-10 13:00:44 -08001741 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1742 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1744 (pAdapter),
1745 pAdapter->sessionId);
1746 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301747 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 /* Unblock anyone waiting for disconnect to complete */
1749 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301750 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 return status;
1752}
1753
1754/**
1755 * hdd_set_peer_authorized_event() - set peer_authorized_event
1756 * @vdev_id: vdevid
1757 *
1758 * Return: None
1759 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001760static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301762 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763 hdd_adapter_t *adapter = NULL;
1764
1765 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1766 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001767 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001768 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 }
1770 complete(&adapter->sta_authorized_event);
1771}
1772
1773/**
1774 * hdd_change_peer_state() - change peer state
1775 * @pAdapter: HDD adapter
1776 * @sta_state: peer state
1777 * @roam_synch_in_progress: roam synch in progress
1778 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301779 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301781QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 uint8_t sta_id,
1783 enum ol_txrx_peer_state sta_state,
1784 bool roam_synch_in_progress)
1785{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301786 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001787 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001788 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1789 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1790 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791
1792 if (!pdev) {
1793 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301794 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 }
1796
1797 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001798 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301799 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 }
1801
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001802 peer = cdp_peer_find_by_local_id(soc,
1803 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301805 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806
Leo Changfdb45c32016-10-28 11:09:23 -07001807 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001808 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001809 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001810 return QDF_STATUS_E_FAULT;
1811 }
1812
Leo Changfdb45c32016-10-28 11:09:23 -07001813 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301814 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001815 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301816 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 }
1818#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1819 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301820 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821#endif
1822
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001823 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1825 /* make sure event is reset */
1826 INIT_COMPLETION(pAdapter->sta_authorized_event);
1827#endif
1828
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001829 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 hdd_set_peer_authorized_event,
1831 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301832 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001833 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301834 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 }
1836
Krunal Sonibe766b02016-03-10 13:00:44 -08001837 if (pAdapter->device_mode == QDF_STA_MODE ||
1838 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001840 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 unsigned long rc;
1842
1843 /* wait for event from firmware to set the event */
1844 rc = wait_for_completion_timeout(
1845 &pAdapter->sta_authorized_event,
1846 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001847 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001848 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001849
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001850 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1851 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001852 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853#endif
1854 }
1855 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301856 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857}
1858
1859/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001860 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1861 * @cbk_data: callback data
1862 * @sta_id: station id
1863 * @vdev_param: vdev parameter
1864 * @is_link_up: link state up or down
1865 *
1866 * Return: QDF status
1867 */
1868QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1869 uint8_t sta_id,
1870 uint32_t vdev_param,
1871 bool is_link_up)
1872{
1873 struct cdp_vdev *data_vdev;
1874 QDF_STATUS status = QDF_STATUS_SUCCESS;
1875 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1876 hdd_context_t *hdd_ctx;
1877 struct wlan_objmgr_psoc **psoc;
1878
1879 if (!cbk_data)
1880 return status;
1881
1882 psoc = cbk_data;
1883 hdd_ctx = container_of(psoc, hdd_context_t, hdd_psoc);
1884
1885 if (!hdd_ctx->tdls_nap_active)
1886 return status;
1887
1888 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, sta_id);
1889 if (NULL == data_vdev) {
1890 status = QDF_STATUS_E_FAILURE;
1891 return status;
1892 }
1893
1894 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1895
1896 return status;
1897}
1898
1899/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 * hdd_roam_register_sta() - register station
1901 * @pAdapter: pointer to adapter
1902 * @pRoamInfo: pointer to roam info
1903 * @staId: station identifier
1904 * @pPeerMacAddress: peer MAC address
1905 * @pBssDesc: pointer to BSS description
1906 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301907 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001909QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 tCsrRoamInfo *pRoamInfo,
1911 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301912 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 tSirBssDescription *pBssDesc)
1914{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301915 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 struct ol_txrx_desc_type staDesc = { 0 };
1917 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001918 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001919 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1920 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921
1922 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301923 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924
1925 /* Get the Station ID from the one saved during the association */
1926 staDesc.sta_id = staId;
1927
1928 /* set the QoS field appropriately */
1929 if (hdd_wmm_is_active(pAdapter))
1930 staDesc.is_qos_enabled = 1;
1931 else
1932 staDesc.is_qos_enabled = 0;
1933
1934#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001935 hdd_notice("WAPI STA Registered: %d",
1936 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 if (pAdapter->wapi_info.fIsWapiSta)
1938 staDesc.is_wapi_supported = 1;
1939 else
1940 staDesc.is_wapi_supported = 0;
1941#endif /* FEATURE_WLAN_WAPI */
1942
Dhanashri Atre50141c52016-04-07 13:15:29 -07001943 /* Register the vdev transmit and receive functions */
1944 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1945 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001946
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001947 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1948 (struct cdp_pdev *)pdev,
1949 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001950 if (!pAdapter->txrx_vdev) {
1951 hdd_err("%s find vdev fail", __func__);
1952 return QDF_STATUS_E_FAILURE;
1953 }
1954
1955 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001956 cdp_vdev_register(soc,
1957 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001958 if (!txrx_ops.tx.tx) {
1959 hdd_err("%s vdev register fail", __func__);
1960 return QDF_STATUS_E_FAILURE;
1961 }
1962
Dhanashri Atre50141c52016-04-07 13:15:29 -07001963 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001964 qdf_status = cdp_peer_register(soc,
1965 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301966 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001967 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001968 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301969 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 }
1971
1972 if (!pRoamInfo->fAuthRequired) {
1973 /*
1974 * Connections that do not need Upper layer auth, transition
1975 * TLSHIM directly to 'Authenticated' state
1976 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301977 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001979 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1981 pRoamInfo->roamSynchInProgress
1982#else
1983 false
1984#endif
1985 );
1986
1987 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001988 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001990 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301992 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001994 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1996 pRoamInfo->roamSynchInProgress
1997#else
1998 false
1999#endif
2000 );
2001 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002002 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302004 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005}
2006
2007/**
2008 * hdd_send_re_assoc_event() - send reassoc event
2009 * @dev: pointer to net device
2010 * @pAdapter: pointer to adapter
2011 * @pCsrRoamInfo: pointer to roam info
2012 * @reqRsnIe: pointer to RSN Information element
2013 * @reqRsnLength: length of RSN IE
2014 *
2015 * Return: none
2016 */
2017static void hdd_send_re_assoc_event(struct net_device *dev,
2018 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
2019 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2020{
2021 unsigned int len = 0;
2022 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002023 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2024 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 uint32_t rspRsnLength = 0;
2026 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2028 uint8_t *buf_ptr, ssid_ie_len;
2029 struct cfg80211_bss *bss = NULL;
2030 uint8_t *final_req_ie = NULL;
2031 tCsrRoamConnectedProfile roam_profile;
2032 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002033 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002035 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002038 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002039 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 }
2041
Naveen Rawat14298b92015-11-25 16:27:41 -08002042 if (!assoc_req_ies) {
2043 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002044 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002045 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002047 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 goto done;
2049 }
2050
2051 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002052 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 goto done;
2054 }
2055
2056 pFTAssocRsp =
2057 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2058 pCsrRoamInfo->nAssocReqLength);
2059 if (pFTAssocRsp == NULL)
2060 goto done;
2061
2062 /* pFTAssocRsp needs to point to the IEs */
2063 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002064 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002065 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066
2067 /*
2068 * Active session count is decremented upon disconnection, but during
2069 * roaming, there is no disconnect indication and hence active session
2070 * count is not decremented.
2071 * After roaming is completed, active session count is incremented
2072 * as a part of connect indication but effectively after roaming the
2073 * active session count should still be the same and hence upon
2074 * successful reassoc decrement the active session count here.
2075 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002076 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002077 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
2078 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079
2080 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2081 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2082 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302083 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2084 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085
2086 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302087 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2089 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302090
2091 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2092 chan, pCsrRoamInfo->bssid.bytes,
2093 &roam_profile.SSID.ssId[0],
2094 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095
2096 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002097 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 buf_ptr = buf_ssid_ie;
2099 *buf_ptr = SIR_MAC_SSID_EID;
2100 buf_ptr++;
2101 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2102 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302103 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 roam_profile.SSID.length);
2105 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002106 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302107 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002108 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002109 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 if (final_req_ie == NULL)
2111 goto done;
2112 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302113 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302115 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2116 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2117 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002119 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302120 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002121 final_req_ie, (ssid_ie_len + reqRsnLength));
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08002122 cfg80211_roamed_bss(dev, bss,
2123 final_req_ie, (ssid_ie_len + reqRsnLength),
2124 rspRsnIe, rspRsnLength, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302126 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002127 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2128 pCsrRoamInfo->nAssocReqLength);
2129
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002130 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302131 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002132 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2133
Prakash Dhavali989127d2016-11-29 14:56:44 +05302134 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002135 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2136 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002137 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002139 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002141 qdf_mem_free(final_req_ie);
2142 qdf_mem_free(rspRsnIe);
2143 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144}
2145
2146/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302147 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002148 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302149 *
2150 * Return: roam sync status if roaming offloaded else false
2151 */
2152#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002153bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302154{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002155 if (roaminfo)
2156 return roaminfo->roamSynchInProgress;
2157 else
2158 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302159}
2160#endif
2161
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002162/**
2163 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2164 * @hddstactx: pointer to HDD sta context
2165 * @roaminfo: pointer to roaminfo structure
2166 *
2167 * This function returns staid for IBSS peer. If peer is broadcast
2168 * MAC address return self staid(0) else find the peer sta id of
2169 * the peer.
2170 *
2171 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2172 */
2173static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2174 tCsrRoamInfo *roaminfo)
2175{
2176 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2177 QDF_STATUS status;
2178
2179 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2180 staid = 0;
2181 } else {
2182 status = hdd_get_peer_sta_id(hddstactx,
2183 &roaminfo->peerMac, &staid);
2184 if (status != QDF_STATUS_SUCCESS) {
2185 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2186 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2187 }
2188 }
2189
2190 return staid;
2191}
Govind Singhedc5cda2015-10-23 17:11:35 +05302192
2193/**
2194 * hdd_change_sta_state_authenticated()-
2195 * This function changes STA state to authenticated
2196 * @adapter: pointer to the adapter structure.
2197 * @roaminfo: pointer to the RoamInfo structure.
2198 *
2199 * This is called from hdd_RoamSetKeyCompleteHandler
2200 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2201 *
2202 * Return: 0 on success and errno on failure
2203 */
2204static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2205 tCsrRoamInfo *roaminfo)
2206{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002207 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002208 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002209 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302210 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002211 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302212
Dustin Brownf660fb42016-09-09 12:04:00 -07002213 timeout = hddstactx->hdd_ReassocScenario ?
2214 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002215 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002216
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002217 if (QDF_IBSS_MODE == adapter->device_mode)
2218 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2219 else
2220 staid = hddstactx->conn_info.staId[0];
2221
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002222 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302223
2224 /* Connections that do not need Upper layer authentication,
2225 * transition TL to 'Authenticated' state after the keys are set
2226 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002227 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302228 hdd_is_roam_sync_in_progress(roaminfo));
2229 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002230 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2231
Krunal Sonibe766b02016-03-10 13:00:44 -08002232 if ((QDF_STA_MODE == adapter->device_mode) ||
2233 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302234 sme_ps_enable_auto_ps_timer(
2235 WLAN_HDD_GET_HAL_CTX(adapter),
2236 adapter->sessionId,
Krunal Soni364e0872017-05-10 21:24:34 -07002237 timeout, false);
Govind Singhedc5cda2015-10-23 17:11:35 +05302238 }
2239
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002240 return qdf_status_to_os_return(status);
2241}
2242
2243/**
2244 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2245 * if key installation is required
2246 * @encr_type: encryption type
2247 *
2248 * Return: true if key installation is required and false otherwise.
2249 */
2250static inline bool hdd_is_key_install_required_for_ibss(
2251 eCsrEncryptionType encr_type)
2252{
2253 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2254 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2255 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
2256 eCSR_ENCRYPT_TYPE_AES == encr_type)
2257 return true;
2258 else
2259 return false;
2260}
2261
2262/**
2263 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2264 * complete
2265 * @adapter: pointer to HDD adapter
2266 * @roaminfo: pointer to roam info
2267 * @roam_result: roam result
2268 *
2269 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2270 * This function checks for the successful set key completion and update
2271 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2272 *
2273 * Return: None
2274 */
2275static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2276 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2277{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002278 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2279 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2280
2281 /*
2282 * If the security mode is one of the following, IBSS peer will be
2283 * waiting in CONN state and we will move the peer state to AUTH
2284 * here. For non-secure connection, no need to wait for set-key complete
2285 * peer will be moved to AUTH in hdd_roam_register_sta.
2286 */
2287 if (QDF_IBSS_MODE == adapter->device_mode) {
2288 if (hdd_is_key_install_required_for_ibss(encr_type))
2289 hdd_change_sta_state_authenticated(adapter, roaminfo);
2290
2291 return;
2292 }
2293
2294 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2295 hdd_sta_ctx->conn_info.gtk_installed = true;
2296 /*
2297 * PTK exchange happens in preauthentication itself if key_mgmt
2298 * is FT-PSK, ptk_installed was false as there is no set PTK
2299 * after roaming. STA TL state moves to authenticated only if
2300 * ptk_installed is true. So, make ptk_installed to true in
2301 * case of 11R roaming.
2302 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302303 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
2304 adapter->sessionId))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002305 hdd_sta_ctx->conn_info.ptk_installed = true;
2306 } else {
2307 hdd_sta_ctx->conn_info.ptk_installed = true;
2308 }
2309
2310 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2311 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2312 * unicast key and it was resulting in sending few un-encrypted packet.
2313 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2314 * set the unicast and broadcast key.
2315 */
2316 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2317 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2318 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2319 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2320 if (hdd_sta_ctx->conn_info.gtk_installed &&
2321 hdd_sta_ctx->conn_info.ptk_installed)
2322 hdd_change_sta_state_authenticated(adapter, roaminfo);
2323 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2324 hdd_change_sta_state_authenticated(adapter, roaminfo);
2325 }
2326
2327 if (hdd_sta_ctx->conn_info.gtk_installed &&
2328 hdd_sta_ctx->conn_info.ptk_installed) {
2329 hdd_sta_ctx->conn_info.gtk_installed = false;
2330 hdd_sta_ctx->conn_info.ptk_installed = false;
2331 }
2332
2333 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2334
2335 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302336}
2337
2338/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 * hdd_roam_set_key_complete_handler() - Update the security parameters
2340 * @pAdapter: pointer to adapter
2341 * @pRoamInfo: pointer to roam info
2342 * @roamId: roam id
2343 * @roamStatus: roam status
2344 * @roamResult: roam result
2345 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302346 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302348static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349 tCsrRoamInfo *pRoamInfo,
2350 uint32_t roamId,
2351 eRoamCmdStatus roamStatus,
2352 eCsrRoamResult roamResult)
2353{
2354 eCsrEncryptionType connectedCipherAlgo;
2355 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302357
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358 ENTER();
2359
2360 if (NULL == pRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002361 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302362 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 }
2364 /*
2365 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2366 * then go to 'authenticated'. For all other authentication types
2367 * (those that do not require upper layer authentication) we can put TL
2368 * directly into 'authenticated' state.
2369 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002370 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 MAC_ADDRESS_STR, roamStatus, roamResult,
2372 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2373
2374 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2375 &connectedCipherAlgo);
2376 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002377 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2378 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379 } else {
2380 /*
2381 * possible disassoc after issuing set key and waiting
2382 * set key complete.
2383 */
2384 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2385 }
2386
2387 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302388 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389}
2390
2391/**
2392 * hdd_perform_roam_set_key_complete() - perform set key complete
2393 * @pAdapter: pointer to adapter
2394 *
2395 * Return: none
2396 */
2397void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2398{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302399 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2401 tCsrRoamInfo roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002402
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302404 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302405 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302406 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302407 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302409 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 hdd_roam_set_key_complete_handler(pAdapter,
2411 &roamInfo,
2412 pHddStaCtx->roam_info.roamId,
2413 pHddStaCtx->roam_info.roamStatus,
2414 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302415 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002416 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417
2418 pHddStaCtx->roam_info.deferKeyComplete = false;
2419}
2420
2421/**
2422 * hdd_association_completion_handler() - association completion handler
2423 * @pAdapter: pointer to adapter
2424 * @pRoamInfo: pointer to roam info
2425 * @roamId: roam id
2426 * @roamStatus: roam status
2427 * @roamResult: roam result
2428 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302429 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302431static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432 tCsrRoamInfo *pRoamInfo,
2433 uint32_t roamId,
2434 eRoamCmdStatus roamStatus,
2435 eCsrRoamResult roamResult)
2436{
2437 struct net_device *dev = pAdapter->dev;
2438 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2439 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302440 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002442 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 bool hddDisconInProgress = false;
2445 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302446 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302447 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448
2449 if (!pHddCtx) {
2450 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302451 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 }
2453
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302454 /* validate config */
2455 if (!pHddCtx->config) {
2456 hdd_err("config is NULL");
2457 return QDF_STATUS_E_NULL_VALUE;
2458 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 /* HDD has initiated disconnect, do not send connect result indication
2460 * to kernel as it will be handled by __cfg80211_disconnect.
2461 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302462 if (((eConnectionState_Disconnecting ==
2463 pHddStaCtx->conn_info.connState) ||
2464 (eConnectionState_NotConnected ==
2465 pHddStaCtx->conn_info.connState)) &&
2466 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2467 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002468 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 hddDisconInProgress = true;
2470 }
2471
2472 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2473 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002474 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302475 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476 }
2477 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 hdd_conn_set_connection_state(pAdapter,
2479 eConnectionState_Associated);
2480 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 /* Save the connection info from CSR... */
2483 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2484 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002485
2486 if (hdd_add_beacon_filter(pAdapter) != 0)
2487 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488#ifdef FEATURE_WLAN_WAPI
2489 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2490 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2491 || pRoamInfo->u.pConnectedProfile->AuthType ==
2492 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2493 pAdapter->wapi_info.fIsWapiSta = 1;
2494 } else {
2495 pAdapter->wapi_info.fIsWapiSta = 0;
2496 }
2497#endif /* FEATURE_WLAN_WAPI */
Krunal Soni364e0872017-05-10 21:24:34 -07002498 hdd_debug("bss_descr[%d] devicemode[%d]", !!pRoamInfo->pBssDesc,
2499 pAdapter->device_mode);
2500 if ((QDF_STA_MODE == pAdapter->device_mode) &&
2501 pRoamInfo->pBssDesc) {
2502 ie_len = GET_IE_LEN_IN_BSS(pRoamInfo->pBssDesc->length);
2503 pHddStaCtx->ap_supports_immediate_power_save =
2504 wlan_hdd_is_ap_supports_immediate_power_save(
2505 (uint8_t *) pRoamInfo->pBssDesc->ieFields,
2506 ie_len);
2507 hdd_debug("ap_supports_immediate_power_save flag [%d]",
2508 pHddStaCtx->ap_supports_immediate_power_save);
2509 }
2510
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 /* Indicate 'connect' status to user space */
2512 hdd_send_association_event(dev, pRoamInfo);
2513
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002514 if (policy_mgr_is_mcc_in_24G(pHddCtx->hdd_psoc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 if (pHddCtx->miracast_value)
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002516 wlan_hdd_set_mas(pAdapter,
2517 pHddCtx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518 }
2519
2520 /* Initialize the Linkup event completion variable */
2521 INIT_COMPLETION(pAdapter->linkup_event_var);
2522
2523 /*
2524 * Sometimes Switching ON the Carrier is taking time to activate
2525 * the device properly. Before allowing any packet to go up to
2526 * the application, device activation has to be ensured for
2527 * proper queue mapping by the kernel. we have registered net
2528 * device notifier for device change notification. With this we
2529 * will come to know that the device is getting
2530 * activated properly.
2531 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002533 /*
2534 * Enable Linkup Event Servicing which allows the net
2535 * device notifier to set the linkup event variable.
2536 */
2537 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002539 /* Switch on the Carrier to activate the device */
2540 wlan_hdd_netif_queue_control(pAdapter,
2541 WLAN_NETIF_CARRIER_ON,
2542 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002544 /*
2545 * Wait for the Link to up to ensure all the queues
2546 * are set properly by the kernel.
2547 */
2548 rc = wait_for_completion_timeout(
2549 &pAdapter->linkup_event_var,
2550 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2551 );
2552 if (!rc)
2553 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002555 /*
2556 * Disable Linkup Event Servicing - no more service
2557 * required from the net device notifier call.
2558 */
2559 pAdapter->isLinkUpSvcNeeded = false;
2560 } else {
2561 pHddStaCtx->ft_carrier_on = false;
2562 ft_carrier_on = true;
2563 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2565 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2566 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002567 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568
2569 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2570
2571 if (hdd_ipa_is_enabled(pHddCtx))
2572 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002573 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 pRoamInfo->bssid.bytes);
2575
2576#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2577 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2578#endif
2579
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302580 hdd_debug("check if STA chan ok for DNBS");
2581 if (policy_mgr_is_chan_ok_for_dnbs(pHddCtx->hdd_psoc,
2582 pHddStaCtx->conn_info.operationChannel,
2583 &ok)) {
2584 hdd_err("Unable to check DNBS eligibility for chan:%d",
2585 pHddStaCtx->conn_info.operationChannel);
2586 return QDF_STATUS_E_FAILURE;
2587 }
2588
2589 if (!ok) {
2590 hdd_err("Chan:%d not suitable for DNBS",
2591 pHddStaCtx->conn_info.operationChannel);
2592 wlan_hdd_netif_queue_control(pAdapter,
2593 WLAN_NETIF_CARRIER_OFF,
2594 WLAN_CONTROL_PATH);
2595 if (!hddDisconInProgress) {
2596 hdd_err("Disconnecting...");
2597 sme_roam_disconnect(
2598 WLAN_HDD_GET_HAL_CTX(pAdapter),
2599 pAdapter->sessionId,
2600 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2601 }
2602 return QDF_STATUS_E_FAILURE;
2603 }
2604
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002605 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002606 policy_mgr_check_concurrent_intf_and_restart_sap(
2607 pHddCtx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608
Nirav Shah1da77682016-05-03 20:16:39 +05302609 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2610 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002611 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302612 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2613
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 /*
2615 * For reassoc, the station is already registered, all we need
2616 * is to change the state of the STA in TL.
2617 * If authentication is required (WPA/WPA2/DWEP), change TL to
2618 * CONNECTED instead of AUTHENTICATED.
2619 */
2620 if (!pRoamInfo->fReassocReq) {
2621 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 u8 *pFTAssocRsp = NULL;
2623 unsigned int assocRsplen = 0;
2624 u8 *pFTAssocReq = NULL;
2625 unsigned int assocReqlen = 0;
2626 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2628 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2629
2630 /* add bss_id to cfg80211 data base */
2631 bss =
2632 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2633 pRoamInfo);
2634 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302635 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 wlan_hdd_netif_queue_control(pAdapter,
2637 WLAN_NETIF_CARRIER_OFF,
2638 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302639 if (!hddDisconInProgress) {
2640 /*
2641 * Here driver was not able to add bss
2642 * in cfg80211 database this can happen
2643 * if connected channel is not valid,
2644 * i.e reg domain was changed during
2645 * connection. Queue disconnect for the
2646 * session if disconnect is not in
2647 * progress.
2648 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002649 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302650 sme_roam_disconnect(
2651 WLAN_HDD_GET_HAL_CTX(pAdapter),
2652 pAdapter->sessionId,
2653 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2654 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302655 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2658 eCSR_AUTH_TYPE_FT_RSN
2659 || pRoamInfo->u.pConnectedProfile->AuthType ==
2660 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2661
2662 /* Association Response */
2663 pFTAssocRsp =
2664 (u8 *) (pRoamInfo->pbFrames +
2665 pRoamInfo->nBeaconLength +
2666 pRoamInfo->nAssocReqLength);
2667 if (pFTAssocRsp != NULL) {
2668 /*
2669 * pFTAssocRsp needs to point to the IEs
2670 */
2671 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002672 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002673 (unsigned int)pFTAssocRsp[0],
2674 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 assocRsplen =
2676 pRoamInfo->nAssocRspLength -
2677 FT_ASSOC_RSP_IES_OFFSET;
2678 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002679 hdd_debug("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 assocRsplen = 0;
2681 }
2682
2683 /* Association Request */
2684 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2685 pRoamInfo->nBeaconLength);
2686 if (pFTAssocReq != NULL) {
2687 if (!ft_carrier_on) {
2688 /*
2689 * pFTAssocReq needs to point to
2690 * the IEs
2691 */
2692 pFTAssocReq +=
2693 FT_ASSOC_REQ_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002694 hdd_debug("pFTAssocReq is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002695 (unsigned int)
2696 pFTAssocReq[0],
2697 (unsigned int)
2698 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 assocReqlen =
2700 pRoamInfo->nAssocReqLength -
2701 FT_ASSOC_REQ_IES_OFFSET;
2702 } else {
2703 /*
2704 * This should contain only the
2705 * FTIEs
2706 */
2707 assocReqlen =
2708 pRoamInfo->nAssocReqLength;
2709 }
2710 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002711 hdd_debug("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 assocReqlen = 0;
2713 }
2714
2715 if (ft_carrier_on) {
2716 if (!hddDisconInProgress) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302717 struct cfg80211_bss *roam_bss;
2718
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 /*
2720 * After roaming is completed,
2721 * active session count is
2722 * incremented as a part of
2723 * connect indication but
2724 * effectively the active
2725 * session count should still
2726 * be the same and hence upon
2727 * successful reassoc
2728 * decrement the active session
2729 * count here.
2730 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002731 if (!hdd_is_roam_sync_in_progress
2732 (pRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002733 policy_mgr_decr_session_set_pcl(
2734 pHddCtx->hdd_psoc,
2735 pAdapter->device_mode,
2736 pAdapter->sessionId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002737 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002738 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 chan =
2740 ieee80211_get_channel
2741 (pAdapter->wdev.wiphy,
2742 (int)pRoamInfo->pBssDesc->
2743 channelId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002744 hdd_debug(
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002745 "assocReqlen %d assocRsplen %d",
2746 assocReqlen,
2747 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002748
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002749 hdd_debug(
Naveen Rawat14298b92015-11-25 16:27:41 -08002750 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302751 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302752 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302753 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002754 pFTAssocReq,
2755 assocReqlen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302756 roam_bss =
2757 hdd_cfg80211_get_bss(
2758 pAdapter->wdev.wiphy,
2759 chan,
2760 pRoamInfo->bssid.bytes,
2761 pRoamInfo->u.
2762 pConnectedProfile->SSID.ssId,
2763 pRoamInfo->u.
2764 pConnectedProfile->SSID.length);
2765 cfg80211_roamed_bss(dev,
2766 roam_bss,
2767 pFTAssocReq,
2768 assocReqlen,
2769 pFTAssocRsp,
2770 assocRsplen,
2771 GFP_KERNEL);
2772 wlan_hdd_send_roam_auth_event(
2773 pAdapter,
2774 pRoamInfo->bssid.bytes,
2775 pFTAssocReq,
2776 assocReqlen,
2777 pFTAssocRsp,
2778 assocRsplen,
2779 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 }
2781 if (sme_get_ftptk_state
2782 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2783 pAdapter->sessionId)) {
2784 sme_set_ftptk_state
2785 (WLAN_HDD_GET_HAL_CTX
2786 (pAdapter),
2787 pAdapter->sessionId,
2788 false);
2789 pRoamInfo->fAuthRequired =
2790 false;
2791
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302792 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 roam_info.bssid,
2794 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302795 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302796 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 roam_info.peerMac,
2798 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302799 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 pHddStaCtx->roam_info.roamId =
2801 roamId;
2802 pHddStaCtx->roam_info.
2803 roamStatus = roamStatus;
2804 pHddStaCtx->roam_info.
2805 deferKeyComplete = true;
2806 }
2807 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002808 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002809 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302810 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302811 pRoamInfo->
2812 bssid.bytes,
2813 pRoamInfo,
2814 pFTAssocReq,
2815 assocReqlen,
2816 pFTAssocRsp,
2817 assocRsplen,
2818 WLAN_STATUS_SUCCESS,
2819 GFP_KERNEL,
2820 false,
2821 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002823 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 /*
2825 * wpa supplicant expecting WPA/RSN IE in
2826 * connect result.
2827 */
2828 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2829 (pAdapter),
2830 pAdapter->sessionId,
2831 &reqRsnLength,
2832 reqRsnIe);
2833
2834 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2835 (pAdapter),
2836 pAdapter->sessionId,
2837 &rspRsnLength,
2838 rspRsnIe);
2839 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 if (ft_carrier_on)
2841 hdd_send_re_assoc_event(dev,
2842 pAdapter,
2843 pRoamInfo,
2844 reqRsnIe,
2845 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002846 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002847 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002848 MAC_ADDRESS_STR
2849 " result:%d and Status:%d",
2850 MAC_ADDR_ARRAY
2851 (pRoamInfo->bssid.bytes),
2852 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853
2854 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302855 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302856 pRoamInfo->
2857 bssid.bytes,
2858 pRoamInfo,
2859 reqRsnIe,
2860 reqRsnLength,
2861 rspRsnIe,
2862 rspRsnLength,
2863 WLAN_STATUS_SUCCESS,
2864 GFP_KERNEL,
2865 false,
2866 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 }
2868 }
2869 }
2870 if (!hddDisconInProgress) {
2871 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 bss);
2874
2875 /*
2876 * Perform any WMM-related association
2877 * processing.
2878 */
2879 hdd_wmm_assoc(pAdapter, pRoamInfo,
2880 eCSR_BSS_TYPE_INFRASTRUCTURE);
2881
2882 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002883 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002885 qdf_status = hdd_roam_register_sta(pAdapter,
2886 pRoamInfo,
2887 pHddStaCtx->conn_info.staId[0],
2888 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002889 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 wlan_hdd_netif_queue_control(pAdapter,
2891 WLAN_WAKE_ALL_NETIF_QUEUE,
2892 WLAN_CONTROL_PATH);
2893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 }
2895 } else {
2896 /*
2897 * wpa supplicant expecting WPA/RSN IE in connect result
2898 * in case of reassociation also need to indicate it to
2899 * supplicant.
2900 */
2901 csr_roam_get_wpa_rsn_req_ie(
2902 WLAN_HDD_GET_HAL_CTX(pAdapter),
2903 pAdapter->sessionId,
2904 &reqRsnLength, reqRsnIe);
2905
2906 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2907 reqRsnIe, reqRsnLength);
2908 /* Reassoc successfully */
2909 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302910 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 hdd_change_peer_state(pAdapter,
2912 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002913 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2915 pRoamInfo->roamSynchInProgress
2916#else
2917 false
2918#endif
2919 );
2920 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002921 hdd_objmgr_set_peer_mlme_auth_state(
2922 pAdapter->hdd_vdev,
2923 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002925 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002926 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302927 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 hdd_change_peer_state(pAdapter,
2929 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002930 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2932 pRoamInfo->roamSynchInProgress
2933#else
2934 false
2935#endif
2936 );
2937 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002938 hdd_objmgr_set_peer_mlme_auth_state(
2939 pAdapter->hdd_vdev,
2940 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 }
2942
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302943 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002944 /*
2945 * Perform any WMM-related association
2946 * processing
2947 */
2948 hdd_wmm_assoc(pAdapter, pRoamInfo,
2949 eCSR_BSS_TYPE_INFRASTRUCTURE);
2950 }
2951
2952 /* Start the tx queues */
2953#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2954 if (pRoamInfo->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002955 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002957 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 wlan_hdd_netif_queue_control(pAdapter,
2959 WLAN_WAKE_ALL_NETIF_QUEUE,
2960 WLAN_CONTROL_PATH);
2961 }
2962
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302963#ifdef FEATURE_WLAN_TDLS
2964 wlan_hdd_tdls_connection_callback(pAdapter);
2965#endif
2966
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302967 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002968 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302969 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 }
2971#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302972 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 sizeof(pAdapter->hdd_stats.hddPmfStats));
2974#endif
2975 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302976 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 hdd_wext_state_t *pWextState =
2978 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2979 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302980 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002981 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302982 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2983 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002984 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302985 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002986 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302987 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2988 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302989
2990 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2991 (pRoamInfo &&
2992 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2993 pRoamInfo->statusCode) ||
2994 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2995 pRoamInfo->statusCode) ||
2996 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2997 pRoamInfo->statusCode)))) {
2998 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2999 pRoamInfo ?
3000 pRoamInfo->bssid.bytes :
3001 pWextState->req_bssId.bytes);
3002 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
3003 pRoamInfo ?
3004 pRoamInfo->bssid.bytes :
3005 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303006 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303007 }
3008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009 /*
3010 * CR465478: Only send up a connection failure result when CSR
3011 * has completed operation - with a ASSOCIATION_FAILURE status.
3012 */
3013 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3014 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303015 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003016 hdd_err("send connect failure to nl80211: for bssid "
3017 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003018 " result: %d and Status: %d reasoncode: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003019 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3020 roamResult, roamStatus,
3021 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303022 pHddStaCtx->conn_info.assoc_status_code =
3023 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003024 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003025 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003027 " result: %d and status: %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3029 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003030 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003031 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303032 wlan_deregister_txrx_packetdump();
3033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 /* inform association failure event to nl80211 */
3035 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3036 roamResult) {
3037 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303038 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303040 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303042 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303043 connect_timeout,
3044 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303046 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303048 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303050 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303051 connect_timeout,
3052 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 } else {
Wu Gao77d28352016-11-23 17:50:56 +08003054 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303055 hdd_connect_result(dev,
3056 pRoamInfo->bssid.bytes,
3057 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08003058 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05303059 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303061 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303062 connect_timeout,
3063 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003064 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303065 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303067 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303069 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303070 connect_timeout,
3071 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 }
Abhishek Singhac2be142015-12-03 16:16:25 +05303073 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003074 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3075 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05303076 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003077 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05303078 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003079 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303080 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303081 connect_timeout,
3082 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 }
3084
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 /*
3086 * Set connection state to eConnectionState_NotConnected only
3087 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003088 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003090 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3091 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 hdd_conn_set_connection_state(pAdapter,
3094 eConnectionState_NotConnected);
3095 }
3096 hdd_wmm_init(pAdapter);
3097
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003098 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303100 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 WLAN_CONTROL_PATH);
3102 }
3103
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303104 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105}
3106
3107/**
3108 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
3109 * @pAdapter: pointer to adapter
3110 * @pRoamInfo: pointer to roam info
3111 * @roamId: roam id
3112 * @roamStatus: roam status
3113 * @roamResult: roam result
3114 *
3115 * Here we update the status of the Ibss when we receive information that we
3116 * have started/joined an ibss session.
3117 *
3118 * Return: none
3119 */
3120static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3121 tCsrRoamInfo *pRoamInfo,
3122 uint32_t roamId,
3123 eRoamCmdStatus roamStatus,
3124 eCsrRoamResult roamResult)
3125{
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003126 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3127
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003128 hdd_debug("%s: id %d, status %d, result %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003129 pAdapter->dev->name, roamId,
3130 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131
3132 switch (roamResult) {
3133 /* both IBSS Started and IBSS Join should come in here. */
3134 case eCSR_ROAM_RESULT_IBSS_STARTED:
3135 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3136 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3137 {
3138 hdd_context_t *pHddCtx =
3139 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303140 hdd_station_ctx_t *hdd_sta_ctx =
3141 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303142 struct qdf_mac_addr broadcastMacAddr =
3143 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144
3145 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303146 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 return;
3148 }
3149
3150 /* When IBSS Started comes from CSR, we need to move
3151 * connection state to IBSS Disconnected (meaning no peers
3152 * are in the IBSS).
3153 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 hdd_conn_set_connection_state(pAdapter,
3155 eConnectionState_IbssDisconnected);
3156 /* notify wmm */
3157 hdd_wmm_connect(pAdapter, pRoamInfo,
3158 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303159
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003160 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303161
3162 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 pAdapter;
3164 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303165 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 &broadcastMacAddr,
3167 pRoamInfo->pBssDesc);
3168
3169 if (pRoamInfo->pBssDesc) {
3170 struct cfg80211_bss *bss;
3171#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3172 struct ieee80211_channel *chan;
3173 int chan_no;
3174 unsigned int freq;
3175#endif
3176 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003177 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3178 pAdapter->dev->name,
3179 MAC_ADDR_ARRAY(
3180 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181
3182 /* we must first give cfg80211 the BSS information */
3183 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3184 pRoamInfo);
3185 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003186 hdd_err("%s: unable to create IBSS entry",
3187 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 return;
3189 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003190 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 wlan_hdd_netif_queue_control(pAdapter,
3192 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3193 WLAN_CONTROL_PATH);
3194
3195#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3196 chan_no = pRoamInfo->pBssDesc->channelId;
3197
3198 if (chan_no <= 14)
3199 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003200 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 else
3202 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003203 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204
3205 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3206
3207 if (chan)
3208 cfg80211_ibss_joined(pAdapter->dev,
3209 bss->bssid, chan,
3210 GFP_KERNEL);
3211 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003212 hdd_warn("%s: chanId: %d, can't find channel",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003213 pAdapter->dev->name,
3214 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215#else
3216 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3217 GFP_KERNEL);
3218#endif
3219 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 bss);
3222 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003223 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003224 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
3225 pAdapter->device_mode, pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003226 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3227 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003228 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
3229 pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003230 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 break;
3232 }
3233
3234 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3235 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003236 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 break;
3238 }
3239
3240 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003241 hdd_err("%s: unexpected result %d",
3242 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 break;
3244 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245}
3246
3247/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003248 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3249 * @sta_ctx: pointer to hdd station context
3250 * @sta_id: station ID
3251 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 *
3253 * This information is passed to iwconfig later. The peer that joined
3254 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003255
3256 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003258bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3259 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003261 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003263 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3264 if (0 == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003265 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003266 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003267 sta_ctx->conn_info.staId[idx] = sta_id;
3268 qdf_copy_macaddr(
3269 &sta_ctx->conn_info.peerMacAddress[idx],
3270 peer_mac_addr);
3271 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 }
3273 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003274 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275}
3276
3277/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003278 * hdd_delete_peer() - removes peer from hdd station context peer table
3279 * @sta_ctx: pointer to hdd station context
3280 * @sta_id: station ID
3281 *
3282 * Return: None
3283 */
3284void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3285{
3286 int i;
3287
3288 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3289 if (sta_id == sta_ctx->conn_info.staId[i]) {
3290 sta_ctx->conn_info.staId[i] = 0;
3291 return;
3292 }
3293 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003294}
3295
3296/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3298 * @pAdapter: pointer to adapter
3299 * @staId: station id
3300 *
3301 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003302 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 * false otherwise.
3304 */
3305static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3306{
3307 bool fSuccess = false;
3308 int idx = 0;
3309 uint8_t valid_idx = 0;
3310 uint8_t del_idx = 0;
3311 uint8_t empty_slots = 0;
3312 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3313
Naveen Rawatc45d1622016-07-05 12:20:09 -07003314 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3316 pHddStaCtx->conn_info.staId[idx] = 0;
3317
Anurag Chouhanc5548422016-02-24 18:33:27 +05303318 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 peerMacAddress[idx]);
3320
3321 fSuccess = true;
3322
3323 /*
3324 * Note the deleted Index, if its 0 we need special
3325 * handling.
3326 */
3327 del_idx = idx;
3328
3329 empty_slots++;
3330 } else {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003331 if (pHddStaCtx->conn_info.staId[idx] !=
3332 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 valid_idx = idx;
3334 } else {
3335 /* Found an empty slot */
3336 empty_slots++;
3337 }
3338 }
3339 }
3340
Naveen Rawatc45d1622016-07-05 12:20:09 -07003341 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 /* Last peer departed, set the IBSS state appropriately */
3343 pHddStaCtx->conn_info.connState =
3344 eConnectionState_IbssDisconnected;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003345 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 }
3347 /* Find next active staId, to have a valid sta trigger for TL. */
3348 if (fSuccess == true) {
3349 if (del_idx == 0) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003350 if (pHddStaCtx->conn_info.staId[valid_idx] !=
3351 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 pHddStaCtx->conn_info.staId[0] =
3353 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303354 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355 peerMacAddress[0],
3356 &pHddStaCtx->conn_info.
3357 peerMacAddress[valid_idx]);
3358
3359 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303360 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 peerMacAddress[valid_idx]);
3362 }
3363 }
3364 }
3365 return fSuccess;
3366}
3367
3368/**
3369 * roam_ibss_connect_handler() - IBSS connection handler
3370 * @pAdapter: pointer to adapter
3371 * @pRoamInfo: pointer to roam info
3372 *
3373 * We update the status of the IBSS to connected in this function.
3374 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303375 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303377static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 tCsrRoamInfo *pRoamInfo)
3379{
3380 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 /*
3382 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3383 * a partner stations).
3384 */
3385 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3386
3387 /* Save the connection info from CSR... */
3388 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3389
3390 /* Send the bssid address to the wext. */
3391 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3392 /* add bss_id to cfg80211 data base */
3393 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3394 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003395 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303397 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 }
3399 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401 bss);
3402
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303403 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404}
3405
3406/**
3407 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3408 * @pAdapter: pointer to adapter
3409 * @pRoamInfo: pointer to roam info
3410 * @roamId: roam id
3411 * @roamStatus: roam status
3412 * @roamResult: roam result
3413 *
3414 * This function indicates the Mic failure to the supplicant
3415 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303416 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303418static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3420 tCsrRoamInfo *pRoamInfo,
3421 uint32_t roamId,
3422 eRoamCmdStatus roamStatus,
3423 eCsrRoamResult roamResult)
3424{
3425 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3426
3427 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3428 TKIP_COUNTER_MEASURE_STOPED ==
3429 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3430 struct iw_michaelmicfailure msg;
3431 union iwreq_data wreq;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003432
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 memset(&msg, '\0', sizeof(msg));
3434 msg.src_addr.sa_family = ARPHRD_ETHER;
3435 memcpy(msg.src_addr.sa_data,
3436 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3437 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003438 hdd_debug("MIC MAC " MAC_ADDRESS_STR,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003439 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440
3441 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3442 msg.flags = IW_MICFAILURE_GROUP;
3443 else
3444 msg.flags = IW_MICFAILURE_PAIRWISE;
3445 memset(&wreq, 0, sizeof(wreq));
3446 wreq.data.length = sizeof(msg);
3447 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3448 (char *)&msg);
3449 /* inform mic failure to nl80211 */
3450 cfg80211_michael_mic_failure(pAdapter->dev,
3451 pRoamInfo->u.pMICFailureInfo->
3452 taMacAddr,
3453 ((pRoamInfo->u.pMICFailureInfo->
3454 multicast ==
3455 eSIR_TRUE) ?
3456 NL80211_KEYTYPE_GROUP :
3457 NL80211_KEYTYPE_PAIRWISE),
3458 pRoamInfo->u.pMICFailureInfo->
3459 keyId,
3460 pRoamInfo->u.pMICFailureInfo->TSC,
3461 GFP_KERNEL);
3462
3463 }
3464
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303465 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466}
3467
3468/**
3469 * roam_roam_connect_status_update_handler() - IBSS connect status update
3470 * @pAdapter: pointer to adapter
3471 * @pRoamInfo: pointer to roam info
3472 * @roamId: roam id
3473 * @roamStatus: roam status
3474 * @roamResult: roam result
3475 *
3476 * The Ibss connection status is updated regularly here in this function.
3477 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303478 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303480static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3482 tCsrRoamInfo *pRoamInfo,
3483 uint32_t roamId,
3484 eRoamCmdStatus roamStatus,
3485 eCsrRoamResult roamResult)
3486{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003488 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303489
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 switch (roamResult) {
3491 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3492 {
3493 hdd_station_ctx_t *pHddStaCtx =
3494 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003495 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003496 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003498 hdd_info("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303499 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3500 MAC_ADDRESS_STR " and stationID= %d",
3501 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3502 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3503 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003505 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3507 pRoamInfo->staId,
3508 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003509 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 break;
3511 }
3512
3513 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3514
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003515 if (hdd_is_key_install_required_for_ibss(encr_type))
3516 pRoamInfo->fAuthRequired = true;
3517
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303519 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 pRoamInfo,
3521 pRoamInfo->staId,
3522 &pRoamInfo->peerMac,
3523 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303524 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003525 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303526 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 }
3528 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003529 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3530 if (stainfo == NULL) {
3531 hdd_err("memory allocation for station_info failed");
3532 return QDF_STATUS_E_NOMEM;
3533 }
3534 stainfo->filled = 0;
3535 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536
3537 cfg80211_new_sta(pAdapter->dev,
3538 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003539 stainfo, GFP_KERNEL);
3540 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003542 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 pHddStaCtx->ibss_enc_key.keyDirection =
3544 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303545 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 &pRoamInfo->peerMac);
3547
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003548 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003549 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303551 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3553 (pAdapter),
3554 pAdapter->sessionId,
3555 &pHddStaCtx->ibss_enc_key,
3556 &roamId);
3557
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303558 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003559 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003560 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303561 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 }
3563 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003564 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 wlan_hdd_netif_queue_control(pAdapter,
3566 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3567 WLAN_CONTROL_PATH);
3568 break;
3569 }
3570
3571 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3572 {
3573
3574 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3575
3576 break;
3577 }
3578 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3579 {
3580 hdd_station_ctx_t *pHddStaCtx =
3581 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3582
3583 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003584 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003586 hdd_info("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303587 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3588 MAC_ADDRESS_STR " and stationID= %d",
3589 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3590 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3591 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592
3593 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3594
3595 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3596 pHddStaCtx->ibss_sta_generation++;
3597
3598 cfg80211_del_sta(pAdapter->dev,
3599 (const u8 *)&pRoamInfo->peerMac.bytes,
3600 GFP_KERNEL);
3601 break;
3602 }
3603 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3604 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003605 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003607 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303609 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 hdd_conn_set_connection_state(pAdapter,
3612 eConnectionState_NotConnected);
3613
3614 /* Send the bssid address to the wext. */
3615 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3616 break;
3617 }
3618 default:
3619 break;
3620
3621 }
3622
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303623 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624}
3625
3626#ifdef FEATURE_WLAN_TDLS
3627/**
3628 * hdd_roam_register_tdlssta() - register new TDLS station
3629 * @pAdapter: pointer to adapter
3630 * @peerMac: pointer to peer MAC address
3631 * @staId: station identifier
3632 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303633 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 *
3635 * Construct the staDesc and register with TL the new STA.
3636 * This is called as part of ADD_STA in the TDLS setup.
3637 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303638 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303642 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303644 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003646 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003647 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3648 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649
3650 /*
3651 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3652 * be peer MAC, here we are working on direct Link
3653 */
3654 staDesc.sta_id = staId;
3655
3656 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303657 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658
Dhanashri Atre50141c52016-04-07 13:15:29 -07003659 /* Register the vdev transmit and receive functions */
3660 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3661 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003662 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003663 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3664 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003665 pAdapter, &txrx_ops);
3666 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667
3668 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003669 qdf_status = cdp_peer_register(soc,
3670 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303671 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003672 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303673 qdf_status, qdf_status);
3674 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 }
3676
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303677 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678}
3679
3680/**
3681 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3682 * @pAdapter: pointer to adapter
3683 * @staId: station identifier
3684 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303685 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686 */
Nitesh Shah99dd9552017-03-20 19:27:47 +05303687QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303689 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003690 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003691 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3692 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303693 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003694 hdd_err("cdp_clear_peer() failed for staID: %d Status: %d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003695 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303697 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698}
3699
3700/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003701 * hdd_tdls_connection_tracker_update() - update connection tracker state
3702 * @adapter: pointer to adapter
3703 * @roam_info: pointer to roam info
3704 * @hdd_tdls_ctx: tdls context
3705 *
3706 * Return: QDF_STATUS enumeration
3707 */
3708static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3709 tCsrRoamInfo *roam_info,
3710 tdlsCtx_t *hdd_tdls_ctx)
3711{
3712 hddTdlsPeer_t *curr_peer;
3713 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3714
3715 curr_peer = wlan_hdd_tdls_find_peer(adapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303716 roam_info->peerMac.bytes);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003717
3718 if (!curr_peer) {
3719 hdd_err("curr_peer is null");
3720 return QDF_STATUS_E_FAILURE;
3721 }
3722
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003723 if (eTDLS_LINK_CONNECTED ==
3724 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003725 hdd_debug("Received CONNECTION_TRACKER_NOTIFICATION "
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003726 MAC_ADDRESS_STR
3727 " staId: %d, reason: %d",
3728 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3729 roam_info->staId,
3730 roam_info->reasonCode);
3731
3732 if (roam_info->reasonCode ==
3733 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3734 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003735 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3736 roam_info->reasonCode ==
3737 eWMI_TDLS_SCAN_STARTED_EVENT)
3738 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003739 else if (roam_info->reasonCode ==
3740 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3741 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003742 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3743 roam_info->reasonCode ==
3744 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3745 hdd_ctx->enable_tdls_connection_tracker = true;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003746 hdd_debug("hdd_ctx->enable_tdls_connection_tracker %d",
Nitesh Shahc549dd52017-02-23 16:45:44 +05303747 hdd_ctx->enable_tdls_connection_tracker);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003748 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003749 hdd_debug("TDLS not connected, ignore notification, reason: %d",
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003750 roam_info->reasonCode);
3751 }
3752
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003753 return QDF_STATUS_SUCCESS;
3754}
3755
3756
3757
3758
3759/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003760 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3761 * @pAdapter: pointer to adapter
3762 * @pRoamInfo: pointer to roam info
3763 * @roamId: roam id
3764 * @roamStatus: roam status
3765 * @roamResult: roam result
3766 *
3767 * HDD interface between SME and TL to ensure TDLS client registration with
3768 * TL in case of new TDLS client is added and deregistration at the time
3769 * TDLS client is deleted.
3770 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303771 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303773static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3775 tCsrRoamInfo *pRoamInfo,
3776 uint32_t roamId,
3777 eRoamCmdStatus roamStatus,
3778 eCsrRoamResult roamResult)
3779{
3780 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303781 tdlsCtx_t *pHddTdlsCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303783 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 uint8_t staIdx;
3785 hddTdlsPeer_t *curr_peer;
3786 uint32_t reason;
3787
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003788 hdd_debug("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 roamResult ==
3790 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3791 ==
3792 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3793 roamResult ==
3794 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3795 : roamResult ==
3796 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3797 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3798 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3799 roamResult ==
3800 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3801 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3802 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3803 : roamResult ==
3804 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3805 : roamResult ==
3806 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3807 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3808 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3809
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 switch (roamResult) {
3811 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3812 {
3813 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003814 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303816 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 } else {
3818 /*
3819 * Check if there is available index for this new TDLS
3820 * STA.
3821 */
3822 for (staIdx = 0;
3823 staIdx < pHddCtx->max_num_tdls_sta;
3824 staIdx++) {
3825 if (0 ==
3826 pHddCtx->tdlsConnInfo[staIdx].
3827 staId) {
3828 pHddCtx->tdlsConnInfo[staIdx].
3829 sessionId =
3830 pRoamInfo->sessionId;
3831 pHddCtx->tdlsConnInfo[staIdx].
3832 staId = pRoamInfo->staId;
3833
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003834 hdd_debug("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003836 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837 staIdx,
3838 pHddCtx->
3839 tdlsConnInfo[staIdx].
3840 staId,
3841 MAC_ADDR_ARRAY
3842 (pRoamInfo->peerMac.bytes));
3843
Anurag Chouhanc5548422016-02-24 18:33:27 +05303844 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845 tdlsConnInfo
3846 [staIdx].
3847 peerMac,
3848 &pRoamInfo->
3849 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303850 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 break;
3852 }
3853 }
3854 if (staIdx < pHddCtx->max_num_tdls_sta) {
3855 if (-1 ==
3856 wlan_hdd_tdls_set_sta_id(pAdapter,
3857 pRoamInfo->
3858 peerMac.bytes,
3859 pRoamInfo->
3860 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003861 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303862 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 }
3864
3865 (WLAN_HDD_GET_CTX(pAdapter))->
3866 sta_to_adapter[pRoamInfo->staId] =
3867 pAdapter;
3868 /*
3869 * store the ucast signature,
3870 * if required for further reference.
3871 */
3872
3873 wlan_hdd_tdls_set_signature(pAdapter,
3874 pRoamInfo->
3875 peerMac.bytes,
3876 pRoamInfo->
3877 ucastSig);
3878 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303879 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003880 hdd_debug("no available slot in conn_info. staId: %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 pRoamInfo->staId);
3882 }
3883 pAdapter->tdlsAddStaStatus = status;
3884 }
3885 complete(&pAdapter->tdls_add_station_comp);
3886 break;
3887 }
3888 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3889 {
3890 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003891 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 pRoamInfo->statusCode);
3893 }
3894 /* store the ucast signature which will be used later when
3895 * registering to TL
3896 */
3897 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3898 complete(&pAdapter->tdls_add_station_comp);
3899 break;
3900 }
3901 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3902 {
3903 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003904 hdd_err("Link Establish Request failed. status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905 pRoamInfo->statusCode);
3906 }
3907 complete(&pAdapter->tdls_link_establish_req_comp);
3908 break;
3909 }
3910 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3911 {
3912 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3913 staIdx++) {
3914 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3915 pRoamInfo->sessionId)
3916 && pRoamInfo->staId ==
3917 pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003918 hdd_debug("HDD: del STA IDX = %x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003919 pRoamInfo->staId);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303920 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921 curr_peer =
3922 wlan_hdd_tdls_find_peer(pAdapter,
3923 pRoamInfo->
Nitesh Shah90a02e92017-02-01 15:28:03 +05303924 peerMac.bytes);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303925 if (NULL != curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003926 hdd_debug("Current status for peer " MAC_ADDRESS_STR " is %d",
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303927 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3928 curr_peer->link_status);
3929 if (TDLS_IS_CONNECTED(curr_peer)) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303930 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 hdd_roam_deregister_tdlssta
3932 (pAdapter,
3933 pRoamInfo->staId);
3934 wlan_hdd_tdls_decrement_peer_count
3935 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303936 } else if (eTDLS_LINK_CONNECTING ==
3937 curr_peer->link_status) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303938 mutex_unlock(&pHddCtx->tdls_lock);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303939 hdd_roam_deregister_tdlssta
3940 (pAdapter,
3941 pRoamInfo->staId);
Nitesh Shah0bf768f2017-03-31 15:01:37 +05303942 } else
3943 mutex_unlock(&pHddCtx->tdls_lock);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303944 } else
3945 mutex_unlock(&pHddCtx->tdls_lock);
3946
Nitesh Shah99dd9552017-03-20 19:27:47 +05303947 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 wlan_hdd_tdls_reset_peer(pAdapter,
3949 pRoamInfo->
3950 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05303951 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952
3953 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3954 pHddCtx->tdlsConnInfo[staIdx].
3955 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303956 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957 tdlsConnInfo[staIdx].
3958 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303959 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303960 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961 break;
3962 }
3963 }
3964 complete(&pAdapter->tdls_del_station_comp);
3965 }
3966 break;
3967 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3968 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003969 hdd_debug("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003970 pRoamInfo->reasonCode);
3971
Nitesh Shahf1f38992017-01-31 16:40:16 +05303972 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003973 curr_peer =
3974 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303975 pRoamInfo->peerMac.bytes);
Ganesh Kondabattini9c8dc462017-04-19 10:52:54 +05303976
3977 if (!curr_peer) {
3978 mutex_unlock(&pHddCtx->tdls_lock);
3979 hdd_debug("peer doesn't exists");
3980 status = QDF_STATUS_SUCCESS;
3981 break;
3982 }
3983
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05303985 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303986 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3987 curr_peer->peerMac);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303988 mutex_unlock(&pHddCtx->tdls_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303989 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 break;
3991 }
3992 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3993 {
3994 /* 0 staIdx is assigned to AP we dont want to touch that */
3995 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3996 staIdx++) {
3997 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3998 pRoamInfo->sessionId)
3999 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004000 hdd_debug("hdd_tdlsStatusUpdate: staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004001 MAC_ADDRESS_STR,
4002 pHddCtx->tdlsConnInfo[staIdx].
4003 staId,
4004 MAC_ADDR_ARRAY(pHddCtx->
4005 tdlsConnInfo
4006 [staIdx].
4007 peerMac.
4008 bytes));
Nitesh Shah99dd9552017-03-20 19:27:47 +05304009 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 wlan_hdd_tdls_reset_peer(pAdapter,
4011 pHddCtx->
4012 tdlsConnInfo
4013 [staIdx].
4014 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304015 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016 hdd_roam_deregister_tdlssta(pAdapter,
4017 pHddCtx->
4018 tdlsConnInfo
4019 [staIdx].
4020 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304021 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 sizeof
4023 (smeTdlsPeerStateParams));
4024 smeTdlsPeerStateParams.vdevId =
4025 pHddCtx->tdlsConnInfo[staIdx].
4026 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304027 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 peerMacAddr,
4029 &pHddCtx->
4030 tdlsConnInfo[staIdx].
4031 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304032 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 smeTdlsPeerStateParams.peerState =
4034 eSME_TDLS_PEER_STATE_TEARDOWN;
4035
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004036 hdd_debug("calling sme_update_tdls_peer_state for staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004037 MAC_ADDRESS_STR,
4038 pHddCtx->tdlsConnInfo[staIdx].
4039 staId,
4040 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 tdlsConnInfo
4042 [staIdx].
4043 peerMac.
4044 bytes));
4045 status =
4046 sme_update_tdls_peer_state(
4047 pHddCtx->hHal,
4048 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304049 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004050 hdd_err("sme_update_tdls_peer_state failed for "
4051 MAC_ADDRESS_STR,
4052 MAC_ADDR_ARRAY
4053 (pHddCtx->
4054 tdlsConnInfo[staIdx].
4055 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 }
4057 wlan_hdd_tdls_decrement_peer_count
4058 (pAdapter);
4059
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304060 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 tdlsConnInfo[staIdx].
4062 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304063 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4065 pHddCtx->tdlsConnInfo[staIdx].
4066 sessionId = 255;
4067
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304068 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 }
4070 }
4071 break;
4072 }
4073 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
4074 {
4075 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07004076 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
4077 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304078 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 break;
4080 }
4081
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004082 if (pHddCtx->tdls_nss_switch_in_progress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004083 hdd_debug("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004084 status = QDF_STATUS_SUCCESS;
4085 break;
4086 }
4087
Nitesh Shah8e866642017-01-31 15:43:31 +05304088 mutex_lock(&pHddCtx->tdls_lock);
4089 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4090 if (!pHddTdlsCtx) {
4091 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004092 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shah8e866642017-01-31 15:43:31 +05304093 roamResult);
4094 status = QDF_STATUS_E_FAILURE;
4095 break;
4096 }
4097
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 curr_peer =
4099 wlan_hdd_tdls_get_peer(pAdapter,
Nitesh Shah379449e2017-01-31 19:11:29 +05304100 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004102 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304103 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 } else {
4105 if (eTDLS_LINK_CONNECTED ==
4106 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004107 hdd_debug("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004108 } else {
4109 /*
4110 * If external control is enabled then initiate
4111 * TDLS only if forced peer is set otherwise
4112 * ignore should Discover trigger from fw.
4113 */
4114 if (pHddCtx->config->
4115 fTDLSExternalControl
4116 && (false ==
4117 curr_peer->isForcedPeer)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004118 hdd_debug("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304119 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004122 hdd_debug("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Jeff Johnson68755312017-02-10 11:46:55 -08004123 pHddCtx->config->
4124 fTDLSExternalControl,
4125 curr_peer->isForcedPeer,
4126 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05304127 pHddTdlsCtx->curr_candidate = curr_peer;
4128 wlan_hdd_tdls_implicit_send_discovery_request(
4129 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304131 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 }
Nitesh Shah8e866642017-01-31 15:43:31 +05304133 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 break;
4135 }
4136
4137 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4138 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304139 mutex_lock(&pHddCtx->tdls_lock);
4140 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4141 if (!pHddTdlsCtx) {
4142 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004143 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304144 roamResult);
4145 status = QDF_STATUS_E_FAILURE;
4146 break;
4147 }
4148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 curr_peer =
4150 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304151 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004153 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304154 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 } else {
4156 if (eTDLS_LINK_CONNECTED ==
4157 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004158 hdd_debug("Received SHOULD_TEARDOWN for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004159 MAC_ADDRESS_STR
4160 " staId: %d, reason: %d",
4161 MAC_ADDR_ARRAY(pRoamInfo->
4162 peerMac.bytes),
4163 pRoamInfo->staId,
4164 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165
4166 if (pRoamInfo->reasonCode ==
4167 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4168 pRoamInfo->reasonCode ==
4169 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4170 pRoamInfo->reasonCode ==
4171 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4172 pRoamInfo->reasonCode ==
4173 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4174 reason =
4175 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4176 } else
4177 reason =
4178 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4179
4180 wlan_hdd_tdls_indicate_teardown
4181 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304182 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304183 hdd_send_wlan_tdls_teardown_event(
4184 eTDLS_TEARDOWN_BSS_DISCONNECT,
4185 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004187 hdd_debug("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004188 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304190 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304192 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193 break;
4194 }
4195
4196 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4197 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304198 mutex_lock(&pHddCtx->tdls_lock);
4199 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4200 if (!pHddTdlsCtx) {
4201 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004202 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304203 roamResult);
4204 status = QDF_STATUS_E_FAILURE;
4205 break;
4206 }
4207
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 curr_peer =
4209 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304210 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004212 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304213 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 } else {
4215 if (eTDLS_LINK_CONNECTED ==
4216 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004217 hdd_debug("Received SHOULD_PEER_DISCONNECTED for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004218 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004219 " staId: %d reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004220 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4221 pRoamInfo->staId,
4222 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223
4224 if (pRoamInfo->reasonCode ==
4225 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4226 pRoamInfo->reasonCode ==
4227 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4228 pRoamInfo->reasonCode ==
4229 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4230 pRoamInfo->reasonCode ==
4231 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4232 reason =
4233 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4234 } else
4235 reason =
4236 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4237
4238 wlan_hdd_tdls_indicate_teardown
4239 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304240 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304241 hdd_send_wlan_tdls_teardown_event(
4242 eTDLS_TEARDOWN_BSS_DISCONNECT,
4243 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004245 hdd_debug("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004246 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304248 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304250 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 break;
4252 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004253
4254 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
Nitesh Shahf1f38992017-01-31 16:40:16 +05304255 mutex_lock(&pHddCtx->tdls_lock);
4256 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4257 if (!pHddTdlsCtx) {
4258 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004259 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304260 roamResult);
4261 status = QDF_STATUS_E_FAILURE;
4262 break;
4263 }
4264
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004265 status = hdd_tdls_connection_tracker_update(pAdapter,
4266 pRoamInfo,
4267 pHddTdlsCtx);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304268 mutex_unlock(&pHddCtx->tdls_lock);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004269 break;
4270
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 default:
4272 {
4273 break;
4274 }
4275 }
4276
4277 return status;
4278}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004279#else
4280
Nitesh Shah99dd9552017-03-20 19:27:47 +05304281inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004282 uint8_t staId)
4283{
4284 return QDF_STATUS_SUCCESS;
4285}
4286
4287static inline QDF_STATUS
4288hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4289 tCsrRoamInfo *pRoamInfo,
4290 uint32_t roamId,
4291 eRoamCmdStatus roamStatus,
4292 eCsrRoamResult roamResult)
4293{
4294 return QDF_STATUS_SUCCESS;
4295}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296#endif
4297
4298#ifdef WLAN_FEATURE_11W
4299/**
4300 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4301 * @pAdapter: pointer to the adapter
4302 * @nFrameLength: Length of the unprotected frame being passed
4303 * @pbFrames: Pointer to the frame buffer
4304 * @frameType: 802.11 frame type
4305 *
4306 * This function forwards the unprotected management frame to the supplicant.
4307 *
4308 * Return: nothing
4309 */
4310static void
4311hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4312 uint8_t *pbFrames, uint8_t frameType)
4313{
4314 uint8_t type = 0;
4315 uint8_t subType = 0;
4316
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004317 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004318 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319
4320 /* Sanity Checks */
4321 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004322 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 return;
4324 }
4325
4326 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004327 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 return;
4329 }
4330
4331 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004332 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 return;
4334 }
4335
4336 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004337 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 return;
4339 }
4340
4341 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004342 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343 return;
4344 }
4345
4346 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4347 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4348
4349 /* Get pAdapter from Destination mac address of the frame */
4350 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4352 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4353 nFrameLength);
4354#else
4355 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4356 nFrameLength);
4357#endif
4358 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4359 } else if (type == SIR_MAC_MGMT_FRAME &&
4360 subType == SIR_MAC_MGMT_DEAUTH) {
4361#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4362 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4363 nFrameLength);
4364#else
4365 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4366 nFrameLength);
4367#endif
4368 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4369 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004370 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004371 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372 return;
4373 }
4374}
4375#endif
4376
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004377#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378/**
4379 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4380 * @pAdapter: pointer to adapter
4381 * @tid: traffic identifier
4382 * @state: state
4383 * @measInterval: measurement interval
4384 *
4385 * This function sends traffic stream metrics IE information to
4386 * the supplicant via wireless event.
4387 *
4388 * Return: none
4389 */
4390static void
4391hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4392 uint8_t state, uint16_t measInterval)
4393{
4394 union iwreq_data wrqu;
4395 char buf[IW_CUSTOM_MAX + 1];
4396 int nBytes = 0;
4397
4398 if (NULL == pAdapter)
4399 return;
4400
4401 /* create the event */
4402 memset(&wrqu, '\0', sizeof(wrqu));
4403 memset(buf, '\0', sizeof(buf));
4404
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004405 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004406 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407
4408 nBytes =
4409 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4410 measInterval);
4411
4412 wrqu.data.pointer = buf;
4413 wrqu.data.length = nBytes;
4414 /* send the event */
4415 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4416}
4417
4418/**
4419 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4420 * @pAdapter: pointer to adapter
4421 * @pRoamInfo: pointer to roam info
4422 *
4423 * This function sends cckm preauth indication to the supplicant
4424 * via wireless custom event.
4425 *
4426 * Return: none
4427 */
4428static void
4429hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4430{
4431 union iwreq_data wrqu;
4432 char buf[IW_CUSTOM_MAX + 1];
4433 char *pos = buf;
4434 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4435
4436 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4437 return;
4438
4439 /* create the event */
4440 memset(&wrqu, '\0', sizeof(wrqu));
4441 memset(buf, '\0', sizeof(buf));
4442
4443 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004444 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004445 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4446 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447
4448 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4449 pos += nBytes;
4450 freeBytes -= nBytes;
4451
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304452 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304453 pos += QDF_MAC_ADDR_SIZE;
4454 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455
4456 nBytes = snprintf(pos, freeBytes, " %u:%u",
4457 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4458 freeBytes -= nBytes;
4459
4460 wrqu.data.pointer = buf;
4461 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4462
4463 /* send the event */
4464 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4465}
4466
4467/**
4468 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4469 * @pAdapter: pointer to adapter
4470 * @pRoamInfo: pointer to roam info
4471 *
4472 * Return: none
4473 */
4474static void
4475hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4476 tCsrRoamInfo *pRoamInfo)
4477{
4478 union iwreq_data wrqu;
4479 char buf[IW_CUSTOM_MAX + 1];
4480 int nBytes = 0;
4481
4482 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4483 return;
4484
4485 /* create the event */
4486 memset(&wrqu, '\0', sizeof(wrqu));
4487 memset(buf, '\0', sizeof(buf));
4488
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004489 hdd_debug("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490
4491 nBytes =
4492 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4493 pRoamInfo->tsmRoamDelay);
4494
4495 wrqu.data.pointer = buf;
4496 wrqu.data.length = nBytes;
4497
4498 /* send the event */
4499 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4500}
4501
4502/**
4503 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4504 * @pAdapter: pointer to adapter
4505 * @measurementToken: measurement token
4506 * @flag: flag
4507 * @numBss: number of bss
4508 *
4509 * If the measurement is none and no scan results found,
4510 * indicate the supplicant about measurement done.
4511 *
4512 * Return: none
4513 */
4514void
4515hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4516 const uint16_t measurementToken,
4517 const bool flag, const uint8_t numBss)
4518{
4519 union iwreq_data wrqu;
4520 char buf[IW_CUSTOM_MAX];
4521 char *pos = buf;
4522 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4523
4524 memset(&wrqu, '\0', sizeof(wrqu));
4525 memset(buf, '\0', sizeof(buf));
4526
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004527 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004528 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529
4530 nBytes =
4531 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4532 flag, numBss);
4533
4534 wrqu.data.pointer = buf;
4535 wrqu.data.length = nBytes;
4536 /* send the event */
4537 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4538}
4539
4540/**
4541 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4542 * @pAdapter: pointer to adapter
4543 * @pRoamInfo: pointer to roam info
4544 *
4545 * If the measurement is none and no scan results found,
4546 * indicate the supplicant about measurement done.
4547 *
4548 * Return: none
4549 */
4550static void
4551hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4552 const tCsrRoamInfo *pRoamInfo)
4553{
4554 union iwreq_data wrqu;
4555 char buf[IW_CUSTOM_MAX];
4556 char *pos = buf;
4557 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4558 uint8_t i = 0, len = 0;
4559 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4560 uint8_t lastSent = 0, sendBss = 0;
4561 int bcnRepFieldSize =
4562 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4563 bcnReportFields);
4564 uint8_t ieLenByte = 1;
4565 /*
4566 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4567 */
4568#define ESEBCNREPHEADER_LEN (18)
4569
4570 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4571 return;
4572
4573 /*
4574 * Custom event can pass maximum of 256 bytes of data,
4575 * based on the IE len we need to identify how many BSS info can
4576 * be filled in to custom event data.
4577 */
4578 /*
4579 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4580 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4581 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4582 */
4583
4584 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4585 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004586 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004588 * indicate the supplicant about measurement done
4589 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590 hdd_indicate_ese_bcn_report_no_results(
4591 pAdapter,
4592 pRoamInfo->pEseBcnReportRsp->
4593 measurementToken,
4594 pRoamInfo->pEseBcnReportRsp->flag,
4595 pRoamInfo->pEseBcnReportRsp->numBss);
4596 } else {
4597 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4598 memset(&wrqu, '\0', sizeof(wrqu));
4599 memset(buf, '\0', sizeof(buf));
4600 tot_bcn_ieLen = 0;
4601 sendBss = 0;
4602 pos = buf;
4603 freeBytes = IW_CUSTOM_MAX;
4604
4605 for (i = lastSent;
4606 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4607 len =
4608 bcnRepFieldSize + ieLenByte +
4609 pRoamInfo->pEseBcnReportRsp->
4610 bcnRepBssInfo[i].ieLen;
4611 if ((len + tot_bcn_ieLen) >
4612 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4613 break;
4614 }
4615 tot_bcn_ieLen += len;
4616 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004617 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004618 i, bcnRepFieldSize, 1,
4619 pRoamInfo->pEseBcnReportRsp->
4620 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 }
4622
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004623 hdd_debug("Sending %d BSS Info", sendBss);
4624 hdd_debug("CCXBCNREP=%d %d %d %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004625 pRoamInfo->pEseBcnReportRsp->measurementToken,
4626 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4627 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628
4629 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4630 pRoamInfo->pEseBcnReportRsp->
4631 measurementToken,
4632 pRoamInfo->pEseBcnReportRsp->flag,
4633 sendBss);
4634 pos += nBytes;
4635 freeBytes -= nBytes;
4636
4637 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304638 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 sizeof(tot_bcn_ieLen));
4640 pos += sizeof(tot_bcn_ieLen);
4641 freeBytes -= sizeof(tot_bcn_ieLen);
4642
4643 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004644 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4646 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4647 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4648 pRoamInfo->pEseBcnReportRsp->
4649 bcnRepBssInfo[i +
4650 lastSent].bcnReportFields.
4651 ChanNum,
4652 pRoamInfo->pEseBcnReportRsp->
4653 bcnRepBssInfo[i +
4654 lastSent].bcnReportFields.
4655 Spare,
4656 pRoamInfo->pEseBcnReportRsp->
4657 bcnRepBssInfo[i +
4658 lastSent].bcnReportFields.
4659 MeasDuration,
4660 pRoamInfo->pEseBcnReportRsp->
4661 bcnRepBssInfo[i +
4662 lastSent].bcnReportFields.
4663 PhyType,
4664 pRoamInfo->pEseBcnReportRsp->
4665 bcnRepBssInfo[i +
4666 lastSent].bcnReportFields.
4667 RecvSigPower,
4668 pRoamInfo->pEseBcnReportRsp->
4669 bcnRepBssInfo[i +
4670 lastSent].bcnReportFields.
4671 ParentTsf,
4672 pRoamInfo->pEseBcnReportRsp->
4673 bcnRepBssInfo[i +
4674 lastSent].bcnReportFields.
4675 TargetTsf[0],
4676 pRoamInfo->pEseBcnReportRsp->
4677 bcnRepBssInfo[i +
4678 lastSent].bcnReportFields.
4679 TargetTsf[1],
4680 pRoamInfo->pEseBcnReportRsp->
4681 bcnRepBssInfo[i +
4682 lastSent].bcnReportFields.
4683 BcnInterval,
4684 pRoamInfo->pEseBcnReportRsp->
4685 bcnRepBssInfo[i +
4686 lastSent].bcnReportFields.
4687 CapabilityInfo,
4688 pRoamInfo->pEseBcnReportRsp->
4689 bcnRepBssInfo[i +
4690 lastSent].bcnReportFields.
4691 Bssid[0],
4692 pRoamInfo->pEseBcnReportRsp->
4693 bcnRepBssInfo[i +
4694 lastSent].bcnReportFields.
4695 Bssid[1],
4696 pRoamInfo->pEseBcnReportRsp->
4697 bcnRepBssInfo[i +
4698 lastSent].bcnReportFields.
4699 Bssid[2],
4700 pRoamInfo->pEseBcnReportRsp->
4701 bcnRepBssInfo[i +
4702 lastSent].bcnReportFields.
4703 Bssid[3],
4704 pRoamInfo->pEseBcnReportRsp->
4705 bcnRepBssInfo[i +
4706 lastSent].bcnReportFields.
4707 Bssid[4],
4708 pRoamInfo->pEseBcnReportRsp->
4709 bcnRepBssInfo[i +
4710 lastSent].bcnReportFields.
4711 Bssid[5]);
4712
4713 /* bcn report fields are copied */
4714 len =
4715 sizeof(pRoamInfo->pEseBcnReportRsp->
4716 bcnRepBssInfo[i +
4717 lastSent].
4718 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304719 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720 (char *)&pRoamInfo->
4721 pEseBcnReportRsp->bcnRepBssInfo[i +
4722 lastSent].
4723 bcnReportFields, len);
4724 pos += len;
4725 freeBytes -= len;
4726
4727 /* Add 1 byte of ie len */
4728 len =
4729 pRoamInfo->pEseBcnReportRsp->
4730 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304731 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 pos += sizeof(len);
4733 freeBytes -= sizeof(len);
4734
4735 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304736 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737 (char *)pRoamInfo->
4738 pEseBcnReportRsp->bcnRepBssInfo[i +
4739 lastSent].
4740 pBuf, len);
4741 pos += len;
4742 freeBytes -= len;
4743 }
4744
4745 wrqu.data.pointer = buf;
4746 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4747
4748 /* send the event */
4749 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4750 buf);
4751 lastSent += sendBss;
4752 }
4753 }
4754}
4755
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004756#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757
4758/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304759 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4760 * @pHddStaCtx: Station Context
4761 *
4762 * API to check if the connection authentication type is 8021x_sha256.
4763 *
4764 * Return: bool
4765 */
4766#ifdef WLAN_FEATURE_11W
4767static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4768{
4769 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4770 pHddStaCtx->conn_info.authType;
4771}
4772#else
4773static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4774{
4775 return false;
4776}
4777#endif
4778
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304779/*
4780 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4781 * @adapter: Pointer to adapter context
4782 * @roam_info: Pointer to roam info
4783 *
4784 * Return: None
4785 */
4786static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4787 tCsrRoamInfo *roam_info)
4788{
4789 struct hdd_chan_change_params chan_change;
4790 struct cfg80211_bss *bss;
4791 struct net_device *dev = adapter->dev;
4792 struct wireless_dev *wdev = dev->ieee80211_ptr;
4793 struct wiphy *wiphy = wdev->wiphy;
4794 QDF_STATUS status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004795 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304796
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004797 hdd_debug("channel switch for session:%d to channel:%d",
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304798 adapter->sessionId, roam_info->chan_info.chan_id);
4799
4800 chan_change.chan = roam_info->chan_info.chan_id;
4801 chan_change.chan_params.ch_width =
4802 roam_info->chan_info.ch_width;
4803 chan_change.chan_params.sec_ch_offset =
4804 roam_info->chan_info.sec_ch_offset;
4805 chan_change.chan_params.center_freq_seg0 =
4806 roam_info->chan_info.band_center_freq1;
4807 chan_change.chan_params.center_freq_seg1 =
4808 roam_info->chan_info.band_center_freq2;
4809
4810 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4811 if (NULL == bss)
4812 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4813 else
4814 cfg80211_put_bss(wiphy, bss);
4815
4816 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4817 if (QDF_IS_STATUS_ERROR(status))
4818 hdd_err("channel change notification failed");
4819
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004820 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
4821 adapter->sessionId);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304822 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004823 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304824}
4825
Komal Seelam98760ba2015-12-15 11:05:18 +05304826/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 * hdd_sme_roam_callback() - hdd sme roam callback
4828 * @pContext: pointer to adapter context
4829 * @pRoamInfo: pointer to roam info
4830 * @roamId: roam id
4831 * @roamStatus: roam status
4832 * @roamResult: roam result
4833 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304834 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304836QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4838 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4839{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304840 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4842 hdd_wext_state_t *pWextState = NULL;
4843 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304844 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304845 struct cfg80211_bss *bss_status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004846 hdd_context_t *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004848 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004849 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850
4851 /* Sanity check */
4852 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004853 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304854 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 }
4856
4857 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4858 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004859 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304861 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4862 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4863 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4864 pAdapter->sessionId, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 switch (roamStatus) {
4867 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304868 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4869 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004870 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 break;
4872
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 /*
4874 * We did pre-auth,then we attempted a 11r or ese reassoc.
4875 * reassoc failed due to failure, timeout, reject from ap
4876 * in any case tell the OS, our carrier is off and mark
4877 * interface down.
4878 */
4879 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004880 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4881 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304882 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4884 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 pHddStaCtx->ft_carrier_on = false;
4886 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004887 hdd_debug("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004888 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889 break;
4890
4891 case eCSR_ROAM_FT_START:
4892 /*
4893 * When we roam for ESE and 11r, we dont want the OS to be
4894 * informed that the link is down. So mark the link ready for
4895 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4896 * be received. Where in we will not mark the link down
4897 * Also we want to stop tx at this point when we will be
4898 * doing disassoc at this time. This saves 30-60 msec
4899 * after reassoc.
4900 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004901 hdd_info("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004902 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004903 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004904 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304905 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004906 WLAN_CONTROL_PATH);
4907 status = hdd_roam_deregister_sta(pAdapter,
4908 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304909 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304910 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 pHddStaCtx->ft_carrier_on = true;
4912 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004913 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4914 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004915 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004916 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004917 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004918 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004919 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304920 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
4921 pAdapter->roam_ho_fail = true;
4922 else
4923 pAdapter->roam_ho_fail = false;
4924 complete(&pAdapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004925 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004928 hdd_debug("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304930 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 wlan_hdd_netif_queue_control(pAdapter,
4934 WLAN_NETIF_CARRIER_OFF,
4935 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 break;
4938 case eCSR_ROAM_LOSTLINK:
4939 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004940 hdd_debug("Roaming started due to connection lost");
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004941 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304943 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 WLAN_CONTROL_PATH);
4945 break;
4946 }
4947 case eCSR_ROAM_DISASSOCIATED:
4948 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004949 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304950 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004951 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304952 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304953 pAdapter->roam_ho_fail = false;
4954 complete(&pAdapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304955
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956 /* Call to clear any MC Addr List filter applied after
4957 * successful connection.
4958 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304959 hdd_disable_and_flush_mc_addr_list(pAdapter,
4960 pmo_peer_disconnect);
4961 qdf_ret_status =
4962 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4963 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004964 }
4965 break;
4966 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004967 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304968 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4970 roamStatus, roamResult);
4971 break;
4972 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004973 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 /*
4975 * To Do - address probable memory leak with WEP encryption upon
4976 * successful association.
4977 */
4978 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4979 /* Clear saved connection information in HDD */
4980 hdd_conn_remove_connect_info(
4981 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4982 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304983 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984 hdd_association_completion_handler(pAdapter, pRoamInfo,
4985 roamId, roamStatus,
4986 roamResult);
4987#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4988 if (pRoamInfo)
4989 pRoamInfo->roamSynchInProgress = false;
4990#endif
4991 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004992 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004993 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304995 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004996 pRoamInfo,
4997 roamId,
4998 roamStatus,
4999 roamResult);
5000 break;
5001 case eCSR_ROAM_IBSS_IND:
5002 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
5003 roamStatus, roamResult);
5004 break;
5005
5006 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305007 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005008 roam_roam_connect_status_update_handler(pAdapter,
5009 pRoamInfo,
5010 roamId,
5011 roamStatus,
5012 roamResult);
5013 break;
5014
5015 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305016 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 hdd_roam_mic_error_indication_handler(pAdapter,
5018 pRoamInfo,
5019 roamId,
5020 roamStatus,
5021 roamResult);
5022 break;
5023
5024 case eCSR_ROAM_SET_KEY_COMPLETE:
5025 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305026 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005027 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
5028 roamId, roamStatus,
5029 roamResult);
5030 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
5031 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005032 hdd_debug("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 pHddStaCtx->hdd_ReassocScenario,
5034 pAdapter->sessionId);
5035 }
5036 }
5037#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5038 if (pRoamInfo != NULL)
5039 pRoamInfo->roamSynchInProgress = false;
5040#endif
5041 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005042
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005043 case eCSR_ROAM_FT_RESPONSE:
5044 hdd_send_ft_event(pAdapter);
5045 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005046
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05305048 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
5049 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005050 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305051 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005052 wlan_hdd_cfg80211_pmksa_candidate_notify(
5053 pAdapter, pRoamInfo, 1, false);
5054 }
5055 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056
5057#ifdef FEATURE_WLAN_LFR_METRICS
5058 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
5059 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305060 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005061 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
5062 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305063 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005064 }
5065 break;
5066 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
5067 /*
5068 * This event will notify pre-auth completion in case of success
5069 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305070 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5072 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305073 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 }
5075 break;
5076 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
5077 /*
5078 * This event will notify pre-auth completion incase of failure.
5079 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305080 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5082 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305083 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 }
5085 break;
5086 case eCSR_ROAM_HANDOVER_SUCCESS:
5087 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08005088 * It will be only invoked on success
5089 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305090 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
5092 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305093 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094 }
5095 break;
5096#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097 case eCSR_ROAM_REMAIN_CHAN_READY:
5098 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
5099 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100#ifdef FEATURE_WLAN_TDLS
5101 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305102 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
5104 roamId,
5105 roamStatus,
5106 roamResult);
5107 break;
5108 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
5109 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
5110 pRoamInfo->reasonCode);
5111 break;
5112#endif
5113#ifdef WLAN_FEATURE_11W
5114 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
5115 hdd_indicate_unprot_mgmt_frame(pAdapter,
5116 pRoamInfo->nFrameLength,
5117 pRoamInfo->pbFrames,
5118 pRoamInfo->frameType);
5119 break;
5120#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005121#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122 case eCSR_ROAM_TSM_IE_IND:
5123 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
5124 pRoamInfo->tsmIe.state,
5125 pRoamInfo->tsmIe.msmt_interval);
5126 break;
5127
5128 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
5129 {
5130 if (eCSR_AUTH_TYPE_CCKM_WPA ==
5131 pHddStaCtx->conn_info.authType
5132 || eCSR_AUTH_TYPE_CCKM_RSN ==
5133 pHddStaCtx->conn_info.authType) {
5134 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
5135 }
5136 break;
5137 }
5138
5139 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
5140 {
5141 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
5142 break;
5143 }
5144
5145 case eCSR_ROAM_ESE_BCN_REPORT_IND:
5146 {
5147 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
5148 break;
5149 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005150#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305151 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305152 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305153 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305154
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305155 case eCSR_ROAM_UPDATE_SCAN_RESULT:
5156 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
5157 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
5158 pAdapter, pRoamInfo->pBssDesc);
5159 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005160 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305161 else
5162 cfg80211_put_bss(
5163#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5164 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5165#endif
5166 bss_status);
5167 }
5168 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005169 case eCSR_ROAM_NDP_STATUS_UPDATE:
5170 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5171 roamResult);
5172 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005173 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005174 hdd_debug("Process ROAM_START from firmware");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005175 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305176 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005177 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005178 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005179 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005180 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08005181 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005182 break;
5183 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005184 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005185 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005186 wlan_hdd_netif_queue_control(pAdapter,
5187 WLAN_WAKE_ALL_NETIF_QUEUE,
5188 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005189 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005190 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305191 pAdapter->roam_ho_fail = false;
5192 complete(&pAdapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005193 break;
5194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 default:
5196 break;
5197 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305198 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199}
5200
5201/**
5202 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5203 * @auth_suite: auth suite
5204 *
5205 * Return: eCsrAuthType enumeration
5206 */
5207eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5208{
5209 eCsrAuthType auth_type;
5210 /* is the auth type supported? */
5211 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5212 auth_type = eCSR_AUTH_TYPE_RSN;
5213 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5214 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005215 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216 /* Check for 11r FT Authentication with PSK */
5217 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5218 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5219 /* Check for 11R FT Authentication with 802.1X */
5220 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5221 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222#ifdef FEATURE_WLAN_ESE
5223 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5224 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5225 } else
5226#endif /* FEATURE_WLAN_ESE */
5227#ifdef WLAN_FEATURE_11W
5228 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5229 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5230 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5231 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5232 } else
5233#endif
5234 {
5235 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5236 }
5237 return auth_type;
5238}
5239
5240/**
5241 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5242 * @auth_suite: auth suite
5243 *
5244 * Return: eCsrAuthType enumeration
5245 */
5246eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5247{
5248 eCsrAuthType auth_type;
5249 /* is the auth type supported? */
5250 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5251 auth_type = eCSR_AUTH_TYPE_WPA;
5252 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5253 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5254 } else
5255#ifdef FEATURE_WLAN_ESE
5256 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5257 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5258 } else
5259#endif /* FEATURE_WLAN_ESE */
5260 {
5261 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5262 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005263 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005264 return auth_type;
5265}
5266
5267/**
5268 * hdd_translate_rsn_to_csr_encryption_type() -
5269 * Translate RSN to CSR encryption type
5270 * @cipher_suite: cipher suite
5271 *
5272 * Return: eCsrEncryptionType enumeration
5273 */
5274eCsrEncryptionType
5275hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5276{
5277 eCsrEncryptionType cipher_type;
5278
5279 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5280 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5281 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5282 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5283 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5284 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5285 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5286 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5287 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5288 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5289 else
5290 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5291
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005292 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 return cipher_type;
5294}
5295
5296/**
5297 * hdd_translate_wpa_to_csr_encryption_type() -
5298 * Translate WPA to CSR encryption type
5299 * @cipher_suite: cipher suite
5300 *
5301 * Return: eCsrEncryptionType enumeration
5302 */
5303eCsrEncryptionType
5304hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5305{
5306 eCsrEncryptionType cipher_type;
5307
5308 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5309 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5310 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5311 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5312 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5313 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5314 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5315 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5316 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5317 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5318 else
5319 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5320
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005321 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 return cipher_type;
5323}
5324
5325/**
5326 * hdd_process_genie() - process gen ie
5327 * @pAdapter: pointer to adapter
5328 * @bssid: pointer to mac address
5329 * @pEncryptType: pointer to encryption type
5330 * @mcEncryptType: pointer to multicast encryption type
5331 * @pAuthType: pointer to auth type
5332 *
5333 * Return: 0 on success, error number otherwise
5334 */
5335static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5336 u8 *bssid,
5337 eCsrEncryptionType *pEncryptType,
5338 eCsrEncryptionType *mcEncryptType,
5339 eCsrAuthType *pAuthType,
5340#ifdef WLAN_FEATURE_11W
5341 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5342#endif
5343 uint16_t gen_ie_len, uint8_t *gen_ie)
5344{
5345 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305346 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 tDot11fIERSN dot11RSNIE;
5348 tDot11fIEWPA dot11WPAIE;
5349 uint32_t i;
5350 uint8_t *pRsnIe;
5351 uint16_t RSNIeLen;
5352 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5353 bool updatePMKCache = false;
5354
5355 /*
5356 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5357 * setting present flag to 0.
5358 */
5359 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5360 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5361
5362 /* Type check */
5363 if (gen_ie[0] == DOT11F_EID_RSN) {
5364 /* Validity checks */
5365 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5366 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005367 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005368 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 return -EINVAL;
5370 }
5371 /* Skip past the EID byte and length byte */
5372 pRsnIe = gen_ie + 2;
5373 RSNIeLen = gen_ie_len - 2;
5374 /* Unpack the RSN IE */
5375 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305376 pRsnIe, RSNIeLen, &dot11RSNIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005378 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005379 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005380 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005381 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 /* dot11RSNIE.akm_suite_count */
5383 /* Just translate the FIRST one */
5384 *pAuthType =
5385 hdd_translate_rsn_to_csr_auth_type(
5386 dot11RSNIE.akm_suites[0]);
5387 /* dot11RSNIE.pwise_cipher_suite_count */
5388 *pEncryptType =
5389 hdd_translate_rsn_to_csr_encryption_type(
5390 dot11RSNIE.pwise_cipher_suites[0]);
5391 /* dot11RSNIE.gp_cipher_suite_count */
5392 *mcEncryptType =
5393 hdd_translate_rsn_to_csr_encryption_type(
5394 dot11RSNIE.gp_cipher_suite);
5395#ifdef WLAN_FEATURE_11W
5396 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5397 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5398#endif
5399 /* Set the PMKSA ID Cache for this interface */
5400 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5401 if (is_zero_ether_addr(bssid)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005402 hdd_warn("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005403 break;
5404 }
5405 updatePMKCache = true;
5406 /*
5407 * For right now, I assume setASSOCIATE() has passed
5408 * in the bssid.
5409 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305410 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305411 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305412 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5414 }
5415
5416 if (updatePMKCache) {
5417 /*
5418 * Calling csr_roam_set_pmkid_cache to configure the
5419 * PMKIDs into the cache.
5420 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005421 hdd_debug("Calling sme_roam_set_pmkid_cache with cache entry %d.",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005422 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 /* Finally set the PMKSA ID Cache in CSR */
5424 result =
5425 sme_roam_set_pmkid_cache(halHandle,
5426 pAdapter->sessionId,
5427 PMKIDCache,
5428 dot11RSNIE.pmkid_count,
5429 false);
5430 }
5431 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5432 /* Validity checks */
5433 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5434 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005435 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005436 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005437 return -EINVAL;
5438 }
5439 /* Skip past the EID and length byte - and four byte WiFi OUI */
5440 pRsnIe = gen_ie + 2 + 4;
5441 RSNIeLen = gen_ie_len - (2 + 4);
5442 /* Unpack the WPA IE */
5443 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305444 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005446 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005447 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005448 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005449 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 /* dot11WPAIE.auth_suite_count */
5451 /* Just translate the FIRST one */
5452 *pAuthType =
5453 hdd_translate_wpa_to_csr_auth_type(
5454 dot11WPAIE.auth_suites[0]);
5455 /* dot11WPAIE.unicast_cipher_count */
5456 *pEncryptType =
5457 hdd_translate_wpa_to_csr_encryption_type(
5458 dot11WPAIE.unicast_ciphers[0]);
5459 /* dot11WPAIE.unicast_cipher_count */
5460 *mcEncryptType =
5461 hdd_translate_wpa_to_csr_encryption_type(
5462 dot11WPAIE.multicast_cipher);
5463 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005464 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465 return -EINVAL;
5466 }
5467 return 0;
5468}
5469
5470/**
5471 * hdd_set_genie_to_csr() - set genie to csr
5472 * @pAdapter: pointer to adapter
5473 * @RSNAuthType: pointer to auth type
5474 *
5475 * Return: 0 on success, error number otherwise
5476 */
5477int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5478{
5479 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5480 uint32_t status = 0;
5481 eCsrEncryptionType RSNEncryptType;
5482 eCsrEncryptionType mcRSNEncryptType;
5483#ifdef WLAN_FEATURE_11W
5484 uint8_t RSNMfpRequired = 0;
5485 uint8_t RSNMfpCapable = 0;
5486#endif
5487 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5488 /* MAC address of assoc peer */
5489 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305490 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 pWextState->roamProfile.BSSIDs.bssid,
5492 sizeof(bssid));
5493 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5494 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5495 /* continue */
5496 } else {
5497 return 0;
5498 }
5499 /* The actual processing may eventually be more extensive than this. */
5500 /* Right now, just consume any PMKIDs that are sent in by the app. */
5501 status = hdd_process_genie(pAdapter, bssid,
5502 &RSNEncryptType,
5503 &mcRSNEncryptType, RSNAuthType,
5504#ifdef WLAN_FEATURE_11W
5505 &RSNMfpRequired, &RSNMfpCapable,
5506#endif
5507 pWextState->WPARSNIE[1] + 2,
5508 pWextState->WPARSNIE);
5509 if (status == 0) {
5510 /*
5511 * Now copy over all the security attributes
5512 * you have parsed out.
5513 */
5514 pWextState->roamProfile.EncryptionType.numEntries = 1;
5515 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5516
5517 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5518 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5519 mcRSNEncryptType;
5520
Krunal Sonibe766b02016-03-10 13:00:44 -08005521 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5523 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5524 /*
5525 * For wpa none supplicant sends the WPA IE with unicast
5526 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5527 * multicast cipher as either AES/TKIP based on group
5528 * cipher configuration mentioned in the
5529 * wpa_supplicant.conf.
5530 */
5531
5532 /* Set the unicast cipher same as multicast cipher */
5533 pWextState->roamProfile.EncryptionType.encryptionType[0]
5534 = mcRSNEncryptType;
5535 }
5536#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005537 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005538 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5540 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5541#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005542 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005543 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 }
5545 return 0;
5546}
5547
5548/**
5549 * hdd_set_csr_auth_type() - set csr auth type
5550 * @pAdapter: pointer to adapter
5551 * @RSNAuthType: auth type
5552 *
5553 * Return: 0 on success, error number otherwise
5554 */
5555int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5556{
5557 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5558 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5559 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560
5561 pRoamProfile->AuthType.numEntries = 1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005562 hdd_debug("pHddStaCtx->conn_info.authType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005563 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564
5565 switch (pHddStaCtx->conn_info.authType) {
5566 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5567#ifdef FEATURE_WLAN_ESE
5568 case eCSR_AUTH_TYPE_CCKM_WPA:
5569 case eCSR_AUTH_TYPE_CCKM_RSN:
5570#endif
5571 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5572
5573 pRoamProfile->AuthType.authType[0] =
5574 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5575 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5576
5577#ifdef FEATURE_WLAN_ESE
5578 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5579 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5580 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005581 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 pRoamProfile->AuthType.authType[0] =
5583 eCSR_AUTH_TYPE_CCKM_WPA;
5584 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005585 hdd_debug("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005586 pRoamProfile->AuthType.authType[0] =
5587 eCSR_AUTH_TYPE_CCKM_WPA;
5588 } else
5589#endif
5590 if ((pWextState->
5591 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5592 == IW_AUTH_KEY_MGMT_802_1X) {
5593 pRoamProfile->AuthType.authType[0] =
5594 eCSR_AUTH_TYPE_WPA;
5595 } else
5596 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5597 == IW_AUTH_KEY_MGMT_PSK) {
5598 pRoamProfile->AuthType.authType[0] =
5599 eCSR_AUTH_TYPE_WPA_PSK;
5600 } else {
5601 pRoamProfile->AuthType.authType[0] =
5602 eCSR_AUTH_TYPE_WPA_NONE;
5603 }
5604 }
5605 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5606#ifdef FEATURE_WLAN_ESE
5607 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5608 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5609 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005610 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 pRoamProfile->AuthType.authType[0] =
5612 eCSR_AUTH_TYPE_CCKM_RSN;
5613 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005614 hdd_debug("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 pRoamProfile->AuthType.authType[0] =
5616 eCSR_AUTH_TYPE_CCKM_RSN;
5617 } else
5618#endif
5619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5621 ((pWextState->
5622 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5623 == IW_AUTH_KEY_MGMT_802_1X)) {
5624 pRoamProfile->AuthType.authType[0] =
5625 eCSR_AUTH_TYPE_FT_RSN;
5626 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5627 &&
5628 ((pWextState->
5629 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5630 == IW_AUTH_KEY_MGMT_PSK)) {
5631 pRoamProfile->AuthType.authType[0] =
5632 eCSR_AUTH_TYPE_FT_RSN_PSK;
5633 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634
5635#ifdef WLAN_FEATURE_11W
5636 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5637 pRoamProfile->AuthType.authType[0] =
5638 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5639 } else if (RSNAuthType ==
5640 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5641 pRoamProfile->AuthType.authType[0] =
5642 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5643 } else
5644#endif
5645
5646 if ((pWextState->
5647 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5648 == IW_AUTH_KEY_MGMT_802_1X) {
5649 pRoamProfile->AuthType.authType[0] =
5650 eCSR_AUTH_TYPE_RSN;
5651 } else
5652 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5653 == IW_AUTH_KEY_MGMT_PSK) {
5654 pRoamProfile->AuthType.authType[0] =
5655 eCSR_AUTH_TYPE_RSN_PSK;
5656 } else {
5657 pRoamProfile->AuthType.authType[0] =
5658 eCSR_AUTH_TYPE_UNKNOWN;
5659 }
5660 }
5661 break;
5662
5663 case eCSR_AUTH_TYPE_SHARED_KEY:
5664
5665 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5666 break;
5667 default:
5668
5669#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005670 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671#endif /* FEATURE_WLAN_ESE */
5672 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5673 break;
5674 }
5675
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005676 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005677 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679 return 0;
5680}
5681
5682/**
5683 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5684 * to the CSR roam profile.
5685 *
5686 * @dev: Pointer to the net device.
5687 * @info: Pointer to the iw_request_info.
5688 * @wrqu: Pointer to the iwreq_data.
5689 * @extra: Pointer to the data.
5690 *
5691 * Return: 0 for success, error number on failure
5692 */
5693static int __iw_set_essid(struct net_device *dev,
5694 struct iw_request_info *info,
5695 union iwreq_data *wrqu, char *extra)
5696{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697 uint32_t status = 0;
5698 hdd_wext_state_t *pWextState;
5699 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5700 hdd_context_t *hdd_ctx;
5701 uint32_t roamId;
5702 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703 eCsrAuthType RSNAuthType;
5704 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005705 int ret;
5706
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005707 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005708
5709 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5710 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305711 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005712 return ret;
5713
Jeff Johnson441e1f72017-02-07 08:50:49 -08005714 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5715 if (0 != ret)
5716 return ret;
5717
Krunal Sonibe766b02016-03-10 13:00:44 -08005718 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005719 pAdapter->device_mode != QDF_IBSS_MODE &&
5720 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005721 hdd_warn("device mode %s(%d) is not allowed",
5722 hdd_device_mode_to_string(pAdapter->device_mode),
5723 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724 return -EINVAL;
5725 }
5726
5727 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5728
5729 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005730 hdd_warn("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731 return -EBUSY;
5732 }
5733 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5734 return -EINVAL;
5735
5736 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305737 /*Try disconnecting if already in connected state*/
5738 status = wlan_hdd_try_disconnect(pAdapter);
5739 if (0 > status) {
5740 hdd_err("Failed to disconnect the existing connection");
5741 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742 }
5743
5744 /*
5745 * when cfg80211 defined, wpa_supplicant wext driver uses
5746 * zero-length, null-string ssid for force disconnection.
5747 * after disconnection (if previously connected) and cleaning ssid,
5748 * driver MUST return success.
5749 */
5750 if (0 == wrqu->essid.length)
5751 return 0;
5752
5753 status = hdd_wmm_get_uapsd_mask(pAdapter,
5754 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305755 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756 pWextState->roamProfile.uapsd_mask = 0;
5757
5758 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5759
5760 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5761 wrqu->essid.length;
5762
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305763 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305765 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005766 ssId), extra, wrqu->essid.length);
5767 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5768 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5769
5770 /* set gen ie */
5771 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5772
5773 /* set auth */
5774 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5775 }
5776#ifdef FEATURE_WLAN_WAPI
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005777 hdd_debug("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778 if (pAdapter->wapi_info.nWapiMode) {
5779 switch (pAdapter->wapi_info.wapiAuthMode) {
5780 case WAPI_AUTH_MODE_PSK:
5781 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005782 hdd_debug("WAPI AUTH TYPE: PSK: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005783 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784 pRoamProfile->AuthType.numEntries = 1;
5785 pRoamProfile->AuthType.authType[0] =
5786 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5787 break;
5788 }
5789 case WAPI_AUTH_MODE_CERT:
5790 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005791 hdd_debug("WAPI AUTH TYPE: CERT: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005792 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005793 pRoamProfile->AuthType.numEntries = 1;
5794 pRoamProfile->AuthType.authType[0] =
5795 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5796 break;
5797 }
5798 } /* End of switch */
5799 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5800 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005801 hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 pRoamProfile->EncryptionType.numEntries = 1;
5803 pRoamProfile->EncryptionType.encryptionType[0] =
5804 eCSR_ENCRYPT_TYPE_WPI;
5805 pRoamProfile->mcEncryptionType.numEntries = 1;
5806 pRoamProfile->mcEncryptionType.encryptionType[0] =
5807 eCSR_ENCRYPT_TYPE_WPI;
5808 }
5809 }
5810#endif /* FEATURE_WLAN_WAPI */
5811 /* if previous genIE is not NULL, update AssocIE */
5812 if (0 != pWextState->genIE.length) {
5813 memset(&pWextState->assocAddIE, 0,
5814 sizeof(pWextState->assocAddIE));
5815 memcpy(pWextState->assocAddIE.addIEdata,
5816 pWextState->genIE.addIEdata, pWextState->genIE.length);
5817 pWextState->assocAddIE.length = pWextState->genIE.length;
5818 pWextState->roamProfile.pAddIEAssoc =
5819 pWextState->assocAddIE.addIEdata;
5820 pWextState->roamProfile.nAddIEAssocLength =
5821 pWextState->assocAddIE.length;
5822
5823 /* clear previous genIE after use it */
5824 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5825 }
5826
5827 /*
5828 * Assumes it is not WPS Association by default, except when
5829 * pAddIEAssoc has WPS IE.
5830 */
5831 pWextState->roamProfile.bWPSAssociation = false;
5832
5833 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5834 pWextState->roamProfile.
5835 nAddIEAssocLength))
5836 pWextState->roamProfile.bWPSAssociation = true;
5837
5838 /* Disable auto BMPS entry by PMC until DHCP is done */
5839 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5840 true);
5841
5842 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5843
5844 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005845 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005846 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005847 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5848 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005850
Agrawal Ashish6b015762016-05-05 11:22:18 +05305851 /*
5852 * Change conn_state to connecting before sme_roam_connect(),
5853 * because sme_roam_connect() has a direct path to call
5854 * hdd_sme_roam_callback(), which will change the conn_state
5855 * If direct path, conn_state will be accordingly changed to
5856 * NotConnected or Associated by either
5857 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5858 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5859 * Connecting state will remain until it is completed.
5860 *
5861 * If connection state is not changed,
5862 * connection state will remain in eConnectionState_NotConnected state.
5863 * In hdd_association_completion_handler, "hddDisconInProgress" is
5864 * set to true if conn state is eConnectionState_NotConnected.
5865 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5866 * informed of connect result indication which is an issue.
5867 */
5868 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305869 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305870 hdd_conn_set_connection_state(pAdapter,
5871 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305872
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873 status = sme_roam_connect(hHal, pAdapter->sessionId,
5874 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305875 if ((QDF_STATUS_SUCCESS != status) &&
5876 (QDF_STA_MODE == pAdapter->device_mode ||
5877 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005878 hdd_err("sme_roam_connect failed session_id: %d status %d -> NotConnected",
Agrawal Ashish6b015762016-05-05 11:22:18 +05305879 pAdapter->sessionId, status);
5880 /* change back to NotAssociated */
5881 hdd_conn_set_connection_state(pAdapter,
5882 eConnectionState_NotConnected);
5883 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005884 pRoamProfile->ChannelInfo.ChannelList = NULL;
5885 pRoamProfile->ChannelInfo.numOfChannels = 0;
5886
5887 EXIT();
5888 return status;
5889}
5890
5891/**
5892 * iw_set_essid() - set essid handler function
5893 * @dev: Pointer to the net device.
5894 * @info: Pointer to the iw_request_info.
5895 * @wrqu: Pointer to the iwreq_data.
5896 * @extra: Pointer to the data.
5897 *
5898 * Return: 0 for success, error number on failure
5899 */
5900int iw_set_essid(struct net_device *dev,
5901 struct iw_request_info *info,
5902 union iwreq_data *wrqu, char *extra)
5903{
5904 int ret;
5905
5906 cds_ssr_protect(__func__);
5907 ret = __iw_set_essid(dev, info, wrqu, extra);
5908 cds_ssr_unprotect(__func__);
5909
5910 return ret;
5911}
5912
5913/**
5914 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5915 * @dev: pointer to the net device
5916 * @info: pointer to the iw request info
5917 * @dwrq: pointer to iw_point
5918 * @extra: pointer to the data
5919 *
5920 * Return: 0 on success, error number otherwise
5921 */
5922static int __iw_get_essid(struct net_device *dev,
5923 struct iw_request_info *info,
5924 struct iw_point *dwrq, char *extra)
5925{
5926 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5927 hdd_context_t *hdd_ctx;
5928 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5929 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5930 int ret;
5931
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005932 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933
5934 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5935 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305936 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937 return ret;
5938
Jeff Johnson441e1f72017-02-07 08:50:49 -08005939 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5940 if (0 != ret)
5941 return ret;
5942
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5944 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5945 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5946 || pHddStaCtx->conn_info.connState ==
5947 eConnectionState_IbssDisconnected)
5948 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5949 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5950 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5951 dwrq->length);
5952 dwrq->flags = 1;
5953 } else {
5954 memset(extra, 0, dwrq->length);
5955 dwrq->length = 0;
5956 dwrq->flags = 0;
5957 }
5958 EXIT();
5959 return 0;
5960}
5961
5962/**
5963 * iw_get_essid() - get essid handler function
5964 * @dev: Pointer to the net device.
5965 * @info: Pointer to the iw_request_info.
5966 * @wrqu: Pointer to the iwreq_data.
5967 * @extra: Pointer to the data.
5968 *
5969 * Return: 0 for success, error number on failure
5970 */
5971int iw_get_essid(struct net_device *dev,
5972 struct iw_request_info *info,
5973 struct iw_point *wrqu, char *extra)
5974{
5975 int ret;
5976
5977 cds_ssr_protect(__func__);
5978 ret = __iw_get_essid(dev, info, wrqu, extra);
5979 cds_ssr_unprotect(__func__);
5980
5981 return ret;
5982}
5983
5984/**
5985 * __iw_set_auth() -
5986 * This function sets the auth type received from the wpa_supplicant
5987 * @dev: pointer to the net device
5988 * @info: pointer to the iw request info
5989 * @wrqu: pointer to iwreq_data
5990 * @extra: pointer to the data
5991 *
5992 * Return: 0 on success, error number otherwise
5993 */
5994static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5995 union iwreq_data *wrqu, char *extra)
5996{
5997 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5998 hdd_context_t *hdd_ctx;
5999 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6000 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6001 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6002 eCsrEncryptionType mcEncryptionType;
6003 eCsrEncryptionType ucEncryptionType;
6004 int ret;
6005
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006006 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007
6008 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6009 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306010 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 return ret;
6012
Jeff Johnson441e1f72017-02-07 08:50:49 -08006013 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6014 if (0 != ret)
6015 return ret;
6016
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 switch (wrqu->param.flags & IW_AUTH_INDEX) {
6018 case IW_AUTH_WPA_VERSION:
6019 pWextState->wpaVersion = wrqu->param.value;
6020 break;
6021
6022 case IW_AUTH_CIPHER_PAIRWISE:
6023 {
6024 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6025 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6026 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6027 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6028 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6029 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6030 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6031 if ((IW_AUTH_KEY_MGMT_802_1X
6032 ==
6033 (pWextState->
6034 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6035 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6036 pHddStaCtx->conn_info.authType))
6037 /*Dynamic WEP key */
6038 ucEncryptionType =
6039 eCSR_ENCRYPT_TYPE_WEP40;
6040 else
6041 /*Static WEP key */
6042 ucEncryptionType =
6043 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6044 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6045 if ((IW_AUTH_KEY_MGMT_802_1X
6046 ==
6047 (pWextState->
6048 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6049 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6050 pHddStaCtx->conn_info.authType))
6051 /*Dynamic WEP key */
6052 ucEncryptionType =
6053 eCSR_ENCRYPT_TYPE_WEP104;
6054 else
6055 /*Static WEP key */
6056 ucEncryptionType =
6057 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6058 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006059 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
6060 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006061 return -EINVAL;
6062 }
6063
6064 pRoamProfile->EncryptionType.numEntries = 1;
6065 pRoamProfile->EncryptionType.encryptionType[0] =
6066 ucEncryptionType;
6067 }
6068 break;
6069 case IW_AUTH_CIPHER_GROUP:
6070 {
6071 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6072 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6073 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6074 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6075 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6076 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6077 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6078 if ((IW_AUTH_KEY_MGMT_802_1X
6079 ==
6080 (pWextState->
6081 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6082 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6083 pHddStaCtx->conn_info.authType))
6084 mcEncryptionType =
6085 eCSR_ENCRYPT_TYPE_WEP40;
6086 else
6087 mcEncryptionType =
6088 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6089 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6090 /* Dynamic WEP keys won't work with shared keys */
6091 if ((IW_AUTH_KEY_MGMT_802_1X
6092 ==
6093 (pWextState->
6094 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6095 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6096 pHddStaCtx->conn_info.authType)) {
6097 mcEncryptionType =
6098 eCSR_ENCRYPT_TYPE_WEP104;
6099 } else {
6100 mcEncryptionType =
6101 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6102 }
6103 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006104 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006105 wrqu->param.value);
6106 return -EINVAL;
6107 }
6108
6109 pRoamProfile->mcEncryptionType.numEntries = 1;
6110 pRoamProfile->mcEncryptionType.encryptionType[0] =
6111 mcEncryptionType;
6112 }
6113 break;
6114
6115 case IW_AUTH_80211_AUTH_ALG:
6116 {
Jeff Johnson5a062372017-01-12 09:51:25 -08006117 /* Save the auth algo here and set auth type to SME
6118 * Roam profile in the iw_set_ap_address
6119 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
6121 pHddStaCtx->conn_info.authType =
6122 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6123
6124 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
6125 pHddStaCtx->conn_info.authType =
6126 eCSR_AUTH_TYPE_SHARED_KEY;
6127
6128 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
6129 /*Not supported */
6130 pHddStaCtx->conn_info.authType =
6131 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6132 pWextState->roamProfile.AuthType.authType[0] =
6133 pHddStaCtx->conn_info.authType;
6134 }
6135 break;
6136
6137 case IW_AUTH_KEY_MGMT:
6138 {
6139#ifdef FEATURE_WLAN_ESE
6140#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
6141 /*Check for CCKM AKM type */
6142 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006143 hdd_debug("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144 /* Set the CCKM bit in authKeyMgmt */
6145 /*
6146 * Right now, this breaks all ref to authKeyMgmt because
6147 * our code doesn't realize it is a "bitfield"
6148 */
6149 pWextState->authKeyMgmt |=
6150 IW_AUTH_KEY_MGMT_CCKM;
6151 /* Set the key management to 802.1X */
6152 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
6153 pWextState->isESEConnection = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006154 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
6155 /* Save the key management */
6156 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08006157 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006158 /* Save the key management anyway */
6159 pWextState->authKeyMgmt = wrqu->param.value;
6160 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6161 /* Save the key management */
6162 pWextState->authKeyMgmt |=
6163 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006164 }
6165#else
6166 /* Save the key management */
6167 pWextState->authKeyMgmt = wrqu->param.value;
6168#endif /* FEATURE_WLAN_ESE */
6169 }
6170 break;
6171
6172 case IW_AUTH_TKIP_COUNTERMEASURES:
6173 {
6174 if (wrqu->param.value) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006175 hdd_debug("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176 wrqu->param.value);
6177 pWextState->mTKIPCounterMeasures =
6178 TKIP_COUNTER_MEASURE_STARTED;
6179 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006180 hdd_debug("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181 wrqu->param.value);
6182 pWextState->mTKIPCounterMeasures =
6183 TKIP_COUNTER_MEASURE_STOPED;
6184 }
6185 }
6186 break;
6187 case IW_AUTH_DROP_UNENCRYPTED:
6188 case IW_AUTH_WPA_ENABLED:
6189 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6190 case IW_AUTH_ROAMING_CONTROL:
6191 case IW_AUTH_PRIVACY_INVOKED:
6192
6193 default:
6194
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006195 hdd_warn("called with unsupported auth type %d",
6196 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006197 break;
6198 }
6199
6200 EXIT();
6201 return 0;
6202}
6203
6204/**
6205 * iw_set_auth() - set auth callback function
6206 * @dev: Pointer to the net device.
6207 * @info: Pointer to the iw_request_info.
6208 * @wrqu: Pointer to the iwreq_data.
6209 * @extra: Pointer to the data.
6210 *
6211 * Return: 0 for success, error number on failure.
6212 */
6213int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6214 union iwreq_data *wrqu, char *extra)
6215{
6216 int ret;
6217
6218 cds_ssr_protect(__func__);
6219 ret = __iw_set_auth(dev, info, wrqu, extra);
6220 cds_ssr_unprotect(__func__);
6221
6222 return ret;
6223}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006224/**
6225 * __iw_get_auth() -
6226 * This function returns the auth type to the wpa_supplicant
6227 * @dev: pointer to the net device
6228 * @info: pointer to the iw request info
6229 * @wrqu: pointer to iwreq_data
6230 * @extra: pointer to the data
6231 *
6232 * Return: 0 on success, error number otherwise
6233 */
6234static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6235 union iwreq_data *wrqu, char *extra)
6236{
6237 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6238 hdd_context_t *hdd_ctx;
6239 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6240 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6241 int ret;
6242
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006243 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006244
6245 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6246 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306247 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006248 return ret;
6249
Jeff Johnson441e1f72017-02-07 08:50:49 -08006250 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6251 if (0 != ret)
6252 return ret;
6253
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006254 switch (pRoamProfile->negotiatedAuthType) {
6255 case eCSR_AUTH_TYPE_WPA_NONE:
6256 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6257 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6258 break;
6259 case eCSR_AUTH_TYPE_WPA:
6260 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6261 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6262 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006263
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006264 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265 case eCSR_AUTH_TYPE_RSN:
6266 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6267 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6268 break;
6269 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6270 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6271 break;
6272 case eCSR_AUTH_TYPE_SHARED_KEY:
6273 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6274 break;
6275 case eCSR_AUTH_TYPE_UNKNOWN:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006276 hdd_debug("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006277 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6278 break;
6279 case eCSR_AUTH_TYPE_AUTOSWITCH:
6280 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6281 break;
6282 case eCSR_AUTH_TYPE_WPA_PSK:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006283 hdd_debug("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6285 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006286
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006287 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006288 case eCSR_AUTH_TYPE_RSN_PSK:
6289#ifdef WLAN_FEATURE_11W
6290 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6291 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6292#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006293 hdd_debug("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006294 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6295 return -EIO;
6296 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006297 hdd_warn("Unknown auth type: %d",
6298 pRoamProfile->negotiatedAuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006299 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6300 return -EIO;
6301 }
6302 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6303 switch (pRoamProfile->negotiatedUCEncryptionType) {
6304 case eCSR_ENCRYPT_TYPE_NONE:
6305 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6306 break;
6307 case eCSR_ENCRYPT_TYPE_WEP40:
6308 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6309 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6310 break;
6311 case eCSR_ENCRYPT_TYPE_TKIP:
6312 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6313 break;
6314 case eCSR_ENCRYPT_TYPE_WEP104:
6315 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6316 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6317 break;
6318 case eCSR_ENCRYPT_TYPE_AES:
6319 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6320 break;
6321 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006322 hdd_warn("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006323 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006324 return -EIO;
6325 }
6326 }
6327
6328 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6329 switch (pRoamProfile->negotiatedMCEncryptionType) {
6330 case eCSR_ENCRYPT_TYPE_NONE:
6331 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6332 break;
6333 case eCSR_ENCRYPT_TYPE_WEP40:
6334 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6335 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6336 break;
6337 case eCSR_ENCRYPT_TYPE_TKIP:
6338 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6339 break;
6340 case eCSR_ENCRYPT_TYPE_WEP104:
6341 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6342 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6343 break;
6344 case eCSR_ENCRYPT_TYPE_AES:
6345 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6346 break;
6347 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006348 hdd_err("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006349 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006350 return -EIO;
6351 }
6352 }
6353
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006354 hdd_debug("called with auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006355 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006356 EXIT();
6357 return 0;
6358}
6359
6360/**
6361 * iw_get_auth() - get auth callback function
6362 * @dev: Pointer to the net device.
6363 * @info: Pointer to the iw_request_info.
6364 * @wrqu: Pointer to the iwreq_data.
6365 * @extra: Pointer to the data.
6366 *
6367 * Return: 0 for success, error number on failure.
6368 */
6369int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6370 union iwreq_data *wrqu, char *extra)
6371{
6372 int ret;
6373
6374 cds_ssr_protect(__func__);
6375 ret = __iw_get_auth(dev, info, wrqu, extra);
6376 cds_ssr_unprotect(__func__);
6377
6378 return ret;
6379}
6380
6381/**
6382 * __iw_set_ap_address() - set ap address
6383 * @dev: pointer to the net device
6384 * @info: pointer to the iw request info
6385 * @wrqu: pointer to iwreq_data
6386 * @extra: pointer to the data
6387 *
6388 * This function updates the HDD global station context connection info
6389 * BSSID with the MAC address received from the wpa_supplicant.
6390 *
6391 * Return: 0 on success, error number otherwise
6392 */
6393static int __iw_set_ap_address(struct net_device *dev,
6394 struct iw_request_info *info,
6395 union iwreq_data *wrqu, char *extra)
6396{
6397
6398 hdd_adapter_t *adapter;
6399 hdd_context_t *hdd_ctx;
6400 hdd_station_ctx_t *pHddStaCtx =
6401 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6402 uint8_t *pMacAddress = NULL;
6403 int ret;
6404
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006405 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006406
6407 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6408
6409 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6410 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306411 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412 return ret;
6413
Jeff Johnson441e1f72017-02-07 08:50:49 -08006414 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6415 if (0 != ret)
6416 return ret;
6417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006418 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006419 hdd_debug(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306420 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306421 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006422 EXIT();
6423
6424 return 0;
6425}
6426
6427/**
6428 * iw_set_ap_address() - set ap addresses callback function
6429 * @dev: Pointer to the net device.
6430 * @info: Pointer to the iw_request_info.
6431 * @wrqu: Pointer to the iwreq_data.
6432 * @extra: Pointer to the data.
6433 *
6434 * Return: 0 for success, error number on failure.
6435 */
6436int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6437 union iwreq_data *wrqu, char *extra)
6438{
6439 int ret;
6440
6441 cds_ssr_protect(__func__);
6442 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6443 cds_ssr_unprotect(__func__);
6444
6445 return ret;
6446}
6447
6448/**
6449 * __iw_get_ap_address() - get ap address
6450 * @dev: pointer to the net device
6451 * @info: pointer to the iw request info
6452 * @wrqu: pointer to iwreq_data
6453 * @extra: pointer to the data
6454 *
6455 * This function returns currently associated BSSID.
6456 *
6457 * Return: 0 on success, error number otherwise
6458 */
6459static int __iw_get_ap_address(struct net_device *dev,
6460 struct iw_request_info *info,
6461 union iwreq_data *wrqu, char *extra)
6462{
6463 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6464 hdd_context_t *hdd_ctx;
6465 hdd_station_ctx_t *pHddStaCtx =
6466 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6467 int ret;
6468
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006469 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470
6471 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6472 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306473 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006474 return ret;
6475
Jeff Johnson441e1f72017-02-07 08:50:49 -08006476 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6477 if (0 != ret)
6478 return ret;
6479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6481 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306482 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306484 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006485 } else {
6486 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6487 }
6488 EXIT();
6489 return 0;
6490}
6491
6492/**
6493 * iw_get_ap_address() - get ap addresses callback function
6494 * @dev: Pointer to the net device.
6495 * @info: Pointer to the iw_request_info.
6496 * @wrqu: Pointer to the iwreq_data.
6497 * @extra: Pointer to the data.
6498 *
6499 * Return: 0 for success, error number on failure.
6500 */
6501int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6502 union iwreq_data *wrqu, char *extra)
6503{
6504 int ret;
6505
6506 cds_ssr_protect(__func__);
6507 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6508 cds_ssr_unprotect(__func__);
6509
6510 return ret;
6511}