blob: 06f74779cf116725bbb8e5c69d41d478e6a97679 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_assoc.c
30 *
31 * WLAN Host Device Driver implementation
32 *
33 */
34
35#include "wlan_hdd_includes.h"
36#include <ani_global.h>
37#include "dot11f.h"
38#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053039#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include <linux/ieee80211.h>
41#include <linux/wireless.h>
42#include <linux/etherdevice.h>
43#include <net/cfg80211.h>
44#include "wlan_hdd_cfg80211.h"
45#include "csr_inside_api.h"
46#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_api.h"
49#include "wlan_hdd_hostapd.h"
50#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070051#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070052#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <cds_sched.h>
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -080054#include "wlan_policy_mgr_api.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053055#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070057#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070058#include <cdp_txrx_cmn.h>
59#include <cdp_txrx_flow_ctrl_legacy.h>
60#include <cdp_txrx_peer_ops.h>
61#include <cdp_txrx_misc.h>
Kabilan Kannan256e3182017-05-02 16:02:37 -070062#include <cdp_txrx_ctrl.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053063#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080064#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080065#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053066#include "wlan_pmo_ucfg_api.h"
Yu Wang000dc2f2017-05-26 17:38:48 +080067#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
69/* These are needed to recognize WPA and RSN suite types */
70#define HDD_WPA_OUI_SIZE 4
71#define HDD_RSN_OUI_SIZE 4
72uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
73uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
74uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
75uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
76uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
77uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
78
79#ifdef FEATURE_WLAN_ESE
80/* CCKM */
81uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
82/* CCKM */
83uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
84#endif /* FEATURE_WLAN_ESE */
85
86/* group cipher */
87uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
88
89/* WEP-40 or RSN */
90uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
91
92/* TKIP or RSN-PSK */
93uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
94
95/* Reserved */
96uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
97
98/* AES-CCMP */
99uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
100
101/* WEP-104 */
102uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
103
104#ifdef WLAN_FEATURE_11W
105/* RSN-PSK-SHA256 */
106uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
107
108/* RSN-8021X-SHA256 */
109uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
110#endif
111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112/* Offset where the EID-Len-IE, start. */
113#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
114#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115
116#define BEACON_FRAME_IES_OFFSET 12
117#define HDD_PEER_AUTHORIZE_WAIT 10
118
119/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700120 * beacon_filter_table - table of IEs used for beacon filtering
121 */
122static const int beacon_filter_table[] = {
123 SIR_MAC_DS_PARAM_SET_EID,
124 SIR_MAC_ERP_INFO_EID,
125 SIR_MAC_EDCA_PARAM_SET_EID,
126 SIR_MAC_QOS_CAPABILITY_EID,
127 SIR_MAC_HT_INFO_EID,
128 SIR_MAC_VHT_OPMODE_EID,
129 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700130#ifdef WLAN_FEATURE_11AX_BSS_COLOR
131 /*
132 * EID: 221 vendor IE is being used temporarily by 11AX
133 * bss-color-change IE till it gets any fixed number. This
134 * vendor EID needs to be replaced with bss-color-change IE
135 * number.
136 */
137 SIR_MAC_EID_VENDOR,
138#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700139};
140
141/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 * hdd_conn_set_authenticated() - set authentication state
143 * @pAdapter: pointer to the adapter
144 * @authState: authentication state
145 *
146 * This function updates the global HDD station context
147 * authentication state.
148 *
149 * Return: none
150 */
151static void
152hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
153{
154 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
155 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
156
157 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700158 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700159 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 pHddStaCtx->conn_info.uIsAuthenticated = authState;
161
162 /* Check is pending ROC request or not when auth state changed */
163 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
164}
165
166/**
167 * hdd_conn_set_connection_state() - set connection state
168 * @pAdapter: pointer to the adapter
169 * @connState: connection state
170 *
171 * This function updates the global HDD station context connection state.
172 *
173 * Return: none
174 */
175void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
176 eConnectionState connState)
177{
178 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
179 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
180
181 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700182 hdd_debug("%pS Changed connectionState Changed from oldState:%d to State:%d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530183 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
184 connState);
Yu Wang000dc2f2017-05-26 17:38:48 +0800185
186 hdd_tsf_notify_wlan_state_change(pAdapter,
187 pHddStaCtx->conn_info.connState,
188 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189 pHddStaCtx->conn_info.connState = connState;
190
191 /* Check is pending ROC request or not when connection state changed */
192 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
193}
194
195/**
196 * hdd_conn_get_connection_state() - get connection state
197 * @pAdapter: pointer to the adapter
198 * @pConnState: pointer to connection state
199 *
200 * This function updates the global HDD station context connection state.
201 *
202 * Return: true if (Infra Associated or IBSS Connected)
203 * and sets output parameter pConnState;
204 * false otherwise
205 */
206static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
207 eConnectionState *pConnState)
208{
209 bool fConnected = false;
210 eConnectionState connState;
211
212 /* get the connection state. */
213 connState = pHddStaCtx->conn_info.connState;
214
215 if (eConnectionState_Associated == connState ||
216 eConnectionState_IbssConnected == connState ||
217 eConnectionState_IbssDisconnected == connState) {
218 fConnected = true;
219 }
220
221 if (pConnState)
222 *pConnState = connState;
223
224 return fConnected;
225}
226
227/**
228 * hdd_is_connecting() - Function to check connection progress
229 * @hdd_sta_ctx: pointer to global HDD Station context
230 *
231 * Return: true if connecting, false otherwise
232 */
233bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
234{
235 return hdd_sta_ctx->conn_info.connState ==
236 eConnectionState_Connecting;
237}
238
239/**
240 * hdd_conn_is_connected() - Function to check connection status
241 * @pHddStaCtx: pointer to global HDD Station context
242 *
243 * Return: false if any errors encountered, true otherwise
244 */
245bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
246{
247 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
248}
249
250/**
251 * hdd_conn_get_connected_band() - get current connection radio band
252 * @pHddStaCtx: pointer to global HDD Station context
253 *
254 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
255 * eCSR_BAND_ALL if not connected
256 */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700257enum band_info hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258{
259 uint8_t staChannel = 0;
260
261 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
262 staChannel = pHddStaCtx->conn_info.operationChannel;
263
264 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700265 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700267 return BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268 else /* If station is not connected return as eCSR_BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700269 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270}
271
272/**
273 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
274 * @pHddStaCtx: pointer to global HDD Station context
275 * @pConnectedCipherAlgo: pointer to connected cipher algo
276 *
277 * Return: false if any errors encountered, true otherwise
278 */
279static inline bool
280hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
281 eCsrEncryptionType *pConnectedCipherAlgo)
282{
283 bool fConnected = false;
284
285 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
286
287 if (pConnectedCipherAlgo)
288 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
289
290 return fConnected;
291}
292
293/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700294 * hdd_remove_beacon_filter() - remove beacon filter
295 * @adapter: Pointer to the hdd adapter
296 *
297 * Return: 0 on success and errno on failure
298 */
299static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
300{
301 QDF_STATUS status;
302 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
303
304 status = sme_remove_beacon_filter(hdd_ctx->hHal,
305 adapter->sessionId);
306 if (!QDF_IS_STATUS_SUCCESS(status)) {
307 hdd_err("sme_remove_beacon_filter() failed");
308 return -EFAULT;
309 }
310
311 return 0;
312}
313
314/**
315 * hdd_add_beacon_filter() - add beacon filter
316 * @adapter: Pointer to the hdd adapter
317 *
318 * Return: 0 on success and errno on failure
319 */
320static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
321{
322 int i;
323 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
324 QDF_STATUS status;
325 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
326
327 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530328 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700329 (unsigned long int *)ie_map);
330
331 status = sme_add_beacon_filter(hdd_ctx->hHal,
332 adapter->sessionId, ie_map);
333 if (!QDF_IS_STATUS_SUCCESS(status)) {
334 hdd_err("sme_add_beacon_filter() failed");
335 return -EFAULT;
336 }
337 return 0;
338}
339
340/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530341 * hdd_copy_vht_caps()- copy vht caps info from roam info to
342 * hdd station context.
343 * @hdd_sta_ctx: pointer to hdd station context
344 * @roam_info: pointer to roam info
345 *
346 * Return: None
347 */
348static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
349 tCsrRoamInfo *roam_info)
350{
351 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
352 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
353 uint32_t i, temp_ht_cap;
354
355 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
356
357 if (roam_ht_cap->advCodingCap)
358 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
359 if (roam_ht_cap->supportedChannelWidthSet)
360 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
361 temp_ht_cap = roam_ht_cap->mimoPowerSave &
362 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
363 if (temp_ht_cap)
364 hdd_ht_cap->cap_info |=
365 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
366 if (roam_ht_cap->greenField)
367 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
368 if (roam_ht_cap->shortGI20MHz)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
370 if (roam_ht_cap->shortGI40MHz)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
372 if (roam_ht_cap->txSTBC)
373 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
374 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
375 IEEE80211_HT_CAP_RX_STBC_SHIFT);
376 if (temp_ht_cap)
377 hdd_ht_cap->cap_info |=
378 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
379 if (roam_ht_cap->delayedBA)
380 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
381 if (roam_ht_cap->maximalAMSDUsize)
382 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
383 if (roam_ht_cap->dsssCckMode40MHz)
384 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
385 if (roam_ht_cap->psmp)
386 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
387 if (roam_ht_cap->stbcControlFrame)
388 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
389 if (roam_ht_cap->lsigTXOPProtection)
390 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
391
392 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
393 if (roam_ht_cap->maxRxAMPDUFactor)
394 hdd_ht_cap->ampdu_params_info |=
395 IEEE80211_HT_AMPDU_PARM_FACTOR;
396 temp_ht_cap = roam_ht_cap->mpduDensity &
397 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
398 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
399 if (temp_ht_cap)
400 hdd_ht_cap->ampdu_params_info |=
401 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
402
403 /* 802.11n HT extended capabilities masks */
404 if (roam_ht_cap->pco)
405 hdd_ht_cap->extended_ht_cap_info |=
406 IEEE80211_HT_EXT_CAP_PCO;
407 temp_ht_cap = roam_ht_cap->transitionTime &
408 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
409 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
410 if (temp_ht_cap)
411 hdd_ht_cap->extended_ht_cap_info |=
412 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
413 temp_ht_cap = roam_ht_cap->mcsFeedback &
414 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
415 if (temp_ht_cap)
416 hdd_ht_cap->extended_ht_cap_info |=
417 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
418
419 /* tx_bf_cap_info capabilities */
420 if (roam_ht_cap->txBF)
421 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
422 if (roam_ht_cap->rxStaggeredSounding)
423 hdd_ht_cap->tx_BF_cap_info |=
424 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
425 if (roam_ht_cap->txStaggeredSounding)
426 hdd_ht_cap->tx_BF_cap_info |=
427 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
428 if (roam_ht_cap->rxZLF)
429 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
430 if (roam_ht_cap->txZLF)
431 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
432 if (roam_ht_cap->implicitTxBF)
433 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
434 temp_ht_cap = roam_ht_cap->calibration &
435 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
436 if (temp_ht_cap)
437 hdd_ht_cap->tx_BF_cap_info |=
438 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
439 if (roam_ht_cap->explicitCSITxBF)
440 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
441 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
442 hdd_ht_cap->tx_BF_cap_info |=
443 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
444 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
445 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
446 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
447 if (temp_ht_cap)
448 hdd_ht_cap->tx_BF_cap_info |=
449 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
450 temp_ht_cap =
451 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
452 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
453 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
454 if (temp_ht_cap)
455 hdd_ht_cap->tx_BF_cap_info |=
456 temp_ht_cap <<
457 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
458 temp_ht_cap =
459 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
460 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
461 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
462 if (temp_ht_cap)
463 hdd_ht_cap->tx_BF_cap_info |=
464 temp_ht_cap <<
465 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
466 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
467 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
468 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
469 if (temp_ht_cap)
470 hdd_ht_cap->tx_BF_cap_info |=
471 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
472 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
473 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
474 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
475 if (temp_ht_cap)
476 hdd_ht_cap->tx_BF_cap_info |=
477 temp_ht_cap <<
478 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
479 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
480 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
481 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
482 if (temp_ht_cap)
483 hdd_ht_cap->tx_BF_cap_info |=
484 temp_ht_cap <<
485 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
486
487 /* antenna selection */
488 if (roam_ht_cap->antennaSelection)
489 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
490 if (roam_ht_cap->explicitCSIFeedbackTx)
491 hdd_ht_cap->antenna_selection_info |=
492 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
493 if (roam_ht_cap->antennaIndicesFeedbackTx)
494 hdd_ht_cap->antenna_selection_info |=
495 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
496 if (roam_ht_cap->explicitCSIFeedback)
497 hdd_ht_cap->antenna_selection_info |=
498 ANTENNA_SEL_INFO_EXP_CSI_FB;
499 if (roam_ht_cap->antennaIndicesFeedback)
500 hdd_ht_cap->antenna_selection_info |=
501 ANTENNA_SEL_INFO_ANT_ID_FB;
502 if (roam_ht_cap->rxAS)
503 hdd_ht_cap->antenna_selection_info |=
504 ANTENNA_SEL_INFO_RX_AS;
505 if (roam_ht_cap->txSoundingPPDUs)
506 hdd_ht_cap->antenna_selection_info |=
507 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
508
509 /* mcs data rate */
510 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
511 hdd_ht_cap->mcs.rx_mask[i] =
512 roam_ht_cap->supportedMCSSet[i];
513 hdd_ht_cap->mcs.rx_highest =
514 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
515 ((short) (roam_ht_cap->supportedMCSSet[10]));
516 hdd_ht_cap->mcs.tx_params =
517 roam_ht_cap->supportedMCSSet[12];
518}
519
520#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
521#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
522#define VHT_CAP_RXSTBC_MASK_SHIFT 8
523#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
524#define VHT_CAP_BEAMFORMEE_STS_MASK \
525 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
526#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
527#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
528 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
529#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
530#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
531 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
532#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
533
534/**
535 * hdd_copy_ht_caps()- copy ht caps info from roam info to
536 * hdd station context.
537 * @hdd_sta_ctx: pointer to hdd station context
538 * @roam_info: pointer to roam info
539 *
540 * Return: None
541 */
542static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
543 tCsrRoamInfo *roam_info)
544{
545 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
546 struct ieee80211_vht_cap *hdd_vht_cap =
547 &hdd_sta_ctx->conn_info.vht_caps;
548 uint32_t temp_vht_cap;
549
550 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
551
552 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
553 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
554 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
555 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
556 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
557 if (temp_vht_cap)
558 if (roam_vht_cap->supportedChannelWidthSet &
559 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
560 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
561 hdd_vht_cap->vht_cap_info |=
562 temp_vht_cap <<
563 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
564 if (roam_vht_cap->supportedChannelWidthSet &
565 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
566 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
567 hdd_vht_cap->vht_cap_info |=
568 temp_vht_cap <<
569 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
570 if (roam_vht_cap->ldpcCodingCap)
571 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
572 if (roam_vht_cap->shortGI80MHz)
573 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
574 if (roam_vht_cap->shortGI160and80plus80MHz)
575 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
576 if (roam_vht_cap->txSTBC)
577 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
578 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
579 VHT_CAP_RXSTBC_MASK_SHIFT);
580 if (temp_vht_cap)
581 hdd_vht_cap->vht_cap_info |=
582 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
583 if (roam_vht_cap->suBeamFormerCap)
584 hdd_vht_cap->vht_cap_info |=
585 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
586 if (roam_vht_cap->suBeamformeeCap)
587 hdd_vht_cap->vht_cap_info |=
588 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
589 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
590 (VHT_CAP_BEAMFORMEE_STS_MASK);
591 if (temp_vht_cap)
592 hdd_vht_cap->vht_cap_info |=
593 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
594 temp_vht_cap = roam_vht_cap->numSoundingDim &
595 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
596 if (temp_vht_cap)
597 hdd_vht_cap->vht_cap_info |=
598 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
599 if (roam_vht_cap->muBeamformerCap)
600 hdd_vht_cap->vht_cap_info |=
601 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
602 if (roam_vht_cap->muBeamformeeCap)
603 hdd_vht_cap->vht_cap_info |=
604 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
605 if (roam_vht_cap->vhtTXOPPS)
606 hdd_vht_cap->vht_cap_info |=
607 IEEE80211_VHT_CAP_VHT_TXOP_PS;
608 if (roam_vht_cap->htcVHTCap)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_HTC_VHT;
611 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
612 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
613 if (temp_vht_cap)
614 hdd_vht_cap->vht_cap_info |=
615 temp_vht_cap <<
616 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
617 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
618 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
619 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
620 if (temp_vht_cap)
621 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
622 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
623 if (roam_vht_cap->rxAntPattern)
624 hdd_vht_cap->vht_cap_info |=
625 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
626 if (roam_vht_cap->txAntPattern)
627 hdd_vht_cap->vht_cap_info |=
628 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
629 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
630 hdd_vht_cap->supp_mcs.rx_highest =
631 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
632 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
633 hdd_vht_cap->supp_mcs.tx_highest =
634 ((uint16_t)roam_vht_cap->txSupDataRate);
635}
636
637/* ht param */
638#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
639#define HT_PARAM_SERVICE_INT_GRAN 0xe0
640#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
641
642/* operatinon mode */
643#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
644
645/* stbc_param */
646#define HT_STBC_PARAM_MCS 0x007f
647
648/**
649 * hdd_copy_ht_operation()- copy HT operation element from roam info to
650 * hdd station context.
651 * @hdd_sta_ctx: pointer to hdd station context
652 * @roam_info: pointer to roam info
653 *
654 * Return: None
655 */
656static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
657 tCsrRoamInfo *roam_info)
658{
659 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
660 struct ieee80211_ht_operation *hdd_ht_ops =
661 &hdd_sta_ctx->conn_info.ht_operation;
662 uint32_t i, temp_ht_ops;
663
664 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
665
666 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
667
668 /* HT_PARAMS */
669 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
670 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
671 if (temp_ht_ops)
672 hdd_ht_ops->ht_param |= temp_ht_ops;
673 else
674 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
675 if (roam_ht_ops->recommendedTxWidthSet)
676 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
677 if (roam_ht_ops->rifsMode)
678 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
679 if (roam_ht_ops->controlledAccessOnly)
680 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
681 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
682 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
683 if (temp_ht_ops)
684 hdd_ht_ops->ht_param |= temp_ht_ops <<
685 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
686
687 /* operation mode */
688 temp_ht_ops = roam_ht_ops->opMode &
689 IEEE80211_HT_OP_MODE_PROTECTION;
690 switch (temp_ht_ops) {
691 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
692 hdd_ht_ops->operation_mode |=
693 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
694 break;
695 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
696 hdd_ht_ops->operation_mode |=
697 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
698 break;
699 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
700 hdd_ht_ops->operation_mode |=
701 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
702 break;
703 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
704 default:
705 hdd_ht_ops->operation_mode |=
706 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
707 }
708 if (roam_ht_ops->nonGFDevicesPresent)
709 hdd_ht_ops->operation_mode |=
710 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
711 if (roam_ht_ops->transmitBurstLimit)
712 hdd_ht_ops->operation_mode |=
713 HT_OP_MODE_TX_BURST_LIMIT;
714 if (roam_ht_ops->obssNonHTStaPresent)
715 hdd_ht_ops->operation_mode |=
716 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
717
718 /* stbc_param */
719 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
720 HT_STBC_PARAM_MCS;
721 if (temp_ht_ops)
722 hdd_ht_ops->stbc_param |= temp_ht_ops;
723 if (roam_ht_ops->dualCTSProtection)
724 hdd_ht_ops->stbc_param |=
725 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
726 if (roam_ht_ops->secondaryBeacon)
727 hdd_ht_ops->stbc_param |=
728 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
729 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
730 hdd_ht_ops->stbc_param |=
731 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
732 if (roam_ht_ops->pcoActive)
733 hdd_ht_ops->stbc_param |=
734 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
735 if (roam_ht_ops->pcoPhase)
736 hdd_ht_ops->stbc_param |=
737 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
738
739 /* basic MCs set */
740 for (i = 0; i < 16; ++i)
741 hdd_ht_ops->basic_set[i] =
742 roam_ht_ops->basicMCSSet[i];
743}
744
745/**
746 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
747 * hdd station context.
748 * @hdd_sta_ctx: pointer to hdd station context
749 * @roam_info: pointer to roam info
750 *
751 * Return: None
752 */
753static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
754 tCsrRoamInfo *roam_info)
755{
756 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
757 struct ieee80211_vht_operation *hdd_vht_ops =
758 &hdd_sta_ctx->conn_info.vht_operation;
759
760 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
761
762 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
763 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
764 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
765 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
766}
767
768
769/**
770 * hdd_save_bss_info() - save connection info in hdd sta ctx
771 * @adapter: Pointer to adapter
772 * @roam_info: pointer to roam info
773 *
774 * Return: None
775 */
776static void hdd_save_bss_info(hdd_adapter_t *adapter,
777 tCsrRoamInfo *roam_info)
778{
779 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
780
781 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
782 hdd_sta_ctx->conn_info.operationChannel);
783 if (roam_info->vht_caps.present) {
784 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
785 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
786 } else {
787 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
788 }
789 if (roam_info->ht_caps.present) {
790 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
791 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
792 } else {
793 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
794 }
795 if (roam_info->reassoc)
796 hdd_sta_ctx->conn_info.roam_count++;
797 if (roam_info->hs20vendor_ie.present) {
798 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
799 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
800 &roam_info->hs20vendor_ie,
801 sizeof(roam_info->hs20vendor_ie));
802 } else {
803 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
804 }
805 if (roam_info->ht_operation.present) {
806 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
807 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
808 } else {
809 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
810 }
811 if (roam_info->vht_operation.present) {
812 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
813 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
814 } else {
815 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
816 }
817}
818
819/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 * hdd_conn_save_connect_info() - save current connection information
821 * @pAdapter: pointer to adapter
822 * @pRoamInfo: pointer to roam info
823 * @eBssType: bss type
824 *
825 * Return: none
826 */
827static void
828hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
829 eCsrRoamBssType eBssType)
830{
831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
832 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
833
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530834 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835
836 if (pRoamInfo) {
837 /* Save the BSSID for the connection */
838 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530839 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530840 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 &pRoamInfo->bssid);
842
843 /*
844 * Save the Station ID for this station from
845 * the 'Roam Info'. For IBSS mode, staId is
846 * assigned in NEW_PEER_IND. For reassoc,
847 * the staID doesn't change and it may be invalid
848 * in this structure so no change here.
849 */
850 if (!pRoamInfo->fReassocReq) {
851 pHddStaCtx->conn_info.staId[0] =
852 pRoamInfo->staId;
853 }
854 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530855 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 &pRoamInfo->bssid);
857 } else {
858 /*
859 * can't happen. We need a valid IBSS or Infra setting
860 * in the BSSDescription or we can't function.
861 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530862 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 }
864
865 /* notify WMM */
866 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
867
868 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530869 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 } else {
871 /* Get Multicast Encryption Type */
872 encryptType =
873 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
874 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
875 /* Get Unicast Encryption Type */
876 encryptType =
877 pRoamInfo->u.pConnectedProfile->EncryptionType;
878 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
879
880 pHddStaCtx->conn_info.authType =
881 pRoamInfo->u.pConnectedProfile->AuthType;
882
883 pHddStaCtx->conn_info.operationChannel =
884 pRoamInfo->u.pConnectedProfile->operationChannel;
885
886 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530887 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 &pRoamInfo->u.pConnectedProfile->SSID,
889 sizeof(tSirMacSSid));
890
891 /* Save dot11mode in which STA associated to AP */
892 pHddStaCtx->conn_info.dot11Mode =
893 pRoamInfo->u.pConnectedProfile->dot11Mode;
894
895 pHddStaCtx->conn_info.proxyARPService =
896 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530897
898 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
899
900 pHddStaCtx->conn_info.rate_flags =
901 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530903 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905}
906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907/**
908 * hdd_send_ft_assoc_response() - send fast transition assoc response
909 * @dev: pointer to net device
910 * @pAdapter: pointer to adapter
911 * @pCsrRoamInfo: pointer to roam info
912 *
913 * Send the 11R key information to the supplicant. Only then can the supplicant
914 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
915 * for the same purpose.)
916 *
917 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
918 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
919 * This is the Assoc Response.
920 *
921 * Return: none
922 */
923static void
924hdd_send_ft_assoc_response(struct net_device *dev,
925 hdd_adapter_t *pAdapter,
926 tCsrRoamInfo *pCsrRoamInfo)
927{
928 union iwreq_data wrqu;
929 char *buff;
930 unsigned int len = 0;
931 u8 *pFTAssocRsp = NULL;
932
933 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700934 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 return;
936 }
937
938 pFTAssocRsp =
939 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
940 pCsrRoamInfo->nAssocReqLength);
941 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700942 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 return;
944 }
945 /* pFTAssocRsp needs to point to the IEs */
946 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700947 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700948 (unsigned int)pFTAssocRsp[0],
949 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950
951 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700952 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700954 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 return;
956 }
957 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
958 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
959 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 memcpy(buff, pFTAssocRsp, len);
961 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
962
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700963 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966/**
967 * hdd_send_ft_event() - send fast transition event
968 * @pAdapter: pointer to adapter
969 *
970 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
971 * FT events to the supplicant. At the reception of Auth2 we send the RIC
972 * followed by the auth response IEs to the supplicant.
973 * Once both are received in the supplicant, an FT event is generated
974 * to the supplicant.
975 *
976 * Return: none
977 */
978static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
979{
980 uint16_t auth_resp_len = 0;
981 uint32_t ric_ies_length = 0;
982 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
983
984#if defined(KERNEL_SUPPORT_11R_CFG80211)
985 struct cfg80211_ft_event_params ftEvent;
986 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
987 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
988 struct net_device *dev = pAdapter->dev;
989#else
990 char *buff;
991 union iwreq_data wrqu;
992 uint16_t str_len;
993#endif
994
995#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530996 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
997 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998
999 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
1000 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001001 if (ric_ies_length == 0)
1002 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003
1004 ftEvent.ric_ies = ricIe;
1005 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001006 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
1008 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1009 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1010 &auth_resp_len);
1011
1012 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001013 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 return;
1015 }
1016
1017 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1018
1019 ftEvent.target_ap = ftIe;
1020
Anurag Chouhan6d760662016-02-20 16:05:43 +05301021 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1022 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001024 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1025 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1026 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 ftEvent.target_ap[0], ftEvent.target_ap[1],
1028 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1029 ftEvent.target_ap[5]);
1030
1031 (void)cfg80211_ft_event(dev, &ftEvent);
1032
1033#else
1034 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001035 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001037 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 return;
1039 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040
1041 /* Sme needs to send the RIC IEs first */
1042 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1043 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1044 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1045 &ric_ies_length);
1046 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001047 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 } else {
1049 wrqu.data.length = str_len + ric_ies_length;
1050 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1051 }
1052
1053 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301054 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1056 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1057 (u8 *) &buff[str_len],
1058 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1059
1060 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001061 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001062 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 return;
1064 }
1065
1066 wrqu.data.length = str_len + auth_resp_len;
1067 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1068
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001069 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070#endif
1071}
1072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073#ifdef FEATURE_WLAN_ESE
1074/**
1075 * hdd_send_new_ap_channel_info() - send new ap channel info
1076 * @dev: pointer to net device
1077 * @pAdapter: pointer to adapter
1078 * @pCsrRoamInfo: pointer to roam info
1079 *
1080 * Send the ESE required "new AP Channel info" to the supplicant.
1081 * (This keeps the supplicant "up to date" on the current channel.)
1082 *
1083 * The current (new AP) channel information is passed in.
1084 *
1085 * Return: none
1086 */
1087static void
1088hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1089 tCsrRoamInfo *pCsrRoamInfo)
1090{
1091 union iwreq_data wrqu;
1092 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1093
1094 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001095 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 return;
1097 }
1098 /*
1099 * Send the Channel event, the supplicant needs this to generate
1100 * the Adjacent AP report.
1101 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001102 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001103 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 memset(&wrqu, '\0', sizeof(wrqu));
1105 wrqu.freq.m = descriptor->channelId;
1106 wrqu.freq.e = 0;
1107 wrqu.freq.i = 0;
1108 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1109}
1110
1111#endif /* FEATURE_WLAN_ESE */
1112
1113/**
1114 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1115 * @pAdapter: pointer to adapter
1116 * @pCsrRoamInfo: pointer to roam info
1117 *
1118 * Return: none
1119 */
1120static void
1121hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1122 tCsrRoamInfo *pCsrRoamInfo)
1123{
1124 union iwreq_data wrqu;
1125 u8 *pBeaconIes;
1126 u8 currentLen = 0;
1127 char *buff;
1128 int totalIeLen = 0, currentOffset = 0, strLen;
1129
1130 memset(&wrqu, '\0', sizeof(wrqu));
1131
1132 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001133 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 return;
1135 }
1136 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1137 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001138 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 return;
1140 }
1141 /* pBeaconIes needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001142 hdd_debug("Beacon IEs is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001143 (unsigned int)pBeaconIes[0],
1144 (unsigned int)pBeaconIes[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001145 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001146 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147
1148 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001149 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001151 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 return;
1153 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154
1155 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1156 currentLen = strLen + 1;
1157
1158 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1159 do {
1160 /*
1161 * If the beacon size exceeds max CUSTOM event size, break it
1162 * into chunks of CUSTOM event max size and send it to
1163 * supplicant. Changes are done in supplicant to handle this.
1164 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301165 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301167 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301168 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169 currentLen);
1170 currentOffset += currentLen;
1171 totalIeLen -= currentLen;
1172 wrqu.data.length = strLen + 1 + currentLen;
1173 if (totalIeLen)
1174 buff[strLen] = 1; /* more chunks pending */
1175 else
1176 buff[strLen] = 0; /* last chunk */
1177
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001178 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001179 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1181 } while (totalIeLen > 0);
1182
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001183 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184}
1185
1186/**
1187 * hdd_send_association_event() - send association event
1188 * @dev: pointer to net device
1189 * @pCsrRoamInfo: pointer to roam info
1190 *
1191 * Return: none
1192 */
1193static void hdd_send_association_event(struct net_device *dev,
1194 tCsrRoamInfo *pCsrRoamInfo)
1195{
Rajeev Kumar78427682017-01-13 16:13:11 -08001196 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1198 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1199 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1200 union iwreq_data wrqu;
1201 int we_event;
1202 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301203 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205 /* Added to find the auth type on the fly at run time */
1206 /* rather than with cfg to see if FT is enabled */
1207 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1208 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209
1210 memset(&wrqu, '\0', sizeof(wrqu));
1211 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1212 we_event = SIOCGIWAP;
1213#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1214 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301215 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001217 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301218 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001219 hdd_notify_sta_disconnect(pAdapter->sessionId,
1220 true, pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301221 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301222 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223#endif
1224 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001225 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001228 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 return;
1230 }
1231
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001232 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001233 policy_mgr_incr_active_session(pHddCtx->hdd_psoc,
1234 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1236 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1237
1238#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001239 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 if (global_p2p_connection_status ==
1241 P2P_CLIENT_CONNECTING_STATE_1) {
1242 global_p2p_connection_status =
1243 P2P_CLIENT_CONNECTED_STATE_1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001244 hdd_debug("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 } else if (global_p2p_connection_status ==
1246 P2P_CLIENT_CONNECTING_STATE_2) {
1247 global_p2p_connection_status =
1248 P2P_CLIENT_COMPLETED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001249 hdd_debug("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 }
1251 }
1252#endif
1253 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1254 MAC_ADDRESS_STR "\n",
1255 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1256 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1257 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1258
1259 /*
1260 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1261 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001262 * fFTEnable is true.
1263 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 if ((pRoamProfile->AuthType.authType[0] ==
1266 eCSR_AUTH_TYPE_FT_RSN_PSK)
1267 || (pRoamProfile->AuthType.authType[0] ==
1268 eCSR_AUTH_TYPE_FT_RSN)
1269#ifdef FEATURE_WLAN_ESE
1270 || (pRoamProfile->AuthType.authType[0] ==
1271 eCSR_AUTH_TYPE_CCKM_RSN)
1272 || (pRoamProfile->AuthType.authType[0] ==
1273 eCSR_AUTH_TYPE_CCKM_WPA)
1274#endif
1275 ) {
1276 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1277 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301278 qdf_copy_macaddr(&peerMacAddr,
1279 &pHddStaCtx->conn_info.bssId);
1280 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1281 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1282 chan_info.info = pCsrRoamInfo->chan_info.info;
1283 chan_info.band_center_freq1 =
1284 pCsrRoamInfo->chan_info.band_center_freq1;
1285 chan_info.band_center_freq2 =
1286 pCsrRoamInfo->chan_info.band_center_freq2;
1287 chan_info.reg_info_1 =
1288 pCsrRoamInfo->chan_info.reg_info_1;
1289 chan_info.reg_info_2 =
1290 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301291
Dustin Brown7d043f62017-03-27 12:07:36 -07001292 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1293 pAdapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301294 peerMacAddr.bytes,
1295 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001296 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301297 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1298 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001299 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1300 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301301 if (ret)
1302 hdd_err("Peer object %pM fail to set associated state",
1303 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301304
Abhishek Singh1c676222016-05-09 14:20:28 +05301305 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001306 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1307 ePeerConnected,
1308 pCsrRoamInfo->timingMeasCap,
1309 pAdapter->sessionId, &chan_info,
1310 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001311 /* Update tdls module about connection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001312 hdd_notify_sta_connect(pAdapter->sessionId,
1313 pCsrRoamInfo->tdls_chan_swit_prohibited,
1314 pCsrRoamInfo->tdls_prohibited,
1315 pAdapter->hdd_vdev);
1316
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001317 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001318
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001321#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 /* start timer in sta/p2p_cli */
1323 spin_lock_bh(&pHddCtx->bus_bw_lock);
1324 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1325 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001326 cdp_get_intra_bss_fwd_pkts_count(
1327 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301328 &pAdapter->prev_fwd_tx_packets,
1329 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001331 hdd_bus_bw_compute_timer_start(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332#endif
1333#endif
1334 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1335 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001336 policy_mgr_update_connection_info(pHddCtx->hdd_psoc,
1337 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001339 ETH_ALEN);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001340 hdd_info("wlan: new IBSS connection to " MAC_ADDRESS_STR,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001341 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301342
Dustin Brown7d043f62017-03-27 12:07:36 -07001343 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1344 QDF_IBSS_MODE,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301345 pCsrRoamInfo->bssid.bytes,
1346 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001347 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301348 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1349 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001350 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1351 WLAN_ASSOC_STATE);
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301352 if (ret)
1353 hdd_err("Peer object %pM fail to set associated state",
1354 peerMacAddr.bytes);
1355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 } else { /* Not Associated */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001357 hdd_info("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001359 policy_mgr_decr_session_set_pcl(pHddCtx->hdd_psoc,
1360 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361
1362#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1363 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1364#endif
1365
Abhishek Singh1c676222016-05-09 14:20:28 +05301366 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1367 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301368 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 &pHddStaCtx->conn_info.bssId);
1370
1371 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001372 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301373 ePeerDisconnected, 0,
1374 pAdapter->sessionId,
1375 NULL,
1376 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301378
Dustin Brown7d043f62017-03-27 12:07:36 -07001379 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
1380 peerMacAddr.bytes);
Rajeev Kumardfa37072017-01-13 16:27:22 -08001381 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301382 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1383 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1384
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001385 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001386 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001387 hdd_notify_sta_disconnect(pAdapter->sessionId,
1388 false,
1389 pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301390 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392#ifdef MSM_PLATFORM
1393 /* stop timer in sta/p2p_cli */
1394 spin_lock_bh(&pHddCtx->bus_bw_lock);
1395 pAdapter->prev_tx_packets = 0;
1396 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301397 pAdapter->prev_fwd_tx_packets = 0;
1398 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001400 hdd_bus_bw_compute_timer_try_stop(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401#endif
1402 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001403 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 /* Send SCC/MCC Switching event to IPA */
1405 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1406
1407 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001408 /* During the WLAN uninitialization,supplicant is stopped before the
1409 * driver so not sending the status of the connection to supplicant
1410 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001411 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 wireless_send_event(dev, we_event, &wrqu, msg);
1413#ifdef FEATURE_WLAN_ESE
1414 if (eConnectionState_Associated ==
1415 pHddStaCtx->conn_info.connState) {
1416 if ((pRoamProfile->AuthType.authType[0] ==
1417 eCSR_AUTH_TYPE_CCKM_RSN) ||
1418 (pRoamProfile->AuthType.authType[0] ==
1419 eCSR_AUTH_TYPE_CCKM_WPA))
1420 hdd_send_new_ap_channel_info(dev, pAdapter,
1421 pCsrRoamInfo);
1422 }
1423#endif
1424 }
1425}
1426
1427/**
1428 * hdd_conn_remove_connect_info() - remove connection info
1429 * @pHddStaCtx: pointer to global HDD station context
1430 * @pCsrRoamInfo: pointer to roam info
1431 *
1432 * Return: none
1433 */
1434static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1435{
1436 /* Remove staId, bssId and peerMacAddress */
1437 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301438 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1439 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301440 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441
1442 /* Clear all security settings */
1443 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1444 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1445 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1446
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301447 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1448 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450 pHddStaCtx->conn_info.proxyARPService = 0;
1451
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301452 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453}
1454
1455/**
1456 * hdd_roam_deregister_sta() - deregister station
1457 * @pAdapter: pointer to adapter
1458 * @staId: station identifier
1459 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301460 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 */
Abhishek Singh07c627e2017-03-20 17:56:34 +05301462QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301464 QDF_STATUS qdf_status;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301465 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1466 int ret = 0;
1467 uint8_t *peer_mac = NULL;
1468 struct qdf_mac_addr broadcastMacAddr =
1469 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 if (eConnectionState_IbssDisconnected ==
1471 pHddStaCtx->conn_info.connState) {
1472 /*
1473 * Do not set the carrier off when the last peer leaves.
1474 * We will set the carrier off while stopping the IBSS.
1475 */
1476 }
1477
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001478 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001479 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301480 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301481 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301482 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1483 staid, qdf_status, qdf_status);
1484 }
1485
1486 if (adapter->device_mode == QDF_STA_MODE) {
1487 peer_mac = pHddStaCtx->conn_info.bssId.bytes;
1488 } else if (adapter->device_mode == QDF_IBSS_MODE) {
1489 if (pHddStaCtx->broadcast_staid == staid)
1490 peer_mac = broadcastMacAddr.bytes;
1491 else
1492 peer_mac = pHddStaCtx->conn_info.
1493 peerMacAddress[staid].bytes;
1494 }
1495
Dustin Brown7d043f62017-03-27 12:07:36 -07001496 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301497 if (ret) {
1498 hdd_err("Peer obj %pM delete fails", peer_mac);
1499 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301501 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502}
1503
1504/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301505 * hdd_print_bss_info() - print bss info
1506 * @hdd_sta_ctx: pointer to hdd station context
1507 *
1508 * Return: None
1509 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001510static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301511{
1512 uint32_t *cap_info;
1513
1514 hdd_info("WIFI DATA LOGGER");
1515 hdd_info("channel: %d",
1516 hdd_sta_ctx->conn_info.freq);
1517 hdd_info("dot11mode: %d",
1518 hdd_sta_ctx->conn_info.dot11Mode);
1519 hdd_info("AKM: %d",
1520 hdd_sta_ctx->conn_info.authType);
1521 hdd_info("ssid: %.*s",
1522 hdd_sta_ctx->conn_info.SSID.SSID.length,
1523 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1524 hdd_info("roam count: %d",
1525 hdd_sta_ctx->conn_info.roam_count);
1526 hdd_info("ant_info: %d",
1527 hdd_sta_ctx->conn_info.txrate.nss);
1528 hdd_info("datarate legacy %d",
1529 hdd_sta_ctx->conn_info.txrate.legacy);
1530 hdd_info("datarate mcs: %d",
1531 hdd_sta_ctx->conn_info.txrate.mcs);
1532 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1533 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1534 hdd_info("ht caps: %x", *cap_info);
1535 }
1536 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1537 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1538 hdd_info("vht caps: %x", *cap_info);
1539 }
1540 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1541 hdd_info("hs20 info: %x",
1542 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1543 hdd_info("signal: %d",
1544 hdd_sta_ctx->conn_info.signal);
1545 hdd_info("noise: %d",
1546 hdd_sta_ctx->conn_info.noise);
1547}
1548
1549/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 * hdd_dis_connect_handler() - disconnect event handler
1551 * @pAdapter: pointer to adapter
1552 * @pRoamInfo: pointer to roam info
1553 * @roamId: roam identifier
1554 * @roamStatus: roam status
1555 * @roamResult: roam result
1556 *
1557 * This function handles disconnect event:
1558 * 1. Disable transmit queues;
1559 * 2. Clean up internal connection states and data structures;
1560 * 3. Send disconnect indication to supplicant.
1561 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301562 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301564static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 tCsrRoamInfo *pRoamInfo,
1566 uint32_t roamId,
1567 eRoamCmdStatus roamStatus,
1568 eCsrRoamResult roamResult)
1569{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301570 QDF_STATUS status = QDF_STATUS_SUCCESS;
1571 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 struct net_device *dev = pAdapter->dev;
1573 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1574 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1575 uint8_t sta_id;
1576 bool sendDisconInd = true;
1577
1578 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001579 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301580 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 }
1582 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001583 hdd_notice("Disabling queues");
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301584 wlan_hdd_netif_queue_control(pAdapter,
1585 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1586 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587
1588 if (hdd_ipa_is_enabled(pHddCtx))
1589 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001590 HDD_IPA_STA_DISCONNECT,
1591 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592
1593#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1594 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1595#endif
1596
Nirav Shah1da77682016-05-03 20:16:39 +05301597 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1598 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001599 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301600 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601
1602 /* HDD has initiated disconnect, do not send disconnect indication
1603 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301604 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 * to cfg80211_disconnected.
1606 */
1607 if ((eConnectionState_Disconnecting ==
1608 pHddStaCtx->conn_info.connState) ||
1609 (eConnectionState_NotConnected ==
1610 pHddStaCtx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001611 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 sendDisconInd = false;
1613 }
1614
1615 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1616 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 hdd_conn_set_connection_state(pAdapter,
1618 eConnectionState_Disconnecting);
1619 }
1620
1621 hdd_clear_roam_profile_ie(pAdapter);
1622 hdd_wmm_init(pAdapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001623 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301624 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625
1626 /* indicate 'disconnect' status to wpa_supplicant... */
1627 hdd_send_association_event(dev, pRoamInfo);
1628 /* indicate disconnected event to nl80211 */
1629 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1630 /*
1631 * Only send indication to kernel if not initiated
1632 * by kernel
1633 */
1634 if (sendDisconInd) {
1635 /*
1636 * To avoid wpa_supplicant sending "HANGED" CMD
1637 * to ICS UI.
1638 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001639 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1640 if (pRoamInfo->reasonCode ==
1641 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1642 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301643 wlan_hdd_cfg80211_indicate_disconnect(
1644 dev, false,
1645 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001646 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301647 wlan_hdd_cfg80211_indicate_disconnect(
1648 dev, false,
1649 WLAN_REASON_UNSPECIFIED
1650 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001651 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301653 hdd_info("sent disconnected event to nl80211, reason code %d",
1654 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1655 pRoamInfo->reasonCode :
1656 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 }
1658 /*
1659 * During the WLAN uninitialization,supplicant is stopped
1660 * before the driver so not sending the status of the
1661 * connection to supplicant.
1662 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001663 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001665 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 if (global_p2p_connection_status ==
1667 P2P_CLIENT_CONNECTED_STATE_1) {
1668 global_p2p_connection_status =
1669 P2P_CLIENT_DISCONNECTED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001670 hdd_debug("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 } else if (global_p2p_connection_status ==
1672 P2P_CLIENT_COMPLETED_STATE) {
1673 global_p2p_connection_status =
1674 P2P_NOT_ACTIVE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001675 hdd_debug("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 }
1677 }
1678#endif
1679
1680 }
1681 }
1682
1683 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001685 if (hdd_remove_beacon_filter(pAdapter) != 0)
1686 hdd_err("hdd_remove_beacon_filter() failed");
1687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301689 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001690
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001691 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301693 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001694 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301695 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301696 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 }
1698 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301699 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001700 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001701 if (HDD_WLAN_INVALID_STA_ID ==
1702 pHddStaCtx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301703 continue;
1704 sta_id = pHddStaCtx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001705 hdd_debug("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301706 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301707 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001708 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301709 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301710 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301711 }
1712 /* set the staid and peer mac as 0, all other
1713 * reset are done in hdd_connRemoveConnectInfo.
1714 */
1715 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301716 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301717 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301718 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1719 pHddCtx->sta_to_adapter[sta_id] = NULL;
1720 }
1721 } else {
1722 sta_id = pHddStaCtx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001723 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301724
1725 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001726 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1727 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301728 eCSR_ROAM_LOSTLINK == roamStatus) {
Abhishek Singhc9941602016-08-09 16:06:22 +05301729 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1730 pHddStaCtx->conn_info.bssId.bytes);
1731 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1732 pHddStaCtx->conn_info.bssId.bytes);
1733 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301734 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 /* Clear saved connection information in HDD */
1737 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301739 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740
1741#ifdef FEATURE_WLAN_TDLS
1742 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1743 wlan_hdd_tdls_disconnection_callback(pAdapter);
1744#endif
1745
Krunal Sonibe766b02016-03-10 13:00:44 -08001746 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1747 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1749 (pAdapter),
1750 pAdapter->sessionId);
1751 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301752 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 /* Unblock anyone waiting for disconnect to complete */
1754 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301755 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 return status;
1757}
1758
1759/**
1760 * hdd_set_peer_authorized_event() - set peer_authorized_event
1761 * @vdev_id: vdevid
1762 *
1763 * Return: None
1764 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001765static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301767 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 hdd_adapter_t *adapter = NULL;
1769
1770 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1771 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001772 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001773 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 }
1775 complete(&adapter->sta_authorized_event);
1776}
1777
1778/**
1779 * hdd_change_peer_state() - change peer state
1780 * @pAdapter: HDD adapter
1781 * @sta_state: peer state
1782 * @roam_synch_in_progress: roam synch in progress
1783 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301784 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301786QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 uint8_t sta_id,
1788 enum ol_txrx_peer_state sta_state,
1789 bool roam_synch_in_progress)
1790{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301791 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001792 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001793 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1794 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1795 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796
1797 if (!pdev) {
1798 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301799 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 }
1801
1802 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001803 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 }
1806
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001807 peer = cdp_peer_find_by_local_id(soc,
1808 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301810 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811
Leo Changfdb45c32016-10-28 11:09:23 -07001812 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001813 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001814 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001815 return QDF_STATUS_E_FAULT;
1816 }
1817
Leo Changfdb45c32016-10-28 11:09:23 -07001818 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301819 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001820 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301821 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 }
1823#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1824 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301825 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826#endif
1827
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001828 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1830 /* make sure event is reset */
1831 INIT_COMPLETION(pAdapter->sta_authorized_event);
1832#endif
1833
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001834 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 hdd_set_peer_authorized_event,
1836 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301837 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001838 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301839 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 }
1841
Krunal Sonibe766b02016-03-10 13:00:44 -08001842 if (pAdapter->device_mode == QDF_STA_MODE ||
1843 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001845 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 unsigned long rc;
1847
1848 /* wait for event from firmware to set the event */
1849 rc = wait_for_completion_timeout(
1850 &pAdapter->sta_authorized_event,
1851 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001852 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001853 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001854
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001855 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1856 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001857 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858#endif
1859 }
1860 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301861 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862}
1863
1864/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001865 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1866 * @cbk_data: callback data
1867 * @sta_id: station id
1868 * @vdev_param: vdev parameter
1869 * @is_link_up: link state up or down
1870 *
1871 * Return: QDF status
1872 */
1873QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1874 uint8_t sta_id,
1875 uint32_t vdev_param,
1876 bool is_link_up)
1877{
1878 struct cdp_vdev *data_vdev;
1879 QDF_STATUS status = QDF_STATUS_SUCCESS;
1880 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1881 hdd_context_t *hdd_ctx;
1882 struct wlan_objmgr_psoc **psoc;
1883
1884 if (!cbk_data)
1885 return status;
1886
1887 psoc = cbk_data;
1888 hdd_ctx = container_of(psoc, hdd_context_t, hdd_psoc);
1889
1890 if (!hdd_ctx->tdls_nap_active)
1891 return status;
1892
1893 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, sta_id);
1894 if (NULL == data_vdev) {
1895 status = QDF_STATUS_E_FAILURE;
1896 return status;
1897 }
1898
1899 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1900
1901 return status;
1902}
1903
1904/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 * hdd_roam_register_sta() - register station
1906 * @pAdapter: pointer to adapter
1907 * @pRoamInfo: pointer to roam info
1908 * @staId: station identifier
1909 * @pPeerMacAddress: peer MAC address
1910 * @pBssDesc: pointer to BSS description
1911 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301912 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001914QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 tCsrRoamInfo *pRoamInfo,
1916 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301917 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 tSirBssDescription *pBssDesc)
1919{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301920 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 struct ol_txrx_desc_type staDesc = { 0 };
1922 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001923 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001924 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1925 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926
1927 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301928 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929
1930 /* Get the Station ID from the one saved during the association */
1931 staDesc.sta_id = staId;
1932
1933 /* set the QoS field appropriately */
1934 if (hdd_wmm_is_active(pAdapter))
1935 staDesc.is_qos_enabled = 1;
1936 else
1937 staDesc.is_qos_enabled = 0;
1938
1939#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001940 hdd_notice("WAPI STA Registered: %d",
1941 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 if (pAdapter->wapi_info.fIsWapiSta)
1943 staDesc.is_wapi_supported = 1;
1944 else
1945 staDesc.is_wapi_supported = 0;
1946#endif /* FEATURE_WLAN_WAPI */
1947
Dhanashri Atre50141c52016-04-07 13:15:29 -07001948 /* Register the vdev transmit and receive functions */
1949 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1950 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001951
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001952 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1953 (struct cdp_pdev *)pdev,
1954 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001955 if (!pAdapter->txrx_vdev) {
1956 hdd_err("%s find vdev fail", __func__);
1957 return QDF_STATUS_E_FAILURE;
1958 }
1959
1960 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001961 cdp_vdev_register(soc,
1962 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001963 if (!txrx_ops.tx.tx) {
1964 hdd_err("%s vdev register fail", __func__);
1965 return QDF_STATUS_E_FAILURE;
1966 }
1967
Dhanashri Atre50141c52016-04-07 13:15:29 -07001968 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001969 qdf_status = cdp_peer_register(soc,
1970 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301971 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001972 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001973 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301974 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 }
1976
1977 if (!pRoamInfo->fAuthRequired) {
1978 /*
1979 * Connections that do not need Upper layer auth, transition
1980 * TLSHIM directly to 'Authenticated' state
1981 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301982 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001984 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1986 pRoamInfo->roamSynchInProgress
1987#else
1988 false
1989#endif
1990 );
1991
1992 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001993 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001995 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301997 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001999 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2001 pRoamInfo->roamSynchInProgress
2002#else
2003 false
2004#endif
2005 );
2006 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002007 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302009 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010}
2011
2012/**
2013 * hdd_send_re_assoc_event() - send reassoc event
2014 * @dev: pointer to net device
2015 * @pAdapter: pointer to adapter
2016 * @pCsrRoamInfo: pointer to roam info
2017 * @reqRsnIe: pointer to RSN Information element
2018 * @reqRsnLength: length of RSN IE
2019 *
2020 * Return: none
2021 */
2022static void hdd_send_re_assoc_event(struct net_device *dev,
2023 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
2024 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2025{
2026 unsigned int len = 0;
2027 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002028 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2029 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 uint32_t rspRsnLength = 0;
2031 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2033 uint8_t *buf_ptr, ssid_ie_len;
2034 struct cfg80211_bss *bss = NULL;
2035 uint8_t *final_req_ie = NULL;
2036 tCsrRoamConnectedProfile roam_profile;
2037 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002038 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002040 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2041
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002043 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002044 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 }
2046
Naveen Rawat14298b92015-11-25 16:27:41 -08002047 if (!assoc_req_ies) {
2048 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002049 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002050 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002052 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 goto done;
2054 }
2055
2056 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002057 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 goto done;
2059 }
2060
2061 pFTAssocRsp =
2062 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2063 pCsrRoamInfo->nAssocReqLength);
2064 if (pFTAssocRsp == NULL)
2065 goto done;
2066
2067 /* pFTAssocRsp needs to point to the IEs */
2068 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002069 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002070 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071
2072 /*
2073 * Active session count is decremented upon disconnection, but during
2074 * roaming, there is no disconnect indication and hence active session
2075 * count is not decremented.
2076 * After roaming is completed, active session count is incremented
2077 * as a part of connect indication but effectively after roaming the
2078 * active session count should still be the same and hence upon
2079 * successful reassoc decrement the active session count here.
2080 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002081 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002082 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
2083 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084
2085 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2086 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2087 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302088 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2089 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090
2091 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302092 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2094 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302095
2096 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2097 chan, pCsrRoamInfo->bssid.bytes,
2098 &roam_profile.SSID.ssId[0],
2099 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100
2101 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002102 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 buf_ptr = buf_ssid_ie;
2104 *buf_ptr = SIR_MAC_SSID_EID;
2105 buf_ptr++;
2106 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2107 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302108 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 roam_profile.SSID.length);
2110 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002111 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302112 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002113 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002114 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 if (final_req_ie == NULL)
2116 goto done;
2117 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302118 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302120 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2121 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2122 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002124 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302125 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002126 final_req_ie, (ssid_ie_len + reqRsnLength));
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08002127 cfg80211_roamed_bss(dev, bss,
2128 final_req_ie, (ssid_ie_len + reqRsnLength),
2129 rspRsnIe, rspRsnLength, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302131 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002132 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2133 pCsrRoamInfo->nAssocReqLength);
2134
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002135 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302136 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002137 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2138
Prakash Dhavali989127d2016-11-29 14:56:44 +05302139 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002140 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2141 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002142 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002144 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002146 qdf_mem_free(final_req_ie);
2147 qdf_mem_free(rspRsnIe);
2148 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149}
2150
2151/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302152 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002153 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302154 *
2155 * Return: roam sync status if roaming offloaded else false
2156 */
2157#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002158bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302159{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002160 if (roaminfo)
2161 return roaminfo->roamSynchInProgress;
2162 else
2163 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302164}
2165#endif
2166
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002167/**
2168 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2169 * @hddstactx: pointer to HDD sta context
2170 * @roaminfo: pointer to roaminfo structure
2171 *
2172 * This function returns staid for IBSS peer. If peer is broadcast
2173 * MAC address return self staid(0) else find the peer sta id of
2174 * the peer.
2175 *
2176 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2177 */
2178static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2179 tCsrRoamInfo *roaminfo)
2180{
2181 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2182 QDF_STATUS status;
2183
2184 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2185 staid = 0;
2186 } else {
2187 status = hdd_get_peer_sta_id(hddstactx,
2188 &roaminfo->peerMac, &staid);
2189 if (status != QDF_STATUS_SUCCESS) {
2190 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2191 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2192 }
2193 }
2194
2195 return staid;
2196}
Govind Singhedc5cda2015-10-23 17:11:35 +05302197
2198/**
2199 * hdd_change_sta_state_authenticated()-
2200 * This function changes STA state to authenticated
2201 * @adapter: pointer to the adapter structure.
2202 * @roaminfo: pointer to the RoamInfo structure.
2203 *
2204 * This is called from hdd_RoamSetKeyCompleteHandler
2205 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2206 *
2207 * Return: 0 on success and errno on failure
2208 */
2209static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2210 tCsrRoamInfo *roaminfo)
2211{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002212 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002213 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002214 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302215 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002216 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302217
Dustin Brownf660fb42016-09-09 12:04:00 -07002218 timeout = hddstactx->hdd_ReassocScenario ?
2219 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002220 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002221
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002222 if (QDF_IBSS_MODE == adapter->device_mode)
2223 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2224 else
2225 staid = hddstactx->conn_info.staId[0];
2226
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002227 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302228
2229 /* Connections that do not need Upper layer authentication,
2230 * transition TL to 'Authenticated' state after the keys are set
2231 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002232 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302233 hdd_is_roam_sync_in_progress(roaminfo));
2234 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002235 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2236
Krunal Sonibe766b02016-03-10 13:00:44 -08002237 if ((QDF_STA_MODE == adapter->device_mode) ||
2238 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302239 sme_ps_enable_auto_ps_timer(
2240 WLAN_HDD_GET_HAL_CTX(adapter),
2241 adapter->sessionId,
Krunal Soni364e0872017-05-10 21:24:34 -07002242 timeout, false);
Govind Singhedc5cda2015-10-23 17:11:35 +05302243 }
2244
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002245 return qdf_status_to_os_return(status);
2246}
2247
2248/**
2249 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2250 * if key installation is required
2251 * @encr_type: encryption type
2252 *
2253 * Return: true if key installation is required and false otherwise.
2254 */
2255static inline bool hdd_is_key_install_required_for_ibss(
2256 eCsrEncryptionType encr_type)
2257{
2258 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2259 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2260 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
2261 eCSR_ENCRYPT_TYPE_AES == encr_type)
2262 return true;
2263 else
2264 return false;
2265}
2266
2267/**
2268 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2269 * complete
2270 * @adapter: pointer to HDD adapter
2271 * @roaminfo: pointer to roam info
2272 * @roam_result: roam result
2273 *
2274 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2275 * This function checks for the successful set key completion and update
2276 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2277 *
2278 * Return: None
2279 */
2280static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2281 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2282{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002283 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2284 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2285
2286 /*
2287 * If the security mode is one of the following, IBSS peer will be
2288 * waiting in CONN state and we will move the peer state to AUTH
2289 * here. For non-secure connection, no need to wait for set-key complete
2290 * peer will be moved to AUTH in hdd_roam_register_sta.
2291 */
2292 if (QDF_IBSS_MODE == adapter->device_mode) {
2293 if (hdd_is_key_install_required_for_ibss(encr_type))
2294 hdd_change_sta_state_authenticated(adapter, roaminfo);
2295
2296 return;
2297 }
2298
2299 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2300 hdd_sta_ctx->conn_info.gtk_installed = true;
2301 /*
2302 * PTK exchange happens in preauthentication itself if key_mgmt
2303 * is FT-PSK, ptk_installed was false as there is no set PTK
2304 * after roaming. STA TL state moves to authenticated only if
2305 * ptk_installed is true. So, make ptk_installed to true in
2306 * case of 11R roaming.
2307 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302308 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
2309 adapter->sessionId))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002310 hdd_sta_ctx->conn_info.ptk_installed = true;
2311 } else {
2312 hdd_sta_ctx->conn_info.ptk_installed = true;
2313 }
2314
2315 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2316 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2317 * unicast key and it was resulting in sending few un-encrypted packet.
2318 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2319 * set the unicast and broadcast key.
2320 */
2321 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2322 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2323 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2324 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2325 if (hdd_sta_ctx->conn_info.gtk_installed &&
2326 hdd_sta_ctx->conn_info.ptk_installed)
2327 hdd_change_sta_state_authenticated(adapter, roaminfo);
2328 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2329 hdd_change_sta_state_authenticated(adapter, roaminfo);
2330 }
2331
2332 if (hdd_sta_ctx->conn_info.gtk_installed &&
2333 hdd_sta_ctx->conn_info.ptk_installed) {
2334 hdd_sta_ctx->conn_info.gtk_installed = false;
2335 hdd_sta_ctx->conn_info.ptk_installed = false;
2336 }
2337
2338 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2339
2340 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302341}
2342
2343/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 * hdd_roam_set_key_complete_handler() - Update the security parameters
2345 * @pAdapter: pointer to adapter
2346 * @pRoamInfo: pointer to roam info
2347 * @roamId: roam id
2348 * @roamStatus: roam status
2349 * @roamResult: roam result
2350 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302351 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302353static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 tCsrRoamInfo *pRoamInfo,
2355 uint32_t roamId,
2356 eRoamCmdStatus roamStatus,
2357 eCsrRoamResult roamResult)
2358{
2359 eCsrEncryptionType connectedCipherAlgo;
2360 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302362
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 ENTER();
2364
2365 if (NULL == pRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002366 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302367 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 }
2369 /*
2370 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2371 * then go to 'authenticated'. For all other authentication types
2372 * (those that do not require upper layer authentication) we can put TL
2373 * directly into 'authenticated' state.
2374 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002375 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 MAC_ADDRESS_STR, roamStatus, roamResult,
2377 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2378
2379 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2380 &connectedCipherAlgo);
2381 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002382 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2383 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 } else {
2385 /*
2386 * possible disassoc after issuing set key and waiting
2387 * set key complete.
2388 */
2389 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2390 }
2391
2392 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302393 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394}
2395
2396/**
2397 * hdd_perform_roam_set_key_complete() - perform set key complete
2398 * @pAdapter: pointer to adapter
2399 *
2400 * Return: none
2401 */
2402void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2403{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302404 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2406 tCsrRoamInfo roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302409 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302410 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302411 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302412 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302414 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 hdd_roam_set_key_complete_handler(pAdapter,
2416 &roamInfo,
2417 pHddStaCtx->roam_info.roamId,
2418 pHddStaCtx->roam_info.roamStatus,
2419 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302420 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002421 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422
2423 pHddStaCtx->roam_info.deferKeyComplete = false;
2424}
2425
2426/**
2427 * hdd_association_completion_handler() - association completion handler
2428 * @pAdapter: pointer to adapter
2429 * @pRoamInfo: pointer to roam info
2430 * @roamId: roam id
2431 * @roamStatus: roam status
2432 * @roamResult: roam result
2433 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302434 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302436static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 tCsrRoamInfo *pRoamInfo,
2438 uint32_t roamId,
2439 eRoamCmdStatus roamStatus,
2440 eCsrRoamResult roamResult)
2441{
2442 struct net_device *dev = pAdapter->dev;
2443 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2444 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302445 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002447 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 bool hddDisconInProgress = false;
2450 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302451 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302452 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453
2454 if (!pHddCtx) {
2455 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302456 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 }
2458
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302459 /* validate config */
2460 if (!pHddCtx->config) {
2461 hdd_err("config is NULL");
2462 return QDF_STATUS_E_NULL_VALUE;
2463 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 /* HDD has initiated disconnect, do not send connect result indication
2465 * to kernel as it will be handled by __cfg80211_disconnect.
2466 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302467 if (((eConnectionState_Disconnecting ==
2468 pHddStaCtx->conn_info.connState) ||
2469 (eConnectionState_NotConnected ==
2470 pHddStaCtx->conn_info.connState)) &&
2471 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2472 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002473 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 hddDisconInProgress = true;
2475 }
2476
2477 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2478 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002479 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302480 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 }
2482 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 hdd_conn_set_connection_state(pAdapter,
2484 eConnectionState_Associated);
2485 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302486
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 /* Save the connection info from CSR... */
2488 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2489 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002490
2491 if (hdd_add_beacon_filter(pAdapter) != 0)
2492 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493#ifdef FEATURE_WLAN_WAPI
2494 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2495 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2496 || pRoamInfo->u.pConnectedProfile->AuthType ==
2497 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2498 pAdapter->wapi_info.fIsWapiSta = 1;
2499 } else {
2500 pAdapter->wapi_info.fIsWapiSta = 0;
2501 }
2502#endif /* FEATURE_WLAN_WAPI */
Krunal Soni364e0872017-05-10 21:24:34 -07002503 hdd_debug("bss_descr[%d] devicemode[%d]", !!pRoamInfo->pBssDesc,
2504 pAdapter->device_mode);
2505 if ((QDF_STA_MODE == pAdapter->device_mode) &&
2506 pRoamInfo->pBssDesc) {
2507 ie_len = GET_IE_LEN_IN_BSS(pRoamInfo->pBssDesc->length);
2508 pHddStaCtx->ap_supports_immediate_power_save =
2509 wlan_hdd_is_ap_supports_immediate_power_save(
2510 (uint8_t *) pRoamInfo->pBssDesc->ieFields,
2511 ie_len);
2512 hdd_debug("ap_supports_immediate_power_save flag [%d]",
2513 pHddStaCtx->ap_supports_immediate_power_save);
2514 }
2515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 /* Indicate 'connect' status to user space */
2517 hdd_send_association_event(dev, pRoamInfo);
2518
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002519 if (policy_mgr_is_mcc_in_24G(pHddCtx->hdd_psoc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 if (pHddCtx->miracast_value)
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002521 wlan_hdd_set_mas(pAdapter,
2522 pHddCtx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 }
2524
2525 /* Initialize the Linkup event completion variable */
2526 INIT_COMPLETION(pAdapter->linkup_event_var);
2527
2528 /*
2529 * Sometimes Switching ON the Carrier is taking time to activate
2530 * the device properly. Before allowing any packet to go up to
2531 * the application, device activation has to be ensured for
2532 * proper queue mapping by the kernel. we have registered net
2533 * device notifier for device change notification. With this we
2534 * will come to know that the device is getting
2535 * activated properly.
2536 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002538 /*
2539 * Enable Linkup Event Servicing which allows the net
2540 * device notifier to set the linkup event variable.
2541 */
2542 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002544 /* Switch on the Carrier to activate the device */
2545 wlan_hdd_netif_queue_control(pAdapter,
2546 WLAN_NETIF_CARRIER_ON,
2547 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002549 /*
2550 * Wait for the Link to up to ensure all the queues
2551 * are set properly by the kernel.
2552 */
2553 rc = wait_for_completion_timeout(
2554 &pAdapter->linkup_event_var,
2555 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2556 );
2557 if (!rc)
2558 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002560 /*
2561 * Disable Linkup Event Servicing - no more service
2562 * required from the net device notifier call.
2563 */
2564 pAdapter->isLinkUpSvcNeeded = false;
2565 } else {
2566 pHddStaCtx->ft_carrier_on = false;
2567 ft_carrier_on = true;
2568 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2570 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2571 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002572 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573
2574 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2575
2576 if (hdd_ipa_is_enabled(pHddCtx))
2577 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002578 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 pRoamInfo->bssid.bytes);
2580
2581#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2582 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2583#endif
2584
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302585 hdd_debug("check if STA chan ok for DNBS");
2586 if (policy_mgr_is_chan_ok_for_dnbs(pHddCtx->hdd_psoc,
2587 pHddStaCtx->conn_info.operationChannel,
2588 &ok)) {
2589 hdd_err("Unable to check DNBS eligibility for chan:%d",
2590 pHddStaCtx->conn_info.operationChannel);
2591 return QDF_STATUS_E_FAILURE;
2592 }
2593
2594 if (!ok) {
2595 hdd_err("Chan:%d not suitable for DNBS",
2596 pHddStaCtx->conn_info.operationChannel);
2597 wlan_hdd_netif_queue_control(pAdapter,
2598 WLAN_NETIF_CARRIER_OFF,
2599 WLAN_CONTROL_PATH);
2600 if (!hddDisconInProgress) {
2601 hdd_err("Disconnecting...");
2602 sme_roam_disconnect(
2603 WLAN_HDD_GET_HAL_CTX(pAdapter),
2604 pAdapter->sessionId,
2605 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2606 }
2607 return QDF_STATUS_E_FAILURE;
2608 }
2609
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002610 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002611 policy_mgr_check_concurrent_intf_and_restart_sap(
2612 pHddCtx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613
Nirav Shah1da77682016-05-03 20:16:39 +05302614 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2615 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002616 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302617 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 /*
2620 * For reassoc, the station is already registered, all we need
2621 * is to change the state of the STA in TL.
2622 * If authentication is required (WPA/WPA2/DWEP), change TL to
2623 * CONNECTED instead of AUTHENTICATED.
2624 */
2625 if (!pRoamInfo->fReassocReq) {
2626 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 u8 *pFTAssocRsp = NULL;
2628 unsigned int assocRsplen = 0;
2629 u8 *pFTAssocReq = NULL;
2630 unsigned int assocReqlen = 0;
2631 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2633 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2634
2635 /* add bss_id to cfg80211 data base */
2636 bss =
2637 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2638 pRoamInfo);
2639 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302640 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 wlan_hdd_netif_queue_control(pAdapter,
2642 WLAN_NETIF_CARRIER_OFF,
2643 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302644 if (!hddDisconInProgress) {
2645 /*
2646 * Here driver was not able to add bss
2647 * in cfg80211 database this can happen
2648 * if connected channel is not valid,
2649 * i.e reg domain was changed during
2650 * connection. Queue disconnect for the
2651 * session if disconnect is not in
2652 * progress.
2653 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002654 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302655 sme_roam_disconnect(
2656 WLAN_HDD_GET_HAL_CTX(pAdapter),
2657 pAdapter->sessionId,
2658 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2659 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302660 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2663 eCSR_AUTH_TYPE_FT_RSN
2664 || pRoamInfo->u.pConnectedProfile->AuthType ==
2665 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2666
2667 /* Association Response */
2668 pFTAssocRsp =
2669 (u8 *) (pRoamInfo->pbFrames +
2670 pRoamInfo->nBeaconLength +
2671 pRoamInfo->nAssocReqLength);
2672 if (pFTAssocRsp != NULL) {
2673 /*
2674 * pFTAssocRsp needs to point to the IEs
2675 */
2676 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002677 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002678 (unsigned int)pFTAssocRsp[0],
2679 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 assocRsplen =
2681 pRoamInfo->nAssocRspLength -
2682 FT_ASSOC_RSP_IES_OFFSET;
2683 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002684 hdd_debug("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 assocRsplen = 0;
2686 }
2687
2688 /* Association Request */
2689 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2690 pRoamInfo->nBeaconLength);
2691 if (pFTAssocReq != NULL) {
2692 if (!ft_carrier_on) {
2693 /*
2694 * pFTAssocReq needs to point to
2695 * the IEs
2696 */
2697 pFTAssocReq +=
2698 FT_ASSOC_REQ_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002699 hdd_debug("pFTAssocReq is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002700 (unsigned int)
2701 pFTAssocReq[0],
2702 (unsigned int)
2703 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 assocReqlen =
2705 pRoamInfo->nAssocReqLength -
2706 FT_ASSOC_REQ_IES_OFFSET;
2707 } else {
2708 /*
2709 * This should contain only the
2710 * FTIEs
2711 */
2712 assocReqlen =
2713 pRoamInfo->nAssocReqLength;
2714 }
2715 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002716 hdd_debug("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 assocReqlen = 0;
2718 }
2719
2720 if (ft_carrier_on) {
2721 if (!hddDisconInProgress) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302722 struct cfg80211_bss *roam_bss;
2723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 /*
2725 * After roaming is completed,
2726 * active session count is
2727 * incremented as a part of
2728 * connect indication but
2729 * effectively the active
2730 * session count should still
2731 * be the same and hence upon
2732 * successful reassoc
2733 * decrement the active session
2734 * count here.
2735 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002736 if (!hdd_is_roam_sync_in_progress
2737 (pRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002738 policy_mgr_decr_session_set_pcl(
2739 pHddCtx->hdd_psoc,
2740 pAdapter->device_mode,
2741 pAdapter->sessionId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002742 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002743 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 chan =
2745 ieee80211_get_channel
2746 (pAdapter->wdev.wiphy,
2747 (int)pRoamInfo->pBssDesc->
2748 channelId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002749 hdd_debug(
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002750 "assocReqlen %d assocRsplen %d",
2751 assocReqlen,
2752 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002753
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002754 hdd_debug(
Naveen Rawat14298b92015-11-25 16:27:41 -08002755 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302756 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302757 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302758 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002759 pFTAssocReq,
2760 assocReqlen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302761 roam_bss =
2762 hdd_cfg80211_get_bss(
2763 pAdapter->wdev.wiphy,
2764 chan,
2765 pRoamInfo->bssid.bytes,
2766 pRoamInfo->u.
2767 pConnectedProfile->SSID.ssId,
2768 pRoamInfo->u.
2769 pConnectedProfile->SSID.length);
2770 cfg80211_roamed_bss(dev,
2771 roam_bss,
2772 pFTAssocReq,
2773 assocReqlen,
2774 pFTAssocRsp,
2775 assocRsplen,
2776 GFP_KERNEL);
2777 wlan_hdd_send_roam_auth_event(
2778 pAdapter,
2779 pRoamInfo->bssid.bytes,
2780 pFTAssocReq,
2781 assocReqlen,
2782 pFTAssocRsp,
2783 assocRsplen,
2784 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 }
2786 if (sme_get_ftptk_state
2787 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2788 pAdapter->sessionId)) {
2789 sme_set_ftptk_state
2790 (WLAN_HDD_GET_HAL_CTX
2791 (pAdapter),
2792 pAdapter->sessionId,
2793 false);
2794 pRoamInfo->fAuthRequired =
2795 false;
2796
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302797 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 roam_info.bssid,
2799 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302800 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302801 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 roam_info.peerMac,
2803 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302804 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 pHddStaCtx->roam_info.roamId =
2806 roamId;
2807 pHddStaCtx->roam_info.
2808 roamStatus = roamStatus;
2809 pHddStaCtx->roam_info.
2810 deferKeyComplete = true;
2811 }
2812 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002813 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002814 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302815 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302816 pRoamInfo->
2817 bssid.bytes,
2818 pRoamInfo,
2819 pFTAssocReq,
2820 assocReqlen,
2821 pFTAssocRsp,
2822 assocRsplen,
2823 WLAN_STATUS_SUCCESS,
2824 GFP_KERNEL,
2825 false,
2826 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002828 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 /*
2830 * wpa supplicant expecting WPA/RSN IE in
2831 * connect result.
2832 */
2833 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2834 (pAdapter),
2835 pAdapter->sessionId,
2836 &reqRsnLength,
2837 reqRsnIe);
2838
2839 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2840 (pAdapter),
2841 pAdapter->sessionId,
2842 &rspRsnLength,
2843 rspRsnIe);
2844 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 if (ft_carrier_on)
2846 hdd_send_re_assoc_event(dev,
2847 pAdapter,
2848 pRoamInfo,
2849 reqRsnIe,
2850 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002851 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002852 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002853 MAC_ADDRESS_STR
2854 " result:%d and Status:%d",
2855 MAC_ADDR_ARRAY
2856 (pRoamInfo->bssid.bytes),
2857 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858
2859 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302860 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302861 pRoamInfo->
2862 bssid.bytes,
2863 pRoamInfo,
2864 reqRsnIe,
2865 reqRsnLength,
2866 rspRsnIe,
2867 rspRsnLength,
2868 WLAN_STATUS_SUCCESS,
2869 GFP_KERNEL,
2870 false,
2871 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 }
2873 }
2874 }
2875 if (!hddDisconInProgress) {
2876 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 bss);
2879
2880 /*
2881 * Perform any WMM-related association
2882 * processing.
2883 */
2884 hdd_wmm_assoc(pAdapter, pRoamInfo,
2885 eCSR_BSS_TYPE_INFRASTRUCTURE);
2886
2887 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002888 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002890 qdf_status = hdd_roam_register_sta(pAdapter,
2891 pRoamInfo,
2892 pHddStaCtx->conn_info.staId[0],
2893 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002894 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 wlan_hdd_netif_queue_control(pAdapter,
2896 WLAN_WAKE_ALL_NETIF_QUEUE,
2897 WLAN_CONTROL_PATH);
2898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 }
2900 } else {
2901 /*
2902 * wpa supplicant expecting WPA/RSN IE in connect result
2903 * in case of reassociation also need to indicate it to
2904 * supplicant.
2905 */
2906 csr_roam_get_wpa_rsn_req_ie(
2907 WLAN_HDD_GET_HAL_CTX(pAdapter),
2908 pAdapter->sessionId,
2909 &reqRsnLength, reqRsnIe);
2910
2911 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2912 reqRsnIe, reqRsnLength);
2913 /* Reassoc successfully */
2914 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302915 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 hdd_change_peer_state(pAdapter,
2917 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002918 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2920 pRoamInfo->roamSynchInProgress
2921#else
2922 false
2923#endif
2924 );
2925 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002926 hdd_objmgr_set_peer_mlme_auth_state(
2927 pAdapter->hdd_vdev,
2928 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002930 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002931 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302932 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 hdd_change_peer_state(pAdapter,
2934 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002935 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2937 pRoamInfo->roamSynchInProgress
2938#else
2939 false
2940#endif
2941 );
2942 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002943 hdd_objmgr_set_peer_mlme_auth_state(
2944 pAdapter->hdd_vdev,
2945 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 }
2947
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302948 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 /*
2950 * Perform any WMM-related association
2951 * processing
2952 */
2953 hdd_wmm_assoc(pAdapter, pRoamInfo,
2954 eCSR_BSS_TYPE_INFRASTRUCTURE);
2955 }
2956
2957 /* Start the tx queues */
2958#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2959 if (pRoamInfo->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002960 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002962 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 wlan_hdd_netif_queue_control(pAdapter,
2964 WLAN_WAKE_ALL_NETIF_QUEUE,
2965 WLAN_CONTROL_PATH);
2966 }
2967
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302968#ifdef FEATURE_WLAN_TDLS
2969 wlan_hdd_tdls_connection_callback(pAdapter);
2970#endif
2971
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302972 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002973 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302974 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 }
2976#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302977 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 sizeof(pAdapter->hdd_stats.hddPmfStats));
2979#endif
2980 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302981 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 hdd_wext_state_t *pWextState =
2983 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2984 if (pRoamInfo)
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(pRoamInfo->bssid.bytes),
2988 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302990 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002991 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302992 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2993 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302994
2995 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2996 (pRoamInfo &&
2997 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2998 pRoamInfo->statusCode) ||
2999 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
3000 pRoamInfo->statusCode) ||
3001 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
3002 pRoamInfo->statusCode)))) {
3003 wlan_hdd_cfg80211_update_bss_list(pAdapter,
3004 pRoamInfo ?
3005 pRoamInfo->bssid.bytes :
3006 pWextState->req_bssId.bytes);
3007 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
3008 pRoamInfo ?
3009 pRoamInfo->bssid.bytes :
3010 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303011 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303012 }
3013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 /*
3015 * CR465478: Only send up a connection failure result when CSR
3016 * has completed operation - with a ASSOCIATION_FAILURE status.
3017 */
3018 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3019 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303020 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003021 hdd_err("send connect failure to nl80211: for bssid "
3022 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003023 " result: %d and Status: %d reasoncode: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003024 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3025 roamResult, roamStatus,
3026 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303027 pHddStaCtx->conn_info.assoc_status_code =
3028 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003029 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003030 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003032 " result: %d and status: %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3034 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003035 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003036 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303037 wlan_deregister_txrx_packetdump();
3038
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 /* inform association failure event to nl80211 */
3040 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3041 roamResult) {
3042 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303043 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303045 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303047 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303048 connect_timeout,
3049 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303051 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303053 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303055 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303056 connect_timeout,
3057 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 } else {
Wu Gao77d28352016-11-23 17:50:56 +08003059 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303060 hdd_connect_result(dev,
3061 pRoamInfo->bssid.bytes,
3062 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08003063 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05303064 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303066 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303067 connect_timeout,
3068 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003069 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303070 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303072 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303074 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303075 connect_timeout,
3076 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 }
Abhishek Singhac2be142015-12-03 16:16:25 +05303078 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003079 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3080 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05303081 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003082 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05303083 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003084 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303085 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303086 connect_timeout,
3087 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 }
3089
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 /*
3091 * Set connection state to eConnectionState_NotConnected only
3092 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003093 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003095 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3096 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 hdd_conn_set_connection_state(pAdapter,
3099 eConnectionState_NotConnected);
3100 }
3101 hdd_wmm_init(pAdapter);
3102
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003103 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303105 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 WLAN_CONTROL_PATH);
3107 }
3108
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303109 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110}
3111
3112/**
3113 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
3114 * @pAdapter: pointer to adapter
3115 * @pRoamInfo: pointer to roam info
3116 * @roamId: roam id
3117 * @roamStatus: roam status
3118 * @roamResult: roam result
3119 *
3120 * Here we update the status of the Ibss when we receive information that we
3121 * have started/joined an ibss session.
3122 *
3123 * Return: none
3124 */
3125static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3126 tCsrRoamInfo *pRoamInfo,
3127 uint32_t roamId,
3128 eRoamCmdStatus roamStatus,
3129 eCsrRoamResult roamResult)
3130{
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003131 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3132
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003133 hdd_debug("%s: id %d, status %d, result %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003134 pAdapter->dev->name, roamId,
3135 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136
3137 switch (roamResult) {
3138 /* both IBSS Started and IBSS Join should come in here. */
3139 case eCSR_ROAM_RESULT_IBSS_STARTED:
3140 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3141 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3142 {
3143 hdd_context_t *pHddCtx =
3144 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303145 hdd_station_ctx_t *hdd_sta_ctx =
3146 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303147 struct qdf_mac_addr broadcastMacAddr =
3148 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149
3150 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303151 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 return;
3153 }
3154
3155 /* When IBSS Started comes from CSR, we need to move
3156 * connection state to IBSS Disconnected (meaning no peers
3157 * are in the IBSS).
3158 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 hdd_conn_set_connection_state(pAdapter,
3160 eConnectionState_IbssDisconnected);
3161 /* notify wmm */
3162 hdd_wmm_connect(pAdapter, pRoamInfo,
3163 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303164
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003165 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303166
3167 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 pAdapter;
3169 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303170 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 &broadcastMacAddr,
3172 pRoamInfo->pBssDesc);
3173
3174 if (pRoamInfo->pBssDesc) {
3175 struct cfg80211_bss *bss;
3176#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3177 struct ieee80211_channel *chan;
3178 int chan_no;
3179 unsigned int freq;
3180#endif
3181 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003182 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3183 pAdapter->dev->name,
3184 MAC_ADDR_ARRAY(
3185 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186
3187 /* we must first give cfg80211 the BSS information */
3188 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3189 pRoamInfo);
3190 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003191 hdd_err("%s: unable to create IBSS entry",
3192 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 return;
3194 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003195 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 wlan_hdd_netif_queue_control(pAdapter,
3197 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3198 WLAN_CONTROL_PATH);
3199
3200#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3201 chan_no = pRoamInfo->pBssDesc->channelId;
3202
3203 if (chan_no <= 14)
3204 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003205 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 else
3207 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003208 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209
3210 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3211
3212 if (chan)
3213 cfg80211_ibss_joined(pAdapter->dev,
3214 bss->bssid, chan,
3215 GFP_KERNEL);
3216 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003217 hdd_warn("%s: chanId: %d, can't find channel",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003218 pAdapter->dev->name,
3219 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220#else
3221 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3222 GFP_KERNEL);
3223#endif
3224 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 bss);
3227 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003228 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003229 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
3230 pAdapter->device_mode, pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003231 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3232 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003233 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
3234 pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003235 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 break;
3237 }
3238
3239 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3240 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003241 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 break;
3243 }
3244
3245 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003246 hdd_err("%s: unexpected result %d",
3247 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 break;
3249 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250}
3251
3252/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003253 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3254 * @sta_ctx: pointer to hdd station context
3255 * @sta_id: station ID
3256 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 *
3258 * This information is passed to iwconfig later. The peer that joined
3259 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003260
3261 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003263bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3264 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003266 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003268 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3269 if (0 == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003270 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003271 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003272 sta_ctx->conn_info.staId[idx] = sta_id;
3273 qdf_copy_macaddr(
3274 &sta_ctx->conn_info.peerMacAddress[idx],
3275 peer_mac_addr);
3276 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 }
3278 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003279 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280}
3281
3282/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003283 * hdd_delete_peer() - removes peer from hdd station context peer table
3284 * @sta_ctx: pointer to hdd station context
3285 * @sta_id: station ID
3286 *
3287 * Return: None
3288 */
3289void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3290{
3291 int i;
3292
3293 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3294 if (sta_id == sta_ctx->conn_info.staId[i]) {
3295 sta_ctx->conn_info.staId[i] = 0;
3296 return;
3297 }
3298 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003299}
3300
3301/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3303 * @pAdapter: pointer to adapter
3304 * @staId: station id
3305 *
3306 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003307 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 * false otherwise.
3309 */
3310static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3311{
3312 bool fSuccess = false;
3313 int idx = 0;
3314 uint8_t valid_idx = 0;
3315 uint8_t del_idx = 0;
3316 uint8_t empty_slots = 0;
3317 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3318
Naveen Rawatc45d1622016-07-05 12:20:09 -07003319 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3321 pHddStaCtx->conn_info.staId[idx] = 0;
3322
Anurag Chouhanc5548422016-02-24 18:33:27 +05303323 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 peerMacAddress[idx]);
3325
3326 fSuccess = true;
3327
3328 /*
3329 * Note the deleted Index, if its 0 we need special
3330 * handling.
3331 */
3332 del_idx = idx;
3333
3334 empty_slots++;
3335 } else {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003336 if (pHddStaCtx->conn_info.staId[idx] !=
3337 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 valid_idx = idx;
3339 } else {
3340 /* Found an empty slot */
3341 empty_slots++;
3342 }
3343 }
3344 }
3345
Naveen Rawatc45d1622016-07-05 12:20:09 -07003346 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 /* Last peer departed, set the IBSS state appropriately */
3348 pHddStaCtx->conn_info.connState =
3349 eConnectionState_IbssDisconnected;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003350 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 }
3352 /* Find next active staId, to have a valid sta trigger for TL. */
3353 if (fSuccess == true) {
3354 if (del_idx == 0) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003355 if (pHddStaCtx->conn_info.staId[valid_idx] !=
3356 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 pHddStaCtx->conn_info.staId[0] =
3358 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303359 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 peerMacAddress[0],
3361 &pHddStaCtx->conn_info.
3362 peerMacAddress[valid_idx]);
3363
3364 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303365 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 peerMacAddress[valid_idx]);
3367 }
3368 }
3369 }
3370 return fSuccess;
3371}
3372
3373/**
3374 * roam_ibss_connect_handler() - IBSS connection handler
3375 * @pAdapter: pointer to adapter
3376 * @pRoamInfo: pointer to roam info
3377 *
3378 * We update the status of the IBSS to connected in this function.
3379 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303380 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303382static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 tCsrRoamInfo *pRoamInfo)
3384{
3385 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 /*
3387 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3388 * a partner stations).
3389 */
3390 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3391
3392 /* Save the connection info from CSR... */
3393 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3394
3395 /* Send the bssid address to the wext. */
3396 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3397 /* add bss_id to cfg80211 data base */
3398 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3399 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003400 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303402 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 }
3404 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 bss);
3407
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303408 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409}
3410
3411/**
3412 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3413 * @pAdapter: pointer to adapter
3414 * @pRoamInfo: pointer to roam info
3415 * @roamId: roam id
3416 * @roamStatus: roam status
3417 * @roamResult: roam result
3418 *
3419 * This function indicates the Mic failure to the supplicant
3420 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303421 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303423static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3425 tCsrRoamInfo *pRoamInfo,
3426 uint32_t roamId,
3427 eRoamCmdStatus roamStatus,
3428 eCsrRoamResult roamResult)
3429{
3430 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3431
3432 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3433 TKIP_COUNTER_MEASURE_STOPED ==
3434 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3435 struct iw_michaelmicfailure msg;
3436 union iwreq_data wreq;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 memset(&msg, '\0', sizeof(msg));
3439 msg.src_addr.sa_family = ARPHRD_ETHER;
3440 memcpy(msg.src_addr.sa_data,
3441 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3442 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003443 hdd_debug("MIC MAC " MAC_ADDRESS_STR,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003444 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445
3446 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3447 msg.flags = IW_MICFAILURE_GROUP;
3448 else
3449 msg.flags = IW_MICFAILURE_PAIRWISE;
3450 memset(&wreq, 0, sizeof(wreq));
3451 wreq.data.length = sizeof(msg);
3452 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3453 (char *)&msg);
3454 /* inform mic failure to nl80211 */
3455 cfg80211_michael_mic_failure(pAdapter->dev,
3456 pRoamInfo->u.pMICFailureInfo->
3457 taMacAddr,
3458 ((pRoamInfo->u.pMICFailureInfo->
3459 multicast ==
3460 eSIR_TRUE) ?
3461 NL80211_KEYTYPE_GROUP :
3462 NL80211_KEYTYPE_PAIRWISE),
3463 pRoamInfo->u.pMICFailureInfo->
3464 keyId,
3465 pRoamInfo->u.pMICFailureInfo->TSC,
3466 GFP_KERNEL);
3467
3468 }
3469
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303470 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471}
3472
3473/**
3474 * roam_roam_connect_status_update_handler() - IBSS connect status update
3475 * @pAdapter: pointer to adapter
3476 * @pRoamInfo: pointer to roam info
3477 * @roamId: roam id
3478 * @roamStatus: roam status
3479 * @roamResult: roam result
3480 *
3481 * The Ibss connection status is updated regularly here in this function.
3482 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303483 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303485static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3487 tCsrRoamInfo *pRoamInfo,
3488 uint32_t roamId,
3489 eRoamCmdStatus roamStatus,
3490 eCsrRoamResult roamResult)
3491{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003493 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 switch (roamResult) {
3496 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3497 {
3498 hdd_station_ctx_t *pHddStaCtx =
3499 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003500 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003501 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003503 hdd_info("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303504 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3505 MAC_ADDRESS_STR " and stationID= %d",
3506 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3507 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3508 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003510 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3512 pRoamInfo->staId,
3513 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003514 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 break;
3516 }
3517
3518 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3519
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003520 if (hdd_is_key_install_required_for_ibss(encr_type))
3521 pRoamInfo->fAuthRequired = true;
3522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303524 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 pRoamInfo,
3526 pRoamInfo->staId,
3527 &pRoamInfo->peerMac,
3528 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303529 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003530 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303531 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 }
3533 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003534 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3535 if (stainfo == NULL) {
3536 hdd_err("memory allocation for station_info failed");
3537 return QDF_STATUS_E_NOMEM;
3538 }
3539 stainfo->filled = 0;
3540 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541
3542 cfg80211_new_sta(pAdapter->dev,
3543 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003544 stainfo, GFP_KERNEL);
3545 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003547 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 pHddStaCtx->ibss_enc_key.keyDirection =
3549 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303550 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 &pRoamInfo->peerMac);
3552
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003553 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003554 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303556 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3558 (pAdapter),
3559 pAdapter->sessionId,
3560 &pHddStaCtx->ibss_enc_key,
3561 &roamId);
3562
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303563 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003564 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003565 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303566 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 }
3568 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003569 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570 wlan_hdd_netif_queue_control(pAdapter,
3571 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3572 WLAN_CONTROL_PATH);
3573 break;
3574 }
3575
3576 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3577 {
3578
3579 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3580
3581 break;
3582 }
3583 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3584 {
3585 hdd_station_ctx_t *pHddStaCtx =
3586 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3587
3588 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003589 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003591 hdd_info("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303592 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3593 MAC_ADDRESS_STR " and stationID= %d",
3594 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3595 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3596 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597
3598 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3599
3600 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3601 pHddStaCtx->ibss_sta_generation++;
3602
3603 cfg80211_del_sta(pAdapter->dev,
3604 (const u8 *)&pRoamInfo->peerMac.bytes,
3605 GFP_KERNEL);
3606 break;
3607 }
3608 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3609 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003610 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003612 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303614 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 hdd_conn_set_connection_state(pAdapter,
3617 eConnectionState_NotConnected);
3618
3619 /* Send the bssid address to the wext. */
3620 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3621 break;
3622 }
3623 default:
3624 break;
3625
3626 }
3627
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303628 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629}
3630
3631#ifdef FEATURE_WLAN_TDLS
3632/**
3633 * hdd_roam_register_tdlssta() - register new TDLS station
3634 * @pAdapter: pointer to adapter
3635 * @peerMac: pointer to peer MAC address
3636 * @staId: station identifier
3637 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303638 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 *
3640 * Construct the staDesc and register with TL the new STA.
3641 * This is called as part of ADD_STA in the TDLS setup.
3642 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303643 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303645QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303647 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303649 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003651 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003652 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3653 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654
3655 /*
3656 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3657 * be peer MAC, here we are working on direct Link
3658 */
3659 staDesc.sta_id = staId;
3660
3661 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303662 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663
Dhanashri Atre50141c52016-04-07 13:15:29 -07003664 /* Register the vdev transmit and receive functions */
3665 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3666 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003667 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003668 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3669 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003670 pAdapter, &txrx_ops);
3671 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003672
3673 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003674 qdf_status = cdp_peer_register(soc,
3675 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303676 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003677 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303678 qdf_status, qdf_status);
3679 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 }
3681
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303682 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683}
3684
3685/**
3686 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3687 * @pAdapter: pointer to adapter
3688 * @staId: station identifier
3689 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303690 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 */
Nitesh Shah99dd9552017-03-20 19:27:47 +05303692QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303694 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003695 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003696 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3697 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303698 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003699 hdd_err("cdp_clear_peer() failed for staID: %d Status: %d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003700 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303702 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703}
3704
3705/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003706 * hdd_tdls_connection_tracker_update() - update connection tracker state
3707 * @adapter: pointer to adapter
3708 * @roam_info: pointer to roam info
3709 * @hdd_tdls_ctx: tdls context
3710 *
3711 * Return: QDF_STATUS enumeration
3712 */
3713static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3714 tCsrRoamInfo *roam_info,
3715 tdlsCtx_t *hdd_tdls_ctx)
3716{
3717 hddTdlsPeer_t *curr_peer;
3718 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3719
3720 curr_peer = wlan_hdd_tdls_find_peer(adapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303721 roam_info->peerMac.bytes);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003722
3723 if (!curr_peer) {
3724 hdd_err("curr_peer is null");
3725 return QDF_STATUS_E_FAILURE;
3726 }
3727
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003728 if (eTDLS_LINK_CONNECTED ==
3729 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003730 hdd_debug("Received CONNECTION_TRACKER_NOTIFICATION "
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003731 MAC_ADDRESS_STR
3732 " staId: %d, reason: %d",
3733 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3734 roam_info->staId,
3735 roam_info->reasonCode);
3736
3737 if (roam_info->reasonCode ==
3738 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3739 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003740 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3741 roam_info->reasonCode ==
3742 eWMI_TDLS_SCAN_STARTED_EVENT)
3743 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003744 else if (roam_info->reasonCode ==
3745 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3746 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003747 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3748 roam_info->reasonCode ==
3749 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3750 hdd_ctx->enable_tdls_connection_tracker = true;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003751 hdd_debug("hdd_ctx->enable_tdls_connection_tracker %d",
Nitesh Shahc549dd52017-02-23 16:45:44 +05303752 hdd_ctx->enable_tdls_connection_tracker);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003753 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003754 hdd_debug("TDLS not connected, ignore notification, reason: %d",
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003755 roam_info->reasonCode);
3756 }
3757
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003758 return QDF_STATUS_SUCCESS;
3759}
3760
3761
3762
3763
3764/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3766 * @pAdapter: pointer to adapter
3767 * @pRoamInfo: pointer to roam info
3768 * @roamId: roam id
3769 * @roamStatus: roam status
3770 * @roamResult: roam result
3771 *
3772 * HDD interface between SME and TL to ensure TDLS client registration with
3773 * TL in case of new TDLS client is added and deregistration at the time
3774 * TDLS client is deleted.
3775 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303776 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303778static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3780 tCsrRoamInfo *pRoamInfo,
3781 uint32_t roamId,
3782 eRoamCmdStatus roamStatus,
3783 eCsrRoamResult roamResult)
3784{
3785 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303786 tdlsCtx_t *pHddTdlsCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303788 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 uint8_t staIdx;
3790 hddTdlsPeer_t *curr_peer;
3791 uint32_t reason;
3792
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003793 hdd_debug("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794 roamResult ==
3795 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3796 ==
3797 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3798 roamResult ==
3799 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3800 : roamResult ==
3801 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3802 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3803 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3804 roamResult ==
3805 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3806 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3807 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3808 : roamResult ==
3809 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3810 : roamResult ==
3811 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3812 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3813 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3814
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 switch (roamResult) {
3816 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3817 {
3818 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003819 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303821 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822 } else {
3823 /*
3824 * Check if there is available index for this new TDLS
3825 * STA.
3826 */
3827 for (staIdx = 0;
3828 staIdx < pHddCtx->max_num_tdls_sta;
3829 staIdx++) {
3830 if (0 ==
3831 pHddCtx->tdlsConnInfo[staIdx].
3832 staId) {
3833 pHddCtx->tdlsConnInfo[staIdx].
3834 sessionId =
3835 pRoamInfo->sessionId;
3836 pHddCtx->tdlsConnInfo[staIdx].
3837 staId = pRoamInfo->staId;
3838
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003839 hdd_debug("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003841 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003842 staIdx,
3843 pHddCtx->
3844 tdlsConnInfo[staIdx].
3845 staId,
3846 MAC_ADDR_ARRAY
3847 (pRoamInfo->peerMac.bytes));
3848
Anurag Chouhanc5548422016-02-24 18:33:27 +05303849 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 tdlsConnInfo
3851 [staIdx].
3852 peerMac,
3853 &pRoamInfo->
3854 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303855 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 break;
3857 }
3858 }
3859 if (staIdx < pHddCtx->max_num_tdls_sta) {
3860 if (-1 ==
3861 wlan_hdd_tdls_set_sta_id(pAdapter,
3862 pRoamInfo->
3863 peerMac.bytes,
3864 pRoamInfo->
3865 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003866 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303867 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 }
3869
3870 (WLAN_HDD_GET_CTX(pAdapter))->
3871 sta_to_adapter[pRoamInfo->staId] =
3872 pAdapter;
3873 /*
3874 * store the ucast signature,
3875 * if required for further reference.
3876 */
3877
3878 wlan_hdd_tdls_set_signature(pAdapter,
3879 pRoamInfo->
3880 peerMac.bytes,
3881 pRoamInfo->
3882 ucastSig);
3883 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303884 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003885 hdd_debug("no available slot in conn_info. staId: %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886 pRoamInfo->staId);
3887 }
3888 pAdapter->tdlsAddStaStatus = status;
3889 }
3890 complete(&pAdapter->tdls_add_station_comp);
3891 break;
3892 }
3893 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3894 {
3895 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003896 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 pRoamInfo->statusCode);
3898 }
3899 /* store the ucast signature which will be used later when
3900 * registering to TL
3901 */
3902 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3903 complete(&pAdapter->tdls_add_station_comp);
3904 break;
3905 }
3906 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3907 {
3908 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003909 hdd_err("Link Establish Request failed. status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 pRoamInfo->statusCode);
3911 }
3912 complete(&pAdapter->tdls_link_establish_req_comp);
3913 break;
3914 }
3915 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3916 {
3917 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3918 staIdx++) {
3919 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3920 pRoamInfo->sessionId)
3921 && pRoamInfo->staId ==
3922 pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003923 hdd_debug("HDD: del STA IDX = %x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003924 pRoamInfo->staId);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303925 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 curr_peer =
3927 wlan_hdd_tdls_find_peer(pAdapter,
3928 pRoamInfo->
Nitesh Shah90a02e92017-02-01 15:28:03 +05303929 peerMac.bytes);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303930 if (NULL != curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003931 hdd_debug("Current status for peer " MAC_ADDRESS_STR " is %d",
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303932 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3933 curr_peer->link_status);
3934 if (TDLS_IS_CONNECTED(curr_peer)) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303935 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 hdd_roam_deregister_tdlssta
3937 (pAdapter,
3938 pRoamInfo->staId);
3939 wlan_hdd_tdls_decrement_peer_count
3940 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303941 } else if (eTDLS_LINK_CONNECTING ==
3942 curr_peer->link_status) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303943 mutex_unlock(&pHddCtx->tdls_lock);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303944 hdd_roam_deregister_tdlssta
3945 (pAdapter,
3946 pRoamInfo->staId);
Nitesh Shah0bf768f2017-03-31 15:01:37 +05303947 } else
3948 mutex_unlock(&pHddCtx->tdls_lock);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303949 } else
3950 mutex_unlock(&pHddCtx->tdls_lock);
3951
Nitesh Shah99dd9552017-03-20 19:27:47 +05303952 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953 wlan_hdd_tdls_reset_peer(pAdapter,
3954 pRoamInfo->
3955 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05303956 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957
3958 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3959 pHddCtx->tdlsConnInfo[staIdx].
3960 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303961 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962 tdlsConnInfo[staIdx].
3963 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303964 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303965 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966 break;
3967 }
3968 }
3969 complete(&pAdapter->tdls_del_station_comp);
3970 }
3971 break;
3972 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3973 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003974 hdd_debug("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 pRoamInfo->reasonCode);
3976
Nitesh Shahf1f38992017-01-31 16:40:16 +05303977 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 curr_peer =
3979 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303980 pRoamInfo->peerMac.bytes);
Ganesh Kondabattini9c8dc462017-04-19 10:52:54 +05303981
3982 if (!curr_peer) {
3983 mutex_unlock(&pHddCtx->tdls_lock);
3984 hdd_debug("peer doesn't exists");
3985 status = QDF_STATUS_SUCCESS;
3986 break;
3987 }
3988
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05303990 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303991 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3992 curr_peer->peerMac);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303993 mutex_unlock(&pHddCtx->tdls_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303994 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 break;
3996 }
3997 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3998 {
3999 /* 0 staIdx is assigned to AP we dont want to touch that */
4000 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
4001 staIdx++) {
4002 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
4003 pRoamInfo->sessionId)
4004 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004005 hdd_debug("hdd_tdlsStatusUpdate: staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004006 MAC_ADDRESS_STR,
4007 pHddCtx->tdlsConnInfo[staIdx].
4008 staId,
4009 MAC_ADDR_ARRAY(pHddCtx->
4010 tdlsConnInfo
4011 [staIdx].
4012 peerMac.
4013 bytes));
Nitesh Shah99dd9552017-03-20 19:27:47 +05304014 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 wlan_hdd_tdls_reset_peer(pAdapter,
4016 pHddCtx->
4017 tdlsConnInfo
4018 [staIdx].
4019 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304020 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 hdd_roam_deregister_tdlssta(pAdapter,
4022 pHddCtx->
4023 tdlsConnInfo
4024 [staIdx].
4025 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304026 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 sizeof
4028 (smeTdlsPeerStateParams));
4029 smeTdlsPeerStateParams.vdevId =
4030 pHddCtx->tdlsConnInfo[staIdx].
4031 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304032 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 peerMacAddr,
4034 &pHddCtx->
4035 tdlsConnInfo[staIdx].
4036 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304037 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 smeTdlsPeerStateParams.peerState =
4039 eSME_TDLS_PEER_STATE_TEARDOWN;
4040
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004041 hdd_debug("calling sme_update_tdls_peer_state for staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004042 MAC_ADDRESS_STR,
4043 pHddCtx->tdlsConnInfo[staIdx].
4044 staId,
4045 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046 tdlsConnInfo
4047 [staIdx].
4048 peerMac.
4049 bytes));
4050 status =
4051 sme_update_tdls_peer_state(
4052 pHddCtx->hHal,
4053 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304054 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004055 hdd_err("sme_update_tdls_peer_state failed for "
4056 MAC_ADDRESS_STR,
4057 MAC_ADDR_ARRAY
4058 (pHddCtx->
4059 tdlsConnInfo[staIdx].
4060 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 }
4062 wlan_hdd_tdls_decrement_peer_count
4063 (pAdapter);
4064
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304065 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 tdlsConnInfo[staIdx].
4067 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304068 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4070 pHddCtx->tdlsConnInfo[staIdx].
4071 sessionId = 255;
4072
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304073 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 }
4075 }
4076 break;
4077 }
4078 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
4079 {
4080 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07004081 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
4082 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304083 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 break;
4085 }
4086
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004087 if (pHddCtx->tdls_nss_switch_in_progress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004088 hdd_debug("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004089 status = QDF_STATUS_SUCCESS;
4090 break;
4091 }
4092
Nitesh Shah8e866642017-01-31 15:43:31 +05304093 mutex_lock(&pHddCtx->tdls_lock);
4094 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4095 if (!pHddTdlsCtx) {
4096 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004097 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shah8e866642017-01-31 15:43:31 +05304098 roamResult);
4099 status = QDF_STATUS_E_FAILURE;
4100 break;
4101 }
4102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103 curr_peer =
4104 wlan_hdd_tdls_get_peer(pAdapter,
Nitesh Shah379449e2017-01-31 19:11:29 +05304105 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004107 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304108 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 } else {
4110 if (eTDLS_LINK_CONNECTED ==
4111 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004112 hdd_debug("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 } else {
4114 /*
4115 * If external control is enabled then initiate
4116 * TDLS only if forced peer is set otherwise
4117 * ignore should Discover trigger from fw.
4118 */
4119 if (pHddCtx->config->
4120 fTDLSExternalControl
4121 && (false ==
4122 curr_peer->isForcedPeer)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004123 hdd_debug("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304124 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004127 hdd_debug("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Jeff Johnson68755312017-02-10 11:46:55 -08004128 pHddCtx->config->
4129 fTDLSExternalControl,
4130 curr_peer->isForcedPeer,
4131 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05304132 pHddTdlsCtx->curr_candidate = curr_peer;
4133 wlan_hdd_tdls_implicit_send_discovery_request(
4134 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304136 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137 }
Nitesh Shah8e866642017-01-31 15:43:31 +05304138 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139 break;
4140 }
4141
4142 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4143 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304144 mutex_lock(&pHddCtx->tdls_lock);
4145 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4146 if (!pHddTdlsCtx) {
4147 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004148 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304149 roamResult);
4150 status = QDF_STATUS_E_FAILURE;
4151 break;
4152 }
4153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 curr_peer =
4155 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304156 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004158 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304159 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 } else {
4161 if (eTDLS_LINK_CONNECTED ==
4162 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004163 hdd_debug("Received SHOULD_TEARDOWN for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004164 MAC_ADDRESS_STR
4165 " staId: %d, reason: %d",
4166 MAC_ADDR_ARRAY(pRoamInfo->
4167 peerMac.bytes),
4168 pRoamInfo->staId,
4169 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170
4171 if (pRoamInfo->reasonCode ==
4172 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4173 pRoamInfo->reasonCode ==
4174 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4175 pRoamInfo->reasonCode ==
4176 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4177 pRoamInfo->reasonCode ==
4178 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4179 reason =
4180 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4181 } else
4182 reason =
4183 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4184
4185 wlan_hdd_tdls_indicate_teardown
4186 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304187 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304188 hdd_send_wlan_tdls_teardown_event(
4189 eTDLS_TEARDOWN_BSS_DISCONNECT,
4190 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004192 hdd_debug("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004193 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304195 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304197 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 break;
4199 }
4200
4201 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4202 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304203 mutex_lock(&pHddCtx->tdls_lock);
4204 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4205 if (!pHddTdlsCtx) {
4206 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004207 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304208 roamResult);
4209 status = QDF_STATUS_E_FAILURE;
4210 break;
4211 }
4212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 curr_peer =
4214 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304215 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004217 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304218 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219 } else {
4220 if (eTDLS_LINK_CONNECTED ==
4221 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004222 hdd_debug("Received SHOULD_PEER_DISCONNECTED for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004223 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004224 " staId: %d reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004225 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4226 pRoamInfo->staId,
4227 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228
4229 if (pRoamInfo->reasonCode ==
4230 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4231 pRoamInfo->reasonCode ==
4232 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4233 pRoamInfo->reasonCode ==
4234 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4235 pRoamInfo->reasonCode ==
4236 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4237 reason =
4238 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4239 } else
4240 reason =
4241 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4242
4243 wlan_hdd_tdls_indicate_teardown
4244 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304245 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304246 hdd_send_wlan_tdls_teardown_event(
4247 eTDLS_TEARDOWN_BSS_DISCONNECT,
4248 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004250 hdd_debug("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004251 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304253 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304255 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 break;
4257 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004258
4259 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
Nitesh Shahf1f38992017-01-31 16:40:16 +05304260 mutex_lock(&pHddCtx->tdls_lock);
4261 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4262 if (!pHddTdlsCtx) {
4263 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004264 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304265 roamResult);
4266 status = QDF_STATUS_E_FAILURE;
4267 break;
4268 }
4269
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004270 status = hdd_tdls_connection_tracker_update(pAdapter,
4271 pRoamInfo,
4272 pHddTdlsCtx);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304273 mutex_unlock(&pHddCtx->tdls_lock);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004274 break;
4275
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 default:
4277 {
4278 break;
4279 }
4280 }
4281
4282 return status;
4283}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004284#else
4285
Nitesh Shah99dd9552017-03-20 19:27:47 +05304286inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004287 uint8_t staId)
4288{
4289 return QDF_STATUS_SUCCESS;
4290}
4291
4292static inline QDF_STATUS
4293hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4294 tCsrRoamInfo *pRoamInfo,
4295 uint32_t roamId,
4296 eRoamCmdStatus roamStatus,
4297 eCsrRoamResult roamResult)
4298{
4299 return QDF_STATUS_SUCCESS;
4300}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301#endif
4302
4303#ifdef WLAN_FEATURE_11W
4304/**
4305 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4306 * @pAdapter: pointer to the adapter
4307 * @nFrameLength: Length of the unprotected frame being passed
4308 * @pbFrames: Pointer to the frame buffer
4309 * @frameType: 802.11 frame type
4310 *
4311 * This function forwards the unprotected management frame to the supplicant.
4312 *
4313 * Return: nothing
4314 */
4315static void
4316hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4317 uint8_t *pbFrames, uint8_t frameType)
4318{
4319 uint8_t type = 0;
4320 uint8_t subType = 0;
4321
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004322 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004323 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324
4325 /* Sanity Checks */
4326 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004327 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 return;
4329 }
4330
4331 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004332 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 return;
4334 }
4335
4336 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004337 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 return;
4339 }
4340
4341 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004342 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343 return;
4344 }
4345
4346 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004347 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 return;
4349 }
4350
4351 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4352 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4353
4354 /* Get pAdapter from Destination mac address of the frame */
4355 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4356#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4357 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4358 nFrameLength);
4359#else
4360 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4361 nFrameLength);
4362#endif
4363 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4364 } else if (type == SIR_MAC_MGMT_FRAME &&
4365 subType == SIR_MAC_MGMT_DEAUTH) {
4366#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4367 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4368 nFrameLength);
4369#else
4370 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4371 nFrameLength);
4372#endif
4373 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4374 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004375 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004376 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377 return;
4378 }
4379}
4380#endif
4381
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004382#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383/**
4384 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4385 * @pAdapter: pointer to adapter
4386 * @tid: traffic identifier
4387 * @state: state
4388 * @measInterval: measurement interval
4389 *
4390 * This function sends traffic stream metrics IE information to
4391 * the supplicant via wireless event.
4392 *
4393 * Return: none
4394 */
4395static void
4396hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4397 uint8_t state, uint16_t measInterval)
4398{
4399 union iwreq_data wrqu;
4400 char buf[IW_CUSTOM_MAX + 1];
4401 int nBytes = 0;
4402
4403 if (NULL == pAdapter)
4404 return;
4405
4406 /* create the event */
4407 memset(&wrqu, '\0', sizeof(wrqu));
4408 memset(buf, '\0', sizeof(buf));
4409
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004410 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004411 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412
4413 nBytes =
4414 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4415 measInterval);
4416
4417 wrqu.data.pointer = buf;
4418 wrqu.data.length = nBytes;
4419 /* send the event */
4420 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4421}
4422
4423/**
4424 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4425 * @pAdapter: pointer to adapter
4426 * @pRoamInfo: pointer to roam info
4427 *
4428 * This function sends cckm preauth indication to the supplicant
4429 * via wireless custom event.
4430 *
4431 * Return: none
4432 */
4433static void
4434hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4435{
4436 union iwreq_data wrqu;
4437 char buf[IW_CUSTOM_MAX + 1];
4438 char *pos = buf;
4439 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4440
4441 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4442 return;
4443
4444 /* create the event */
4445 memset(&wrqu, '\0', sizeof(wrqu));
4446 memset(buf, '\0', sizeof(buf));
4447
4448 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004449 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004450 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4451 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452
4453 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4454 pos += nBytes;
4455 freeBytes -= nBytes;
4456
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304457 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304458 pos += QDF_MAC_ADDR_SIZE;
4459 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460
4461 nBytes = snprintf(pos, freeBytes, " %u:%u",
4462 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4463 freeBytes -= nBytes;
4464
4465 wrqu.data.pointer = buf;
4466 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4467
4468 /* send the event */
4469 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4470}
4471
4472/**
4473 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4474 * @pAdapter: pointer to adapter
4475 * @pRoamInfo: pointer to roam info
4476 *
4477 * Return: none
4478 */
4479static void
4480hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4481 tCsrRoamInfo *pRoamInfo)
4482{
4483 union iwreq_data wrqu;
4484 char buf[IW_CUSTOM_MAX + 1];
4485 int nBytes = 0;
4486
4487 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4488 return;
4489
4490 /* create the event */
4491 memset(&wrqu, '\0', sizeof(wrqu));
4492 memset(buf, '\0', sizeof(buf));
4493
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004494 hdd_debug("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495
4496 nBytes =
4497 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4498 pRoamInfo->tsmRoamDelay);
4499
4500 wrqu.data.pointer = buf;
4501 wrqu.data.length = nBytes;
4502
4503 /* send the event */
4504 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4505}
4506
4507/**
4508 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4509 * @pAdapter: pointer to adapter
4510 * @measurementToken: measurement token
4511 * @flag: flag
4512 * @numBss: number of bss
4513 *
4514 * If the measurement is none and no scan results found,
4515 * indicate the supplicant about measurement done.
4516 *
4517 * Return: none
4518 */
4519void
4520hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4521 const uint16_t measurementToken,
4522 const bool flag, const uint8_t numBss)
4523{
4524 union iwreq_data wrqu;
4525 char buf[IW_CUSTOM_MAX];
4526 char *pos = buf;
4527 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4528
4529 memset(&wrqu, '\0', sizeof(wrqu));
4530 memset(buf, '\0', sizeof(buf));
4531
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004532 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004533 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534
4535 nBytes =
4536 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4537 flag, numBss);
4538
4539 wrqu.data.pointer = buf;
4540 wrqu.data.length = nBytes;
4541 /* send the event */
4542 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4543}
4544
4545/**
4546 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4547 * @pAdapter: pointer to adapter
4548 * @pRoamInfo: pointer to roam info
4549 *
4550 * If the measurement is none and no scan results found,
4551 * indicate the supplicant about measurement done.
4552 *
4553 * Return: none
4554 */
4555static void
4556hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4557 const tCsrRoamInfo *pRoamInfo)
4558{
4559 union iwreq_data wrqu;
4560 char buf[IW_CUSTOM_MAX];
4561 char *pos = buf;
4562 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4563 uint8_t i = 0, len = 0;
4564 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4565 uint8_t lastSent = 0, sendBss = 0;
4566 int bcnRepFieldSize =
4567 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4568 bcnReportFields);
4569 uint8_t ieLenByte = 1;
4570 /*
4571 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4572 */
4573#define ESEBCNREPHEADER_LEN (18)
4574
4575 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4576 return;
4577
4578 /*
4579 * Custom event can pass maximum of 256 bytes of data,
4580 * based on the IE len we need to identify how many BSS info can
4581 * be filled in to custom event data.
4582 */
4583 /*
4584 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4585 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4586 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4587 */
4588
4589 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4590 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004591 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004593 * indicate the supplicant about measurement done
4594 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 hdd_indicate_ese_bcn_report_no_results(
4596 pAdapter,
4597 pRoamInfo->pEseBcnReportRsp->
4598 measurementToken,
4599 pRoamInfo->pEseBcnReportRsp->flag,
4600 pRoamInfo->pEseBcnReportRsp->numBss);
4601 } else {
4602 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4603 memset(&wrqu, '\0', sizeof(wrqu));
4604 memset(buf, '\0', sizeof(buf));
4605 tot_bcn_ieLen = 0;
4606 sendBss = 0;
4607 pos = buf;
4608 freeBytes = IW_CUSTOM_MAX;
4609
4610 for (i = lastSent;
4611 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4612 len =
4613 bcnRepFieldSize + ieLenByte +
4614 pRoamInfo->pEseBcnReportRsp->
4615 bcnRepBssInfo[i].ieLen;
4616 if ((len + tot_bcn_ieLen) >
4617 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4618 break;
4619 }
4620 tot_bcn_ieLen += len;
4621 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004622 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004623 i, bcnRepFieldSize, 1,
4624 pRoamInfo->pEseBcnReportRsp->
4625 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 }
4627
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004628 hdd_debug("Sending %d BSS Info", sendBss);
4629 hdd_debug("CCXBCNREP=%d %d %d %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004630 pRoamInfo->pEseBcnReportRsp->measurementToken,
4631 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4632 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633
4634 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4635 pRoamInfo->pEseBcnReportRsp->
4636 measurementToken,
4637 pRoamInfo->pEseBcnReportRsp->flag,
4638 sendBss);
4639 pos += nBytes;
4640 freeBytes -= nBytes;
4641
4642 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304643 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 sizeof(tot_bcn_ieLen));
4645 pos += sizeof(tot_bcn_ieLen);
4646 freeBytes -= sizeof(tot_bcn_ieLen);
4647
4648 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004649 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4651 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4652 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4653 pRoamInfo->pEseBcnReportRsp->
4654 bcnRepBssInfo[i +
4655 lastSent].bcnReportFields.
4656 ChanNum,
4657 pRoamInfo->pEseBcnReportRsp->
4658 bcnRepBssInfo[i +
4659 lastSent].bcnReportFields.
4660 Spare,
4661 pRoamInfo->pEseBcnReportRsp->
4662 bcnRepBssInfo[i +
4663 lastSent].bcnReportFields.
4664 MeasDuration,
4665 pRoamInfo->pEseBcnReportRsp->
4666 bcnRepBssInfo[i +
4667 lastSent].bcnReportFields.
4668 PhyType,
4669 pRoamInfo->pEseBcnReportRsp->
4670 bcnRepBssInfo[i +
4671 lastSent].bcnReportFields.
4672 RecvSigPower,
4673 pRoamInfo->pEseBcnReportRsp->
4674 bcnRepBssInfo[i +
4675 lastSent].bcnReportFields.
4676 ParentTsf,
4677 pRoamInfo->pEseBcnReportRsp->
4678 bcnRepBssInfo[i +
4679 lastSent].bcnReportFields.
4680 TargetTsf[0],
4681 pRoamInfo->pEseBcnReportRsp->
4682 bcnRepBssInfo[i +
4683 lastSent].bcnReportFields.
4684 TargetTsf[1],
4685 pRoamInfo->pEseBcnReportRsp->
4686 bcnRepBssInfo[i +
4687 lastSent].bcnReportFields.
4688 BcnInterval,
4689 pRoamInfo->pEseBcnReportRsp->
4690 bcnRepBssInfo[i +
4691 lastSent].bcnReportFields.
4692 CapabilityInfo,
4693 pRoamInfo->pEseBcnReportRsp->
4694 bcnRepBssInfo[i +
4695 lastSent].bcnReportFields.
4696 Bssid[0],
4697 pRoamInfo->pEseBcnReportRsp->
4698 bcnRepBssInfo[i +
4699 lastSent].bcnReportFields.
4700 Bssid[1],
4701 pRoamInfo->pEseBcnReportRsp->
4702 bcnRepBssInfo[i +
4703 lastSent].bcnReportFields.
4704 Bssid[2],
4705 pRoamInfo->pEseBcnReportRsp->
4706 bcnRepBssInfo[i +
4707 lastSent].bcnReportFields.
4708 Bssid[3],
4709 pRoamInfo->pEseBcnReportRsp->
4710 bcnRepBssInfo[i +
4711 lastSent].bcnReportFields.
4712 Bssid[4],
4713 pRoamInfo->pEseBcnReportRsp->
4714 bcnRepBssInfo[i +
4715 lastSent].bcnReportFields.
4716 Bssid[5]);
4717
4718 /* bcn report fields are copied */
4719 len =
4720 sizeof(pRoamInfo->pEseBcnReportRsp->
4721 bcnRepBssInfo[i +
4722 lastSent].
4723 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304724 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725 (char *)&pRoamInfo->
4726 pEseBcnReportRsp->bcnRepBssInfo[i +
4727 lastSent].
4728 bcnReportFields, len);
4729 pos += len;
4730 freeBytes -= len;
4731
4732 /* Add 1 byte of ie len */
4733 len =
4734 pRoamInfo->pEseBcnReportRsp->
4735 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304736 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737 pos += sizeof(len);
4738 freeBytes -= sizeof(len);
4739
4740 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304741 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 (char *)pRoamInfo->
4743 pEseBcnReportRsp->bcnRepBssInfo[i +
4744 lastSent].
4745 pBuf, len);
4746 pos += len;
4747 freeBytes -= len;
4748 }
4749
4750 wrqu.data.pointer = buf;
4751 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4752
4753 /* send the event */
4754 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4755 buf);
4756 lastSent += sendBss;
4757 }
4758 }
4759}
4760
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004761#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762
4763/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304764 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4765 * @pHddStaCtx: Station Context
4766 *
4767 * API to check if the connection authentication type is 8021x_sha256.
4768 *
4769 * Return: bool
4770 */
4771#ifdef WLAN_FEATURE_11W
4772static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4773{
4774 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4775 pHddStaCtx->conn_info.authType;
4776}
4777#else
4778static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4779{
4780 return false;
4781}
4782#endif
4783
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304784/*
4785 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4786 * @adapter: Pointer to adapter context
4787 * @roam_info: Pointer to roam info
4788 *
4789 * Return: None
4790 */
4791static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4792 tCsrRoamInfo *roam_info)
4793{
4794 struct hdd_chan_change_params chan_change;
4795 struct cfg80211_bss *bss;
4796 struct net_device *dev = adapter->dev;
4797 struct wireless_dev *wdev = dev->ieee80211_ptr;
4798 struct wiphy *wiphy = wdev->wiphy;
4799 QDF_STATUS status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004800 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304801
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004802 hdd_debug("channel switch for session:%d to channel:%d",
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304803 adapter->sessionId, roam_info->chan_info.chan_id);
4804
4805 chan_change.chan = roam_info->chan_info.chan_id;
4806 chan_change.chan_params.ch_width =
4807 roam_info->chan_info.ch_width;
4808 chan_change.chan_params.sec_ch_offset =
4809 roam_info->chan_info.sec_ch_offset;
4810 chan_change.chan_params.center_freq_seg0 =
4811 roam_info->chan_info.band_center_freq1;
4812 chan_change.chan_params.center_freq_seg1 =
4813 roam_info->chan_info.band_center_freq2;
4814
4815 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4816 if (NULL == bss)
4817 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4818 else
4819 cfg80211_put_bss(wiphy, bss);
4820
4821 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4822 if (QDF_IS_STATUS_ERROR(status))
4823 hdd_err("channel change notification failed");
4824
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004825 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
4826 adapter->sessionId);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304827 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004828 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304829}
4830
Komal Seelam98760ba2015-12-15 11:05:18 +05304831/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 * hdd_sme_roam_callback() - hdd sme roam callback
4833 * @pContext: pointer to adapter context
4834 * @pRoamInfo: pointer to roam info
4835 * @roamId: roam id
4836 * @roamStatus: roam status
4837 * @roamResult: roam result
4838 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304839 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304841QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4843 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4844{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304845 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4847 hdd_wext_state_t *pWextState = NULL;
4848 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304849 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304850 struct cfg80211_bss *bss_status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004851 hdd_context_t *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004852
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004853 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004854 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855
4856 /* Sanity check */
4857 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004858 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304859 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 }
4861
4862 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4863 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004864 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304866 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4867 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4868 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4869 pAdapter->sessionId, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 switch (roamStatus) {
4872 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304873 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4874 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004875 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876 break;
4877
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 /*
4879 * We did pre-auth,then we attempted a 11r or ese reassoc.
4880 * reassoc failed due to failure, timeout, reject from ap
4881 * in any case tell the OS, our carrier is off and mark
4882 * interface down.
4883 */
4884 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004885 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4886 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304887 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4889 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 pHddStaCtx->ft_carrier_on = false;
4891 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004892 hdd_debug("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004893 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894 break;
4895
4896 case eCSR_ROAM_FT_START:
4897 /*
4898 * When we roam for ESE and 11r, we dont want the OS to be
4899 * informed that the link is down. So mark the link ready for
4900 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4901 * be received. Where in we will not mark the link down
4902 * Also we want to stop tx at this point when we will be
4903 * doing disassoc at this time. This saves 30-60 msec
4904 * after reassoc.
4905 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004906 hdd_info("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004907 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004908 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004909 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304910 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004911 WLAN_CONTROL_PATH);
4912 status = hdd_roam_deregister_sta(pAdapter,
4913 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304914 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304915 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916 pHddStaCtx->ft_carrier_on = true;
4917 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004918 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4919 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004921 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004922 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004923 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004924 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304925 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
4926 pAdapter->roam_ho_fail = true;
4927 else
4928 pAdapter->roam_ho_fail = false;
4929 complete(&pAdapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004930 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004933 hdd_debug("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304935 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938 wlan_hdd_netif_queue_control(pAdapter,
4939 WLAN_NETIF_CARRIER_OFF,
4940 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 break;
4943 case eCSR_ROAM_LOSTLINK:
4944 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004945 hdd_debug("Roaming started due to connection lost");
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004946 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304948 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 WLAN_CONTROL_PATH);
4950 break;
4951 }
4952 case eCSR_ROAM_DISASSOCIATED:
4953 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004954 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304955 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004956 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304957 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304958 pAdapter->roam_ho_fail = false;
4959 complete(&pAdapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304960
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 /* Call to clear any MC Addr List filter applied after
4962 * successful connection.
4963 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304964 hdd_disable_and_flush_mc_addr_list(pAdapter,
4965 pmo_peer_disconnect);
4966 qdf_ret_status =
4967 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4968 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 }
4970 break;
4971 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004972 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304973 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4975 roamStatus, roamResult);
4976 break;
4977 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004978 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 /*
4980 * To Do - address probable memory leak with WEP encryption upon
4981 * successful association.
4982 */
4983 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4984 /* Clear saved connection information in HDD */
4985 hdd_conn_remove_connect_info(
4986 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4987 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304988 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989 hdd_association_completion_handler(pAdapter, pRoamInfo,
4990 roamId, roamStatus,
4991 roamResult);
4992#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4993 if (pRoamInfo)
4994 pRoamInfo->roamSynchInProgress = false;
4995#endif
4996 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004997 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004998 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004999 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305000 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 pRoamInfo,
5002 roamId,
5003 roamStatus,
5004 roamResult);
5005 break;
5006 case eCSR_ROAM_IBSS_IND:
5007 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
5008 roamStatus, roamResult);
5009 break;
5010
5011 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305012 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013 roam_roam_connect_status_update_handler(pAdapter,
5014 pRoamInfo,
5015 roamId,
5016 roamStatus,
5017 roamResult);
5018 break;
5019
5020 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305021 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022 hdd_roam_mic_error_indication_handler(pAdapter,
5023 pRoamInfo,
5024 roamId,
5025 roamStatus,
5026 roamResult);
5027 break;
5028
5029 case eCSR_ROAM_SET_KEY_COMPLETE:
5030 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305031 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
5033 roamId, roamStatus,
5034 roamResult);
5035 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
5036 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005037 hdd_debug("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 pHddStaCtx->hdd_ReassocScenario,
5039 pAdapter->sessionId);
5040 }
5041 }
5042#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5043 if (pRoamInfo != NULL)
5044 pRoamInfo->roamSynchInProgress = false;
5045#endif
5046 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048 case eCSR_ROAM_FT_RESPONSE:
5049 hdd_send_ft_event(pAdapter);
5050 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005051
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005052 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05305053 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
5054 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305056 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005057 wlan_hdd_cfg80211_pmksa_candidate_notify(
5058 pAdapter, pRoamInfo, 1, false);
5059 }
5060 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005061
5062#ifdef FEATURE_WLAN_LFR_METRICS
5063 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
5064 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305065 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005066 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
5067 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305068 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 }
5070 break;
5071 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
5072 /*
5073 * This event will notify pre-auth completion in case of success
5074 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305075 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5077 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305078 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 }
5080 break;
5081 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
5082 /*
5083 * This event will notify pre-auth completion incase of failure.
5084 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305085 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5087 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305088 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005089 }
5090 break;
5091 case eCSR_ROAM_HANDOVER_SUCCESS:
5092 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08005093 * It will be only invoked on success
5094 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305095 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
5097 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305098 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 }
5100 break;
5101#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102 case eCSR_ROAM_REMAIN_CHAN_READY:
5103 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
5104 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105#ifdef FEATURE_WLAN_TDLS
5106 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305107 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005108 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
5109 roamId,
5110 roamStatus,
5111 roamResult);
5112 break;
5113 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
5114 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
5115 pRoamInfo->reasonCode);
5116 break;
5117#endif
5118#ifdef WLAN_FEATURE_11W
5119 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
5120 hdd_indicate_unprot_mgmt_frame(pAdapter,
5121 pRoamInfo->nFrameLength,
5122 pRoamInfo->pbFrames,
5123 pRoamInfo->frameType);
5124 break;
5125#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005126#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 case eCSR_ROAM_TSM_IE_IND:
5128 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
5129 pRoamInfo->tsmIe.state,
5130 pRoamInfo->tsmIe.msmt_interval);
5131 break;
5132
5133 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
5134 {
5135 if (eCSR_AUTH_TYPE_CCKM_WPA ==
5136 pHddStaCtx->conn_info.authType
5137 || eCSR_AUTH_TYPE_CCKM_RSN ==
5138 pHddStaCtx->conn_info.authType) {
5139 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
5140 }
5141 break;
5142 }
5143
5144 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
5145 {
5146 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
5147 break;
5148 }
5149
5150 case eCSR_ROAM_ESE_BCN_REPORT_IND:
5151 {
5152 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
5153 break;
5154 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005155#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305156 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305157 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305158 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305159
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305160 case eCSR_ROAM_UPDATE_SCAN_RESULT:
5161 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
5162 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
5163 pAdapter, pRoamInfo->pBssDesc);
5164 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005165 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305166 else
5167 cfg80211_put_bss(
5168#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5169 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5170#endif
5171 bss_status);
5172 }
5173 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005174 case eCSR_ROAM_NDP_STATUS_UPDATE:
5175 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5176 roamResult);
5177 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005178 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005179 hdd_debug("Process ROAM_START from firmware");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005180 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305181 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005182 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005183 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005184 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005185 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08005186 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005187 break;
5188 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005189 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005190 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005191 wlan_hdd_netif_queue_control(pAdapter,
5192 WLAN_WAKE_ALL_NETIF_QUEUE,
5193 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005194 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005195 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305196 pAdapter->roam_ho_fail = false;
5197 complete(&pAdapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005198 break;
5199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 default:
5201 break;
5202 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305203 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005204}
5205
5206/**
5207 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5208 * @auth_suite: auth suite
5209 *
5210 * Return: eCsrAuthType enumeration
5211 */
5212eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5213{
5214 eCsrAuthType auth_type;
5215 /* is the auth type supported? */
5216 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5217 auth_type = eCSR_AUTH_TYPE_RSN;
5218 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5219 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005220 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221 /* Check for 11r FT Authentication with PSK */
5222 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5223 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5224 /* Check for 11R FT Authentication with 802.1X */
5225 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5226 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227#ifdef FEATURE_WLAN_ESE
5228 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5229 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5230 } else
5231#endif /* FEATURE_WLAN_ESE */
5232#ifdef WLAN_FEATURE_11W
5233 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5234 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5235 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5236 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5237 } else
5238#endif
5239 {
5240 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5241 }
5242 return auth_type;
5243}
5244
5245/**
5246 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5247 * @auth_suite: auth suite
5248 *
5249 * Return: eCsrAuthType enumeration
5250 */
5251eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5252{
5253 eCsrAuthType auth_type;
5254 /* is the auth type supported? */
5255 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5256 auth_type = eCSR_AUTH_TYPE_WPA;
5257 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5258 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5259 } else
5260#ifdef FEATURE_WLAN_ESE
5261 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5262 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5263 } else
5264#endif /* FEATURE_WLAN_ESE */
5265 {
5266 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5267 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005268 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005269 return auth_type;
5270}
5271
5272/**
5273 * hdd_translate_rsn_to_csr_encryption_type() -
5274 * Translate RSN to CSR encryption type
5275 * @cipher_suite: cipher suite
5276 *
5277 * Return: eCsrEncryptionType enumeration
5278 */
5279eCsrEncryptionType
5280hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5281{
5282 eCsrEncryptionType cipher_type;
5283
5284 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5285 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5286 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5287 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5288 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5289 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5290 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5291 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5292 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5293 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5294 else
5295 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5296
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005297 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 return cipher_type;
5299}
5300
5301/**
5302 * hdd_translate_wpa_to_csr_encryption_type() -
5303 * Translate WPA to CSR encryption type
5304 * @cipher_suite: cipher suite
5305 *
5306 * Return: eCsrEncryptionType enumeration
5307 */
5308eCsrEncryptionType
5309hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5310{
5311 eCsrEncryptionType cipher_type;
5312
5313 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5314 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5315 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5316 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5317 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5318 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5319 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5320 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5321 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5322 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5323 else
5324 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5325
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005326 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 return cipher_type;
5328}
5329
5330/**
5331 * hdd_process_genie() - process gen ie
5332 * @pAdapter: pointer to adapter
5333 * @bssid: pointer to mac address
5334 * @pEncryptType: pointer to encryption type
5335 * @mcEncryptType: pointer to multicast encryption type
5336 * @pAuthType: pointer to auth type
5337 *
5338 * Return: 0 on success, error number otherwise
5339 */
5340static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5341 u8 *bssid,
5342 eCsrEncryptionType *pEncryptType,
5343 eCsrEncryptionType *mcEncryptType,
5344 eCsrAuthType *pAuthType,
5345#ifdef WLAN_FEATURE_11W
5346 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5347#endif
5348 uint16_t gen_ie_len, uint8_t *gen_ie)
5349{
5350 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305351 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 tDot11fIERSN dot11RSNIE;
5353 tDot11fIEWPA dot11WPAIE;
5354 uint32_t i;
5355 uint8_t *pRsnIe;
5356 uint16_t RSNIeLen;
5357 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5358 bool updatePMKCache = false;
5359
5360 /*
5361 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5362 * setting present flag to 0.
5363 */
5364 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5365 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5366
5367 /* Type check */
5368 if (gen_ie[0] == DOT11F_EID_RSN) {
5369 /* Validity checks */
5370 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5371 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005372 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005373 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 return -EINVAL;
5375 }
5376 /* Skip past the EID byte and length byte */
5377 pRsnIe = gen_ie + 2;
5378 RSNIeLen = gen_ie_len - 2;
5379 /* Unpack the RSN IE */
5380 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305381 pRsnIe, RSNIeLen, &dot11RSNIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005383 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005384 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005385 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005386 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387 /* dot11RSNIE.akm_suite_count */
5388 /* Just translate the FIRST one */
5389 *pAuthType =
5390 hdd_translate_rsn_to_csr_auth_type(
5391 dot11RSNIE.akm_suites[0]);
5392 /* dot11RSNIE.pwise_cipher_suite_count */
5393 *pEncryptType =
5394 hdd_translate_rsn_to_csr_encryption_type(
5395 dot11RSNIE.pwise_cipher_suites[0]);
5396 /* dot11RSNIE.gp_cipher_suite_count */
5397 *mcEncryptType =
5398 hdd_translate_rsn_to_csr_encryption_type(
5399 dot11RSNIE.gp_cipher_suite);
5400#ifdef WLAN_FEATURE_11W
5401 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5402 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5403#endif
5404 /* Set the PMKSA ID Cache for this interface */
5405 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5406 if (is_zero_ether_addr(bssid)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005407 hdd_warn("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 break;
5409 }
5410 updatePMKCache = true;
5411 /*
5412 * For right now, I assume setASSOCIATE() has passed
5413 * in the bssid.
5414 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305415 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305416 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305417 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5419 }
5420
5421 if (updatePMKCache) {
5422 /*
5423 * Calling csr_roam_set_pmkid_cache to configure the
5424 * PMKIDs into the cache.
5425 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005426 hdd_debug("Calling sme_roam_set_pmkid_cache with cache entry %d.",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005427 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 /* Finally set the PMKSA ID Cache in CSR */
5429 result =
5430 sme_roam_set_pmkid_cache(halHandle,
5431 pAdapter->sessionId,
5432 PMKIDCache,
5433 dot11RSNIE.pmkid_count,
5434 false);
5435 }
5436 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5437 /* Validity checks */
5438 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5439 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005440 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005441 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442 return -EINVAL;
5443 }
5444 /* Skip past the EID and length byte - and four byte WiFi OUI */
5445 pRsnIe = gen_ie + 2 + 4;
5446 RSNIeLen = gen_ie_len - (2 + 4);
5447 /* Unpack the WPA IE */
5448 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305449 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005451 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005452 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005453 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005454 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 /* dot11WPAIE.auth_suite_count */
5456 /* Just translate the FIRST one */
5457 *pAuthType =
5458 hdd_translate_wpa_to_csr_auth_type(
5459 dot11WPAIE.auth_suites[0]);
5460 /* dot11WPAIE.unicast_cipher_count */
5461 *pEncryptType =
5462 hdd_translate_wpa_to_csr_encryption_type(
5463 dot11WPAIE.unicast_ciphers[0]);
5464 /* dot11WPAIE.unicast_cipher_count */
5465 *mcEncryptType =
5466 hdd_translate_wpa_to_csr_encryption_type(
5467 dot11WPAIE.multicast_cipher);
5468 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005469 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005470 return -EINVAL;
5471 }
5472 return 0;
5473}
5474
5475/**
5476 * hdd_set_genie_to_csr() - set genie to csr
5477 * @pAdapter: pointer to adapter
5478 * @RSNAuthType: pointer to auth type
5479 *
5480 * Return: 0 on success, error number otherwise
5481 */
5482int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5483{
5484 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5485 uint32_t status = 0;
5486 eCsrEncryptionType RSNEncryptType;
5487 eCsrEncryptionType mcRSNEncryptType;
5488#ifdef WLAN_FEATURE_11W
5489 uint8_t RSNMfpRequired = 0;
5490 uint8_t RSNMfpCapable = 0;
5491#endif
5492 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5493 /* MAC address of assoc peer */
5494 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305495 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496 pWextState->roamProfile.BSSIDs.bssid,
5497 sizeof(bssid));
5498 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5499 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5500 /* continue */
5501 } else {
5502 return 0;
5503 }
5504 /* The actual processing may eventually be more extensive than this. */
5505 /* Right now, just consume any PMKIDs that are sent in by the app. */
5506 status = hdd_process_genie(pAdapter, bssid,
5507 &RSNEncryptType,
5508 &mcRSNEncryptType, RSNAuthType,
5509#ifdef WLAN_FEATURE_11W
5510 &RSNMfpRequired, &RSNMfpCapable,
5511#endif
5512 pWextState->WPARSNIE[1] + 2,
5513 pWextState->WPARSNIE);
5514 if (status == 0) {
5515 /*
5516 * Now copy over all the security attributes
5517 * you have parsed out.
5518 */
5519 pWextState->roamProfile.EncryptionType.numEntries = 1;
5520 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5521
5522 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5523 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5524 mcRSNEncryptType;
5525
Krunal Sonibe766b02016-03-10 13:00:44 -08005526 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5528 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5529 /*
5530 * For wpa none supplicant sends the WPA IE with unicast
5531 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5532 * multicast cipher as either AES/TKIP based on group
5533 * cipher configuration mentioned in the
5534 * wpa_supplicant.conf.
5535 */
5536
5537 /* Set the unicast cipher same as multicast cipher */
5538 pWextState->roamProfile.EncryptionType.encryptionType[0]
5539 = mcRSNEncryptType;
5540 }
5541#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005542 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005543 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5545 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5546#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005547 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005548 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 }
5550 return 0;
5551}
5552
5553/**
5554 * hdd_set_csr_auth_type() - set csr auth type
5555 * @pAdapter: pointer to adapter
5556 * @RSNAuthType: auth type
5557 *
5558 * Return: 0 on success, error number otherwise
5559 */
5560int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5561{
5562 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5563 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5564 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565
5566 pRoamProfile->AuthType.numEntries = 1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005567 hdd_debug("pHddStaCtx->conn_info.authType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005568 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569
5570 switch (pHddStaCtx->conn_info.authType) {
5571 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5572#ifdef FEATURE_WLAN_ESE
5573 case eCSR_AUTH_TYPE_CCKM_WPA:
5574 case eCSR_AUTH_TYPE_CCKM_RSN:
5575#endif
5576 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5577
5578 pRoamProfile->AuthType.authType[0] =
5579 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5580 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5581
5582#ifdef FEATURE_WLAN_ESE
5583 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5584 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5585 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005586 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 pRoamProfile->AuthType.authType[0] =
5588 eCSR_AUTH_TYPE_CCKM_WPA;
5589 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005590 hdd_debug("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005591 pRoamProfile->AuthType.authType[0] =
5592 eCSR_AUTH_TYPE_CCKM_WPA;
5593 } else
5594#endif
5595 if ((pWextState->
5596 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5597 == IW_AUTH_KEY_MGMT_802_1X) {
5598 pRoamProfile->AuthType.authType[0] =
5599 eCSR_AUTH_TYPE_WPA;
5600 } else
5601 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5602 == IW_AUTH_KEY_MGMT_PSK) {
5603 pRoamProfile->AuthType.authType[0] =
5604 eCSR_AUTH_TYPE_WPA_PSK;
5605 } else {
5606 pRoamProfile->AuthType.authType[0] =
5607 eCSR_AUTH_TYPE_WPA_NONE;
5608 }
5609 }
5610 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5611#ifdef FEATURE_WLAN_ESE
5612 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5613 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5614 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005615 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 pRoamProfile->AuthType.authType[0] =
5617 eCSR_AUTH_TYPE_CCKM_RSN;
5618 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005619 hdd_debug("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 pRoamProfile->AuthType.authType[0] =
5621 eCSR_AUTH_TYPE_CCKM_RSN;
5622 } else
5623#endif
5624
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005625 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5626 ((pWextState->
5627 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5628 == IW_AUTH_KEY_MGMT_802_1X)) {
5629 pRoamProfile->AuthType.authType[0] =
5630 eCSR_AUTH_TYPE_FT_RSN;
5631 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5632 &&
5633 ((pWextState->
5634 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5635 == IW_AUTH_KEY_MGMT_PSK)) {
5636 pRoamProfile->AuthType.authType[0] =
5637 eCSR_AUTH_TYPE_FT_RSN_PSK;
5638 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639
5640#ifdef WLAN_FEATURE_11W
5641 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5642 pRoamProfile->AuthType.authType[0] =
5643 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5644 } else if (RSNAuthType ==
5645 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5646 pRoamProfile->AuthType.authType[0] =
5647 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5648 } else
5649#endif
5650
5651 if ((pWextState->
5652 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5653 == IW_AUTH_KEY_MGMT_802_1X) {
5654 pRoamProfile->AuthType.authType[0] =
5655 eCSR_AUTH_TYPE_RSN;
5656 } else
5657 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5658 == IW_AUTH_KEY_MGMT_PSK) {
5659 pRoamProfile->AuthType.authType[0] =
5660 eCSR_AUTH_TYPE_RSN_PSK;
5661 } else {
5662 pRoamProfile->AuthType.authType[0] =
5663 eCSR_AUTH_TYPE_UNKNOWN;
5664 }
5665 }
5666 break;
5667
5668 case eCSR_AUTH_TYPE_SHARED_KEY:
5669
5670 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5671 break;
5672 default:
5673
5674#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005675 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005676#endif /* FEATURE_WLAN_ESE */
5677 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5678 break;
5679 }
5680
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005681 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005682 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684 return 0;
5685}
5686
5687/**
5688 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5689 * to the CSR roam profile.
5690 *
5691 * @dev: Pointer to the net device.
5692 * @info: Pointer to the iw_request_info.
5693 * @wrqu: Pointer to the iwreq_data.
5694 * @extra: Pointer to the data.
5695 *
5696 * Return: 0 for success, error number on failure
5697 */
5698static int __iw_set_essid(struct net_device *dev,
5699 struct iw_request_info *info,
5700 union iwreq_data *wrqu, char *extra)
5701{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 uint32_t status = 0;
5703 hdd_wext_state_t *pWextState;
5704 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5705 hdd_context_t *hdd_ctx;
5706 uint32_t roamId;
5707 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005708 eCsrAuthType RSNAuthType;
5709 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710 int ret;
5711
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005712 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713
5714 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5715 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305716 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005717 return ret;
5718
Jeff Johnson441e1f72017-02-07 08:50:49 -08005719 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5720 if (0 != ret)
5721 return ret;
5722
Krunal Sonibe766b02016-03-10 13:00:44 -08005723 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005724 pAdapter->device_mode != QDF_IBSS_MODE &&
5725 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005726 hdd_warn("device mode %s(%d) is not allowed",
5727 hdd_device_mode_to_string(pAdapter->device_mode),
5728 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 return -EINVAL;
5730 }
5731
5732 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5733
5734 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005735 hdd_warn("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 return -EBUSY;
5737 }
5738 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5739 return -EINVAL;
5740
5741 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305742 /*Try disconnecting if already in connected state*/
5743 status = wlan_hdd_try_disconnect(pAdapter);
5744 if (0 > status) {
5745 hdd_err("Failed to disconnect the existing connection");
5746 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 }
5748
5749 /*
5750 * when cfg80211 defined, wpa_supplicant wext driver uses
5751 * zero-length, null-string ssid for force disconnection.
5752 * after disconnection (if previously connected) and cleaning ssid,
5753 * driver MUST return success.
5754 */
5755 if (0 == wrqu->essid.length)
5756 return 0;
5757
5758 status = hdd_wmm_get_uapsd_mask(pAdapter,
5759 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305760 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761 pWextState->roamProfile.uapsd_mask = 0;
5762
5763 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5764
5765 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5766 wrqu->essid.length;
5767
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305768 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005769 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305770 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 ssId), extra, wrqu->essid.length);
5772 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5773 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5774
5775 /* set gen ie */
5776 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5777
5778 /* set auth */
5779 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5780 }
5781#ifdef FEATURE_WLAN_WAPI
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005782 hdd_debug("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 if (pAdapter->wapi_info.nWapiMode) {
5784 switch (pAdapter->wapi_info.wapiAuthMode) {
5785 case WAPI_AUTH_MODE_PSK:
5786 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005787 hdd_debug("WAPI AUTH TYPE: PSK: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005788 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789 pRoamProfile->AuthType.numEntries = 1;
5790 pRoamProfile->AuthType.authType[0] =
5791 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5792 break;
5793 }
5794 case WAPI_AUTH_MODE_CERT:
5795 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005796 hdd_debug("WAPI AUTH TYPE: CERT: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005797 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005798 pRoamProfile->AuthType.numEntries = 1;
5799 pRoamProfile->AuthType.authType[0] =
5800 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5801 break;
5802 }
5803 } /* End of switch */
5804 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5805 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005806 hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005807 pRoamProfile->EncryptionType.numEntries = 1;
5808 pRoamProfile->EncryptionType.encryptionType[0] =
5809 eCSR_ENCRYPT_TYPE_WPI;
5810 pRoamProfile->mcEncryptionType.numEntries = 1;
5811 pRoamProfile->mcEncryptionType.encryptionType[0] =
5812 eCSR_ENCRYPT_TYPE_WPI;
5813 }
5814 }
5815#endif /* FEATURE_WLAN_WAPI */
5816 /* if previous genIE is not NULL, update AssocIE */
5817 if (0 != pWextState->genIE.length) {
5818 memset(&pWextState->assocAddIE, 0,
5819 sizeof(pWextState->assocAddIE));
5820 memcpy(pWextState->assocAddIE.addIEdata,
5821 pWextState->genIE.addIEdata, pWextState->genIE.length);
5822 pWextState->assocAddIE.length = pWextState->genIE.length;
5823 pWextState->roamProfile.pAddIEAssoc =
5824 pWextState->assocAddIE.addIEdata;
5825 pWextState->roamProfile.nAddIEAssocLength =
5826 pWextState->assocAddIE.length;
5827
5828 /* clear previous genIE after use it */
5829 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5830 }
5831
5832 /*
5833 * Assumes it is not WPS Association by default, except when
5834 * pAddIEAssoc has WPS IE.
5835 */
5836 pWextState->roamProfile.bWPSAssociation = false;
5837
5838 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5839 pWextState->roamProfile.
5840 nAddIEAssocLength))
5841 pWextState->roamProfile.bWPSAssociation = true;
5842
5843 /* Disable auto BMPS entry by PMC until DHCP is done */
5844 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5845 true);
5846
5847 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5848
5849 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005850 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005851 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005852 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5853 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005854 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005855
Agrawal Ashish6b015762016-05-05 11:22:18 +05305856 /*
5857 * Change conn_state to connecting before sme_roam_connect(),
5858 * because sme_roam_connect() has a direct path to call
5859 * hdd_sme_roam_callback(), which will change the conn_state
5860 * If direct path, conn_state will be accordingly changed to
5861 * NotConnected or Associated by either
5862 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5863 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5864 * Connecting state will remain until it is completed.
5865 *
5866 * If connection state is not changed,
5867 * connection state will remain in eConnectionState_NotConnected state.
5868 * In hdd_association_completion_handler, "hddDisconInProgress" is
5869 * set to true if conn state is eConnectionState_NotConnected.
5870 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5871 * informed of connect result indication which is an issue.
5872 */
5873 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305874 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305875 hdd_conn_set_connection_state(pAdapter,
5876 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305877
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 status = sme_roam_connect(hHal, pAdapter->sessionId,
5879 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305880 if ((QDF_STATUS_SUCCESS != status) &&
5881 (QDF_STA_MODE == pAdapter->device_mode ||
5882 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005883 hdd_err("sme_roam_connect failed session_id: %d status %d -> NotConnected",
Agrawal Ashish6b015762016-05-05 11:22:18 +05305884 pAdapter->sessionId, status);
5885 /* change back to NotAssociated */
5886 hdd_conn_set_connection_state(pAdapter,
5887 eConnectionState_NotConnected);
5888 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 pRoamProfile->ChannelInfo.ChannelList = NULL;
5890 pRoamProfile->ChannelInfo.numOfChannels = 0;
5891
5892 EXIT();
5893 return status;
5894}
5895
5896/**
5897 * iw_set_essid() - set essid handler function
5898 * @dev: Pointer to the net device.
5899 * @info: Pointer to the iw_request_info.
5900 * @wrqu: Pointer to the iwreq_data.
5901 * @extra: Pointer to the data.
5902 *
5903 * Return: 0 for success, error number on failure
5904 */
5905int iw_set_essid(struct net_device *dev,
5906 struct iw_request_info *info,
5907 union iwreq_data *wrqu, char *extra)
5908{
5909 int ret;
5910
5911 cds_ssr_protect(__func__);
5912 ret = __iw_set_essid(dev, info, wrqu, extra);
5913 cds_ssr_unprotect(__func__);
5914
5915 return ret;
5916}
5917
5918/**
5919 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5920 * @dev: pointer to the net device
5921 * @info: pointer to the iw request info
5922 * @dwrq: pointer to iw_point
5923 * @extra: pointer to the data
5924 *
5925 * Return: 0 on success, error number otherwise
5926 */
5927static int __iw_get_essid(struct net_device *dev,
5928 struct iw_request_info *info,
5929 struct iw_point *dwrq, char *extra)
5930{
5931 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5932 hdd_context_t *hdd_ctx;
5933 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5934 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5935 int ret;
5936
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005937 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938
5939 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5940 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305941 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 return ret;
5943
Jeff Johnson441e1f72017-02-07 08:50:49 -08005944 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5945 if (0 != ret)
5946 return ret;
5947
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5949 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5950 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5951 || pHddStaCtx->conn_info.connState ==
5952 eConnectionState_IbssDisconnected)
5953 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5954 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5955 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5956 dwrq->length);
5957 dwrq->flags = 1;
5958 } else {
5959 memset(extra, 0, dwrq->length);
5960 dwrq->length = 0;
5961 dwrq->flags = 0;
5962 }
5963 EXIT();
5964 return 0;
5965}
5966
5967/**
5968 * iw_get_essid() - get essid handler function
5969 * @dev: Pointer to the net device.
5970 * @info: Pointer to the iw_request_info.
5971 * @wrqu: Pointer to the iwreq_data.
5972 * @extra: Pointer to the data.
5973 *
5974 * Return: 0 for success, error number on failure
5975 */
5976int iw_get_essid(struct net_device *dev,
5977 struct iw_request_info *info,
5978 struct iw_point *wrqu, char *extra)
5979{
5980 int ret;
5981
5982 cds_ssr_protect(__func__);
5983 ret = __iw_get_essid(dev, info, wrqu, extra);
5984 cds_ssr_unprotect(__func__);
5985
5986 return ret;
5987}
5988
5989/**
5990 * __iw_set_auth() -
5991 * This function sets the auth type received from the wpa_supplicant
5992 * @dev: pointer to the net device
5993 * @info: pointer to the iw request info
5994 * @wrqu: pointer to iwreq_data
5995 * @extra: pointer to the data
5996 *
5997 * Return: 0 on success, error number otherwise
5998 */
5999static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6000 union iwreq_data *wrqu, char *extra)
6001{
6002 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6003 hdd_context_t *hdd_ctx;
6004 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6005 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6006 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6007 eCsrEncryptionType mcEncryptionType;
6008 eCsrEncryptionType ucEncryptionType;
6009 int ret;
6010
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006011 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012
6013 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6014 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306015 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 return ret;
6017
Jeff Johnson441e1f72017-02-07 08:50:49 -08006018 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6019 if (0 != ret)
6020 return ret;
6021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022 switch (wrqu->param.flags & IW_AUTH_INDEX) {
6023 case IW_AUTH_WPA_VERSION:
6024 pWextState->wpaVersion = wrqu->param.value;
6025 break;
6026
6027 case IW_AUTH_CIPHER_PAIRWISE:
6028 {
6029 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6030 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6031 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6032 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6033 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6034 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6035 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6036 if ((IW_AUTH_KEY_MGMT_802_1X
6037 ==
6038 (pWextState->
6039 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6040 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6041 pHddStaCtx->conn_info.authType))
6042 /*Dynamic WEP key */
6043 ucEncryptionType =
6044 eCSR_ENCRYPT_TYPE_WEP40;
6045 else
6046 /*Static WEP key */
6047 ucEncryptionType =
6048 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6049 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6050 if ((IW_AUTH_KEY_MGMT_802_1X
6051 ==
6052 (pWextState->
6053 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6054 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6055 pHddStaCtx->conn_info.authType))
6056 /*Dynamic WEP key */
6057 ucEncryptionType =
6058 eCSR_ENCRYPT_TYPE_WEP104;
6059 else
6060 /*Static WEP key */
6061 ucEncryptionType =
6062 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6063 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006064 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
6065 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066 return -EINVAL;
6067 }
6068
6069 pRoamProfile->EncryptionType.numEntries = 1;
6070 pRoamProfile->EncryptionType.encryptionType[0] =
6071 ucEncryptionType;
6072 }
6073 break;
6074 case IW_AUTH_CIPHER_GROUP:
6075 {
6076 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6077 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6078 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6079 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6080 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6081 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6082 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6083 if ((IW_AUTH_KEY_MGMT_802_1X
6084 ==
6085 (pWextState->
6086 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6087 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6088 pHddStaCtx->conn_info.authType))
6089 mcEncryptionType =
6090 eCSR_ENCRYPT_TYPE_WEP40;
6091 else
6092 mcEncryptionType =
6093 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6094 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6095 /* Dynamic WEP keys won't work with shared keys */
6096 if ((IW_AUTH_KEY_MGMT_802_1X
6097 ==
6098 (pWextState->
6099 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6100 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6101 pHddStaCtx->conn_info.authType)) {
6102 mcEncryptionType =
6103 eCSR_ENCRYPT_TYPE_WEP104;
6104 } else {
6105 mcEncryptionType =
6106 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6107 }
6108 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006109 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110 wrqu->param.value);
6111 return -EINVAL;
6112 }
6113
6114 pRoamProfile->mcEncryptionType.numEntries = 1;
6115 pRoamProfile->mcEncryptionType.encryptionType[0] =
6116 mcEncryptionType;
6117 }
6118 break;
6119
6120 case IW_AUTH_80211_AUTH_ALG:
6121 {
Jeff Johnson5a062372017-01-12 09:51:25 -08006122 /* Save the auth algo here and set auth type to SME
6123 * Roam profile in the iw_set_ap_address
6124 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006125 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
6126 pHddStaCtx->conn_info.authType =
6127 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6128
6129 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
6130 pHddStaCtx->conn_info.authType =
6131 eCSR_AUTH_TYPE_SHARED_KEY;
6132
6133 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
6134 /*Not supported */
6135 pHddStaCtx->conn_info.authType =
6136 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6137 pWextState->roamProfile.AuthType.authType[0] =
6138 pHddStaCtx->conn_info.authType;
6139 }
6140 break;
6141
6142 case IW_AUTH_KEY_MGMT:
6143 {
6144#ifdef FEATURE_WLAN_ESE
6145#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
6146 /*Check for CCKM AKM type */
6147 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006148 hdd_debug("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149 /* Set the CCKM bit in authKeyMgmt */
6150 /*
6151 * Right now, this breaks all ref to authKeyMgmt because
6152 * our code doesn't realize it is a "bitfield"
6153 */
6154 pWextState->authKeyMgmt |=
6155 IW_AUTH_KEY_MGMT_CCKM;
6156 /* Set the key management to 802.1X */
6157 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
6158 pWextState->isESEConnection = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006159 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
6160 /* Save the key management */
6161 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08006162 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 /* Save the key management anyway */
6164 pWextState->authKeyMgmt = wrqu->param.value;
6165 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6166 /* Save the key management */
6167 pWextState->authKeyMgmt |=
6168 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 }
6170#else
6171 /* Save the key management */
6172 pWextState->authKeyMgmt = wrqu->param.value;
6173#endif /* FEATURE_WLAN_ESE */
6174 }
6175 break;
6176
6177 case IW_AUTH_TKIP_COUNTERMEASURES:
6178 {
6179 if (wrqu->param.value) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006180 hdd_debug("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181 wrqu->param.value);
6182 pWextState->mTKIPCounterMeasures =
6183 TKIP_COUNTER_MEASURE_STARTED;
6184 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006185 hdd_debug("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 wrqu->param.value);
6187 pWextState->mTKIPCounterMeasures =
6188 TKIP_COUNTER_MEASURE_STOPED;
6189 }
6190 }
6191 break;
6192 case IW_AUTH_DROP_UNENCRYPTED:
6193 case IW_AUTH_WPA_ENABLED:
6194 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6195 case IW_AUTH_ROAMING_CONTROL:
6196 case IW_AUTH_PRIVACY_INVOKED:
6197
6198 default:
6199
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006200 hdd_warn("called with unsupported auth type %d",
6201 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006202 break;
6203 }
6204
6205 EXIT();
6206 return 0;
6207}
6208
6209/**
6210 * iw_set_auth() - set auth callback function
6211 * @dev: Pointer to the net device.
6212 * @info: Pointer to the iw_request_info.
6213 * @wrqu: Pointer to the iwreq_data.
6214 * @extra: Pointer to the data.
6215 *
6216 * Return: 0 for success, error number on failure.
6217 */
6218int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6219 union iwreq_data *wrqu, char *extra)
6220{
6221 int ret;
6222
6223 cds_ssr_protect(__func__);
6224 ret = __iw_set_auth(dev, info, wrqu, extra);
6225 cds_ssr_unprotect(__func__);
6226
6227 return ret;
6228}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006229/**
6230 * __iw_get_auth() -
6231 * This function returns the auth type to the wpa_supplicant
6232 * @dev: pointer to the net device
6233 * @info: pointer to the iw request info
6234 * @wrqu: pointer to iwreq_data
6235 * @extra: pointer to the data
6236 *
6237 * Return: 0 on success, error number otherwise
6238 */
6239static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6240 union iwreq_data *wrqu, char *extra)
6241{
6242 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6243 hdd_context_t *hdd_ctx;
6244 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6245 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6246 int ret;
6247
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006248 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249
6250 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6251 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306252 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006253 return ret;
6254
Jeff Johnson441e1f72017-02-07 08:50:49 -08006255 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6256 if (0 != ret)
6257 return ret;
6258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006259 switch (pRoamProfile->negotiatedAuthType) {
6260 case eCSR_AUTH_TYPE_WPA_NONE:
6261 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6262 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6263 break;
6264 case eCSR_AUTH_TYPE_WPA:
6265 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6266 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6267 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006269 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 case eCSR_AUTH_TYPE_RSN:
6271 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6272 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6273 break;
6274 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6275 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6276 break;
6277 case eCSR_AUTH_TYPE_SHARED_KEY:
6278 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6279 break;
6280 case eCSR_AUTH_TYPE_UNKNOWN:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006281 hdd_debug("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6283 break;
6284 case eCSR_AUTH_TYPE_AUTOSWITCH:
6285 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6286 break;
6287 case eCSR_AUTH_TYPE_WPA_PSK:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006288 hdd_debug("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006289 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6290 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006293 case eCSR_AUTH_TYPE_RSN_PSK:
6294#ifdef WLAN_FEATURE_11W
6295 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6296 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6297#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006298 hdd_debug("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006299 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6300 return -EIO;
6301 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006302 hdd_warn("Unknown auth type: %d",
6303 pRoamProfile->negotiatedAuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006304 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6305 return -EIO;
6306 }
6307 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6308 switch (pRoamProfile->negotiatedUCEncryptionType) {
6309 case eCSR_ENCRYPT_TYPE_NONE:
6310 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6311 break;
6312 case eCSR_ENCRYPT_TYPE_WEP40:
6313 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6314 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6315 break;
6316 case eCSR_ENCRYPT_TYPE_TKIP:
6317 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6318 break;
6319 case eCSR_ENCRYPT_TYPE_WEP104:
6320 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6321 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6322 break;
6323 case eCSR_ENCRYPT_TYPE_AES:
6324 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6325 break;
6326 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006327 hdd_warn("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006328 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006329 return -EIO;
6330 }
6331 }
6332
6333 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6334 switch (pRoamProfile->negotiatedMCEncryptionType) {
6335 case eCSR_ENCRYPT_TYPE_NONE:
6336 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6337 break;
6338 case eCSR_ENCRYPT_TYPE_WEP40:
6339 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6340 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6341 break;
6342 case eCSR_ENCRYPT_TYPE_TKIP:
6343 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6344 break;
6345 case eCSR_ENCRYPT_TYPE_WEP104:
6346 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6347 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6348 break;
6349 case eCSR_ENCRYPT_TYPE_AES:
6350 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6351 break;
6352 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006353 hdd_err("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006354 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006355 return -EIO;
6356 }
6357 }
6358
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006359 hdd_debug("called with auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006360 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006361 EXIT();
6362 return 0;
6363}
6364
6365/**
6366 * iw_get_auth() - get auth callback function
6367 * @dev: Pointer to the net device.
6368 * @info: Pointer to the iw_request_info.
6369 * @wrqu: Pointer to the iwreq_data.
6370 * @extra: Pointer to the data.
6371 *
6372 * Return: 0 for success, error number on failure.
6373 */
6374int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6375 union iwreq_data *wrqu, char *extra)
6376{
6377 int ret;
6378
6379 cds_ssr_protect(__func__);
6380 ret = __iw_get_auth(dev, info, wrqu, extra);
6381 cds_ssr_unprotect(__func__);
6382
6383 return ret;
6384}
6385
6386/**
6387 * __iw_set_ap_address() - set ap address
6388 * @dev: pointer to the net device
6389 * @info: pointer to the iw request info
6390 * @wrqu: pointer to iwreq_data
6391 * @extra: pointer to the data
6392 *
6393 * This function updates the HDD global station context connection info
6394 * BSSID with the MAC address received from the wpa_supplicant.
6395 *
6396 * Return: 0 on success, error number otherwise
6397 */
6398static int __iw_set_ap_address(struct net_device *dev,
6399 struct iw_request_info *info,
6400 union iwreq_data *wrqu, char *extra)
6401{
6402
6403 hdd_adapter_t *adapter;
6404 hdd_context_t *hdd_ctx;
6405 hdd_station_ctx_t *pHddStaCtx =
6406 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6407 uint8_t *pMacAddress = NULL;
6408 int ret;
6409
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006410 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006411
6412 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6413
6414 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6415 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306416 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006417 return ret;
6418
Jeff Johnson441e1f72017-02-07 08:50:49 -08006419 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6420 if (0 != ret)
6421 return ret;
6422
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006423 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006424 hdd_debug(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306425 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306426 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006427 EXIT();
6428
6429 return 0;
6430}
6431
6432/**
6433 * iw_set_ap_address() - set ap addresses callback function
6434 * @dev: Pointer to the net device.
6435 * @info: Pointer to the iw_request_info.
6436 * @wrqu: Pointer to the iwreq_data.
6437 * @extra: Pointer to the data.
6438 *
6439 * Return: 0 for success, error number on failure.
6440 */
6441int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6442 union iwreq_data *wrqu, char *extra)
6443{
6444 int ret;
6445
6446 cds_ssr_protect(__func__);
6447 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6448 cds_ssr_unprotect(__func__);
6449
6450 return ret;
6451}
6452
6453/**
6454 * __iw_get_ap_address() - get ap address
6455 * @dev: pointer to the net device
6456 * @info: pointer to the iw request info
6457 * @wrqu: pointer to iwreq_data
6458 * @extra: pointer to the data
6459 *
6460 * This function returns currently associated BSSID.
6461 *
6462 * Return: 0 on success, error number otherwise
6463 */
6464static int __iw_get_ap_address(struct net_device *dev,
6465 struct iw_request_info *info,
6466 union iwreq_data *wrqu, char *extra)
6467{
6468 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6469 hdd_context_t *hdd_ctx;
6470 hdd_station_ctx_t *pHddStaCtx =
6471 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6472 int ret;
6473
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006474 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006475
6476 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6477 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306478 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479 return ret;
6480
Jeff Johnson441e1f72017-02-07 08:50:49 -08006481 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6482 if (0 != ret)
6483 return ret;
6484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006485 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6486 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306487 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006488 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306489 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006490 } else {
6491 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6492 }
6493 EXIT();
6494 return 0;
6495}
6496
6497/**
6498 * iw_get_ap_address() - get ap addresses callback function
6499 * @dev: Pointer to the net device.
6500 * @info: Pointer to the iw_request_info.
6501 * @wrqu: Pointer to the iwreq_data.
6502 * @extra: Pointer to the data.
6503 *
6504 * Return: 0 for success, error number on failure.
6505 */
6506int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6507 union iwreq_data *wrqu, char *extra)
6508{
6509 int ret;
6510
6511 cds_ssr_protect(__func__);
6512 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6513 cds_ssr_unprotect(__func__);
6514
6515 return ret;
6516}