blob: 9302e8468a42fd6ff0afae327084633bd5280b91 [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>
54#include "cds_concurrency.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>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053062#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080063#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080064#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053065#include "wlan_pmo_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
67/* These are needed to recognize WPA and RSN suite types */
68#define HDD_WPA_OUI_SIZE 4
69#define HDD_RSN_OUI_SIZE 4
70uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
71uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
72uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
73uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
74uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
75uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
76
77#ifdef FEATURE_WLAN_ESE
78/* CCKM */
79uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
80/* CCKM */
81uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
82#endif /* FEATURE_WLAN_ESE */
83
84/* group cipher */
85uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
86
87/* WEP-40 or RSN */
88uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
89
90/* TKIP or RSN-PSK */
91uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
92
93/* Reserved */
94uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
95
96/* AES-CCMP */
97uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
98
99/* WEP-104 */
100uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
101
102#ifdef WLAN_FEATURE_11W
103/* RSN-PSK-SHA256 */
104uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
105
106/* RSN-8021X-SHA256 */
107uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
108#endif
109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110/* Offset where the EID-Len-IE, start. */
111#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
112#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113
114#define BEACON_FRAME_IES_OFFSET 12
115#define HDD_PEER_AUTHORIZE_WAIT 10
116
117/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700118 * beacon_filter_table - table of IEs used for beacon filtering
119 */
120static const int beacon_filter_table[] = {
121 SIR_MAC_DS_PARAM_SET_EID,
122 SIR_MAC_ERP_INFO_EID,
123 SIR_MAC_EDCA_PARAM_SET_EID,
124 SIR_MAC_QOS_CAPABILITY_EID,
125 SIR_MAC_HT_INFO_EID,
126 SIR_MAC_VHT_OPMODE_EID,
127 SIR_MAC_VHT_OPERATION_EID,
128};
129
130/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 * hdd_conn_set_authenticated() - set authentication state
132 * @pAdapter: pointer to the adapter
133 * @authState: authentication state
134 *
135 * This function updates the global HDD station context
136 * authentication state.
137 *
138 * Return: none
139 */
140static void
141hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
142{
143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
144 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
145
146 /* save the new connection state */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700147 hdd_notice("Authenticated state Changed from oldState:%d to State:%d",
148 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 pHddStaCtx->conn_info.uIsAuthenticated = authState;
150
151 /* Check is pending ROC request or not when auth state changed */
152 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
153}
154
155/**
156 * hdd_conn_set_connection_state() - set connection state
157 * @pAdapter: pointer to the adapter
158 * @connState: connection state
159 *
160 * This function updates the global HDD station context connection state.
161 *
162 * Return: none
163 */
164void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
165 eConnectionState connState)
166{
167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
168 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
169
170 /* save the new connection state */
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530171 hdd_info("%pS Changed connectionState Changed from oldState:%d to State:%d",
172 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
173 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 pHddStaCtx->conn_info.connState = connState;
175
176 /* Check is pending ROC request or not when connection state changed */
177 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
178}
179
180/**
181 * hdd_conn_get_connection_state() - get connection state
182 * @pAdapter: pointer to the adapter
183 * @pConnState: pointer to connection state
184 *
185 * This function updates the global HDD station context connection state.
186 *
187 * Return: true if (Infra Associated or IBSS Connected)
188 * and sets output parameter pConnState;
189 * false otherwise
190 */
191static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
192 eConnectionState *pConnState)
193{
194 bool fConnected = false;
195 eConnectionState connState;
196
197 /* get the connection state. */
198 connState = pHddStaCtx->conn_info.connState;
199
200 if (eConnectionState_Associated == connState ||
201 eConnectionState_IbssConnected == connState ||
202 eConnectionState_IbssDisconnected == connState) {
203 fConnected = true;
204 }
205
206 if (pConnState)
207 *pConnState = connState;
208
209 return fConnected;
210}
211
212/**
213 * hdd_is_connecting() - Function to check connection progress
214 * @hdd_sta_ctx: pointer to global HDD Station context
215 *
216 * Return: true if connecting, false otherwise
217 */
218bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
219{
220 return hdd_sta_ctx->conn_info.connState ==
221 eConnectionState_Connecting;
222}
223
224/**
225 * hdd_conn_is_connected() - Function to check connection status
226 * @pHddStaCtx: pointer to global HDD Station context
227 *
228 * Return: false if any errors encountered, true otherwise
229 */
230bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
231{
232 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
233}
234
235/**
236 * hdd_conn_get_connected_band() - get current connection radio band
237 * @pHddStaCtx: pointer to global HDD Station context
238 *
239 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
240 * eCSR_BAND_ALL if not connected
241 */
242eCsrBand hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
243{
244 uint8_t staChannel = 0;
245
246 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
247 staChannel = pHddStaCtx->conn_info.operationChannel;
248
249 if (staChannel > 0 && staChannel < 14)
250 return eCSR_BAND_24;
251 else if (staChannel >= 36 && staChannel <= 184)
252 return eCSR_BAND_5G;
253 else /* If station is not connected return as eCSR_BAND_ALL */
254 return eCSR_BAND_ALL;
255}
256
257/**
258 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
259 * @pHddStaCtx: pointer to global HDD Station context
260 * @pConnectedCipherAlgo: pointer to connected cipher algo
261 *
262 * Return: false if any errors encountered, true otherwise
263 */
264static inline bool
265hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
266 eCsrEncryptionType *pConnectedCipherAlgo)
267{
268 bool fConnected = false;
269
270 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
271
272 if (pConnectedCipherAlgo)
273 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
274
275 return fConnected;
276}
277
278/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700279 * hdd_remove_beacon_filter() - remove beacon filter
280 * @adapter: Pointer to the hdd adapter
281 *
282 * Return: 0 on success and errno on failure
283 */
284static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
285{
286 QDF_STATUS status;
287 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
288
289 status = sme_remove_beacon_filter(hdd_ctx->hHal,
290 adapter->sessionId);
291 if (!QDF_IS_STATUS_SUCCESS(status)) {
292 hdd_err("sme_remove_beacon_filter() failed");
293 return -EFAULT;
294 }
295
296 return 0;
297}
298
299/**
300 * hdd_add_beacon_filter() - add beacon filter
301 * @adapter: Pointer to the hdd adapter
302 *
303 * Return: 0 on success and errno on failure
304 */
305static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
306{
307 int i;
308 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
309 QDF_STATUS status;
310 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
311
312 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530313 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700314 (unsigned long int *)ie_map);
315
316 status = sme_add_beacon_filter(hdd_ctx->hHal,
317 adapter->sessionId, ie_map);
318 if (!QDF_IS_STATUS_SUCCESS(status)) {
319 hdd_err("sme_add_beacon_filter() failed");
320 return -EFAULT;
321 }
322 return 0;
323}
324
325/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530326 * hdd_copy_vht_caps()- copy vht caps info from roam info to
327 * hdd station context.
328 * @hdd_sta_ctx: pointer to hdd station context
329 * @roam_info: pointer to roam info
330 *
331 * Return: None
332 */
333static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
334 tCsrRoamInfo *roam_info)
335{
336 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
337 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
338 uint32_t i, temp_ht_cap;
339
340 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
341
342 if (roam_ht_cap->advCodingCap)
343 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
344 if (roam_ht_cap->supportedChannelWidthSet)
345 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
346 temp_ht_cap = roam_ht_cap->mimoPowerSave &
347 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
348 if (temp_ht_cap)
349 hdd_ht_cap->cap_info |=
350 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
351 if (roam_ht_cap->greenField)
352 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
353 if (roam_ht_cap->shortGI20MHz)
354 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
355 if (roam_ht_cap->shortGI40MHz)
356 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
357 if (roam_ht_cap->txSTBC)
358 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
359 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
360 IEEE80211_HT_CAP_RX_STBC_SHIFT);
361 if (temp_ht_cap)
362 hdd_ht_cap->cap_info |=
363 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
364 if (roam_ht_cap->delayedBA)
365 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
366 if (roam_ht_cap->maximalAMSDUsize)
367 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
368 if (roam_ht_cap->dsssCckMode40MHz)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
370 if (roam_ht_cap->psmp)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
372 if (roam_ht_cap->stbcControlFrame)
373 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
374 if (roam_ht_cap->lsigTXOPProtection)
375 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
376
377 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
378 if (roam_ht_cap->maxRxAMPDUFactor)
379 hdd_ht_cap->ampdu_params_info |=
380 IEEE80211_HT_AMPDU_PARM_FACTOR;
381 temp_ht_cap = roam_ht_cap->mpduDensity &
382 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
383 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
384 if (temp_ht_cap)
385 hdd_ht_cap->ampdu_params_info |=
386 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
387
388 /* 802.11n HT extended capabilities masks */
389 if (roam_ht_cap->pco)
390 hdd_ht_cap->extended_ht_cap_info |=
391 IEEE80211_HT_EXT_CAP_PCO;
392 temp_ht_cap = roam_ht_cap->transitionTime &
393 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
394 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
395 if (temp_ht_cap)
396 hdd_ht_cap->extended_ht_cap_info |=
397 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
398 temp_ht_cap = roam_ht_cap->mcsFeedback &
399 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
400 if (temp_ht_cap)
401 hdd_ht_cap->extended_ht_cap_info |=
402 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
403
404 /* tx_bf_cap_info capabilities */
405 if (roam_ht_cap->txBF)
406 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
407 if (roam_ht_cap->rxStaggeredSounding)
408 hdd_ht_cap->tx_BF_cap_info |=
409 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
410 if (roam_ht_cap->txStaggeredSounding)
411 hdd_ht_cap->tx_BF_cap_info |=
412 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
413 if (roam_ht_cap->rxZLF)
414 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
415 if (roam_ht_cap->txZLF)
416 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
417 if (roam_ht_cap->implicitTxBF)
418 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
419 temp_ht_cap = roam_ht_cap->calibration &
420 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
421 if (temp_ht_cap)
422 hdd_ht_cap->tx_BF_cap_info |=
423 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
424 if (roam_ht_cap->explicitCSITxBF)
425 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
426 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
427 hdd_ht_cap->tx_BF_cap_info |=
428 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
429 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
430 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
431 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
432 if (temp_ht_cap)
433 hdd_ht_cap->tx_BF_cap_info |=
434 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
435 temp_ht_cap =
436 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
437 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
438 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
439 if (temp_ht_cap)
440 hdd_ht_cap->tx_BF_cap_info |=
441 temp_ht_cap <<
442 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
443 temp_ht_cap =
444 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
445 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
446 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
447 if (temp_ht_cap)
448 hdd_ht_cap->tx_BF_cap_info |=
449 temp_ht_cap <<
450 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
451 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
452 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
453 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
454 if (temp_ht_cap)
455 hdd_ht_cap->tx_BF_cap_info |=
456 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
457 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
458 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
459 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
460 if (temp_ht_cap)
461 hdd_ht_cap->tx_BF_cap_info |=
462 temp_ht_cap <<
463 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
464 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
465 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
466 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
467 if (temp_ht_cap)
468 hdd_ht_cap->tx_BF_cap_info |=
469 temp_ht_cap <<
470 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
471
472 /* antenna selection */
473 if (roam_ht_cap->antennaSelection)
474 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
475 if (roam_ht_cap->explicitCSIFeedbackTx)
476 hdd_ht_cap->antenna_selection_info |=
477 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
478 if (roam_ht_cap->antennaIndicesFeedbackTx)
479 hdd_ht_cap->antenna_selection_info |=
480 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
481 if (roam_ht_cap->explicitCSIFeedback)
482 hdd_ht_cap->antenna_selection_info |=
483 ANTENNA_SEL_INFO_EXP_CSI_FB;
484 if (roam_ht_cap->antennaIndicesFeedback)
485 hdd_ht_cap->antenna_selection_info |=
486 ANTENNA_SEL_INFO_ANT_ID_FB;
487 if (roam_ht_cap->rxAS)
488 hdd_ht_cap->antenna_selection_info |=
489 ANTENNA_SEL_INFO_RX_AS;
490 if (roam_ht_cap->txSoundingPPDUs)
491 hdd_ht_cap->antenna_selection_info |=
492 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
493
494 /* mcs data rate */
495 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
496 hdd_ht_cap->mcs.rx_mask[i] =
497 roam_ht_cap->supportedMCSSet[i];
498 hdd_ht_cap->mcs.rx_highest =
499 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
500 ((short) (roam_ht_cap->supportedMCSSet[10]));
501 hdd_ht_cap->mcs.tx_params =
502 roam_ht_cap->supportedMCSSet[12];
503}
504
505#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
506#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
507#define VHT_CAP_RXSTBC_MASK_SHIFT 8
508#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
509#define VHT_CAP_BEAMFORMEE_STS_MASK \
510 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
511#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
512#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
513 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
514#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
515#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
516 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
517#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
518
519/**
520 * hdd_copy_ht_caps()- copy ht caps info from roam info to
521 * hdd station context.
522 * @hdd_sta_ctx: pointer to hdd station context
523 * @roam_info: pointer to roam info
524 *
525 * Return: None
526 */
527static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
528 tCsrRoamInfo *roam_info)
529{
530 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
531 struct ieee80211_vht_cap *hdd_vht_cap =
532 &hdd_sta_ctx->conn_info.vht_caps;
533 uint32_t temp_vht_cap;
534
535 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
536
537 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
538 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
539 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
540 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
541 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
542 if (temp_vht_cap)
543 if (roam_vht_cap->supportedChannelWidthSet &
544 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
545 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
546 hdd_vht_cap->vht_cap_info |=
547 temp_vht_cap <<
548 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
549 if (roam_vht_cap->supportedChannelWidthSet &
550 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
551 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
552 hdd_vht_cap->vht_cap_info |=
553 temp_vht_cap <<
554 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
555 if (roam_vht_cap->ldpcCodingCap)
556 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
557 if (roam_vht_cap->shortGI80MHz)
558 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
559 if (roam_vht_cap->shortGI160and80plus80MHz)
560 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
561 if (roam_vht_cap->txSTBC)
562 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
563 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
564 VHT_CAP_RXSTBC_MASK_SHIFT);
565 if (temp_vht_cap)
566 hdd_vht_cap->vht_cap_info |=
567 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
568 if (roam_vht_cap->suBeamFormerCap)
569 hdd_vht_cap->vht_cap_info |=
570 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
571 if (roam_vht_cap->suBeamformeeCap)
572 hdd_vht_cap->vht_cap_info |=
573 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
574 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
575 (VHT_CAP_BEAMFORMEE_STS_MASK);
576 if (temp_vht_cap)
577 hdd_vht_cap->vht_cap_info |=
578 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
579 temp_vht_cap = roam_vht_cap->numSoundingDim &
580 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
581 if (temp_vht_cap)
582 hdd_vht_cap->vht_cap_info |=
583 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
584 if (roam_vht_cap->muBeamformerCap)
585 hdd_vht_cap->vht_cap_info |=
586 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
587 if (roam_vht_cap->muBeamformeeCap)
588 hdd_vht_cap->vht_cap_info |=
589 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
590 if (roam_vht_cap->vhtTXOPPS)
591 hdd_vht_cap->vht_cap_info |=
592 IEEE80211_VHT_CAP_VHT_TXOP_PS;
593 if (roam_vht_cap->htcVHTCap)
594 hdd_vht_cap->vht_cap_info |=
595 IEEE80211_VHT_CAP_HTC_VHT;
596 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
597 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
598 if (temp_vht_cap)
599 hdd_vht_cap->vht_cap_info |=
600 temp_vht_cap <<
601 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
602 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
603 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
604 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
605 if (temp_vht_cap)
606 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
607 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
608 if (roam_vht_cap->rxAntPattern)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
611 if (roam_vht_cap->txAntPattern)
612 hdd_vht_cap->vht_cap_info |=
613 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
614 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
615 hdd_vht_cap->supp_mcs.rx_highest =
616 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
617 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
618 hdd_vht_cap->supp_mcs.tx_highest =
619 ((uint16_t)roam_vht_cap->txSupDataRate);
620}
621
622/* ht param */
623#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
624#define HT_PARAM_SERVICE_INT_GRAN 0xe0
625#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
626
627/* operatinon mode */
628#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
629
630/* stbc_param */
631#define HT_STBC_PARAM_MCS 0x007f
632
633/**
634 * hdd_copy_ht_operation()- copy HT operation element from roam info to
635 * hdd station context.
636 * @hdd_sta_ctx: pointer to hdd station context
637 * @roam_info: pointer to roam info
638 *
639 * Return: None
640 */
641static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
642 tCsrRoamInfo *roam_info)
643{
644 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
645 struct ieee80211_ht_operation *hdd_ht_ops =
646 &hdd_sta_ctx->conn_info.ht_operation;
647 uint32_t i, temp_ht_ops;
648
649 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
650
651 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
652
653 /* HT_PARAMS */
654 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
655 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
656 if (temp_ht_ops)
657 hdd_ht_ops->ht_param |= temp_ht_ops;
658 else
659 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
660 if (roam_ht_ops->recommendedTxWidthSet)
661 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
662 if (roam_ht_ops->rifsMode)
663 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
664 if (roam_ht_ops->controlledAccessOnly)
665 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
666 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
667 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
668 if (temp_ht_ops)
669 hdd_ht_ops->ht_param |= temp_ht_ops <<
670 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
671
672 /* operation mode */
673 temp_ht_ops = roam_ht_ops->opMode &
674 IEEE80211_HT_OP_MODE_PROTECTION;
675 switch (temp_ht_ops) {
676 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
677 hdd_ht_ops->operation_mode |=
678 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
679 break;
680 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
681 hdd_ht_ops->operation_mode |=
682 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
683 break;
684 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
685 hdd_ht_ops->operation_mode |=
686 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
687 break;
688 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
689 default:
690 hdd_ht_ops->operation_mode |=
691 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
692 }
693 if (roam_ht_ops->nonGFDevicesPresent)
694 hdd_ht_ops->operation_mode |=
695 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
696 if (roam_ht_ops->transmitBurstLimit)
697 hdd_ht_ops->operation_mode |=
698 HT_OP_MODE_TX_BURST_LIMIT;
699 if (roam_ht_ops->obssNonHTStaPresent)
700 hdd_ht_ops->operation_mode |=
701 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
702
703 /* stbc_param */
704 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
705 HT_STBC_PARAM_MCS;
706 if (temp_ht_ops)
707 hdd_ht_ops->stbc_param |= temp_ht_ops;
708 if (roam_ht_ops->dualCTSProtection)
709 hdd_ht_ops->stbc_param |=
710 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
711 if (roam_ht_ops->secondaryBeacon)
712 hdd_ht_ops->stbc_param |=
713 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
714 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
715 hdd_ht_ops->stbc_param |=
716 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
717 if (roam_ht_ops->pcoActive)
718 hdd_ht_ops->stbc_param |=
719 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
720 if (roam_ht_ops->pcoPhase)
721 hdd_ht_ops->stbc_param |=
722 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
723
724 /* basic MCs set */
725 for (i = 0; i < 16; ++i)
726 hdd_ht_ops->basic_set[i] =
727 roam_ht_ops->basicMCSSet[i];
728}
729
730/**
731 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
732 * hdd station context.
733 * @hdd_sta_ctx: pointer to hdd station context
734 * @roam_info: pointer to roam info
735 *
736 * Return: None
737 */
738static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
739 tCsrRoamInfo *roam_info)
740{
741 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
742 struct ieee80211_vht_operation *hdd_vht_ops =
743 &hdd_sta_ctx->conn_info.vht_operation;
744
745 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
746
747 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
748 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
749 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
750 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
751}
752
753
754/**
755 * hdd_save_bss_info() - save connection info in hdd sta ctx
756 * @adapter: Pointer to adapter
757 * @roam_info: pointer to roam info
758 *
759 * Return: None
760 */
761static void hdd_save_bss_info(hdd_adapter_t *adapter,
762 tCsrRoamInfo *roam_info)
763{
764 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
765
766 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
767 hdd_sta_ctx->conn_info.operationChannel);
768 if (roam_info->vht_caps.present) {
769 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
770 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
771 } else {
772 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
773 }
774 if (roam_info->ht_caps.present) {
775 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
776 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
777 } else {
778 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
779 }
780 if (roam_info->reassoc)
781 hdd_sta_ctx->conn_info.roam_count++;
782 if (roam_info->hs20vendor_ie.present) {
783 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
784 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
785 &roam_info->hs20vendor_ie,
786 sizeof(roam_info->hs20vendor_ie));
787 } else {
788 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
789 }
790 if (roam_info->ht_operation.present) {
791 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
792 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
793 } else {
794 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
795 }
796 if (roam_info->vht_operation.present) {
797 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
798 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
799 } else {
800 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
801 }
802}
803
804/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 * hdd_conn_save_connect_info() - save current connection information
806 * @pAdapter: pointer to adapter
807 * @pRoamInfo: pointer to roam info
808 * @eBssType: bss type
809 *
810 * Return: none
811 */
812static void
813hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
814 eCsrRoamBssType eBssType)
815{
816 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
817 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
818
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530819 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820
821 if (pRoamInfo) {
822 /* Save the BSSID for the connection */
823 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530824 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530825 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 &pRoamInfo->bssid);
827
828 /*
829 * Save the Station ID for this station from
830 * the 'Roam Info'. For IBSS mode, staId is
831 * assigned in NEW_PEER_IND. For reassoc,
832 * the staID doesn't change and it may be invalid
833 * in this structure so no change here.
834 */
835 if (!pRoamInfo->fReassocReq) {
836 pHddStaCtx->conn_info.staId[0] =
837 pRoamInfo->staId;
838 }
839 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
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 } else {
843 /*
844 * can't happen. We need a valid IBSS or Infra setting
845 * in the BSSDescription or we can't function.
846 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530847 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 }
849
850 /* notify WMM */
851 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
852
853 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530854 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 } else {
856 /* Get Multicast Encryption Type */
857 encryptType =
858 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
859 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
860 /* Get Unicast Encryption Type */
861 encryptType =
862 pRoamInfo->u.pConnectedProfile->EncryptionType;
863 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
864
865 pHddStaCtx->conn_info.authType =
866 pRoamInfo->u.pConnectedProfile->AuthType;
867
868 pHddStaCtx->conn_info.operationChannel =
869 pRoamInfo->u.pConnectedProfile->operationChannel;
870
871 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530872 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 &pRoamInfo->u.pConnectedProfile->SSID,
874 sizeof(tSirMacSSid));
875
876 /* Save dot11mode in which STA associated to AP */
877 pHddStaCtx->conn_info.dot11Mode =
878 pRoamInfo->u.pConnectedProfile->dot11Mode;
879
880 pHddStaCtx->conn_info.proxyARPService =
881 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530882
883 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
884
885 pHddStaCtx->conn_info.rate_flags =
886 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530888 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890}
891
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892/**
893 * hdd_send_ft_assoc_response() - send fast transition assoc response
894 * @dev: pointer to net device
895 * @pAdapter: pointer to adapter
896 * @pCsrRoamInfo: pointer to roam info
897 *
898 * Send the 11R key information to the supplicant. Only then can the supplicant
899 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
900 * for the same purpose.)
901 *
902 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
903 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
904 * This is the Assoc Response.
905 *
906 * Return: none
907 */
908static void
909hdd_send_ft_assoc_response(struct net_device *dev,
910 hdd_adapter_t *pAdapter,
911 tCsrRoamInfo *pCsrRoamInfo)
912{
913 union iwreq_data wrqu;
914 char *buff;
915 unsigned int len = 0;
916 u8 *pFTAssocRsp = NULL;
917
918 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700919 hdd_err("pCsrRoamInfo->nAssocRspLength=%d",
920 (int)pCsrRoamInfo->nAssocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 return;
922 }
923
924 pFTAssocRsp =
925 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
926 pCsrRoamInfo->nAssocReqLength);
927 if (pFTAssocRsp == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700928 hdd_err("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 return;
930 }
931 /* pFTAssocRsp needs to point to the IEs */
932 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700933 hdd_notice("AssocRsp is now at %02x%02x",
934 (unsigned int)pFTAssocRsp[0],
935 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
937 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700938 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700940 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 return;
942 }
943 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
944 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
945 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 memcpy(buff, pFTAssocRsp, len);
947 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
948
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700949 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952/**
953 * hdd_send_ft_event() - send fast transition event
954 * @pAdapter: pointer to adapter
955 *
956 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
957 * FT events to the supplicant. At the reception of Auth2 we send the RIC
958 * followed by the auth response IEs to the supplicant.
959 * Once both are received in the supplicant, an FT event is generated
960 * to the supplicant.
961 *
962 * Return: none
963 */
964static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
965{
966 uint16_t auth_resp_len = 0;
967 uint32_t ric_ies_length = 0;
968 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
969
970#if defined(KERNEL_SUPPORT_11R_CFG80211)
971 struct cfg80211_ft_event_params ftEvent;
972 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
973 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
974 struct net_device *dev = pAdapter->dev;
975#else
976 char *buff;
977 union iwreq_data wrqu;
978 uint16_t str_len;
979#endif
980
981#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530982 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
983 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984
985 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
986 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
987 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700988 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 }
990
991 ftEvent.ric_ies = ricIe;
992 ftEvent.ric_ies_len = ric_ies_length;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700993 hdd_notice("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994
995 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
996 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
997 &auth_resp_len);
998
999 if (auth_resp_len == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001000 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 return;
1002 }
1003
1004 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1005
1006 ftEvent.target_ap = ftIe;
1007
Anurag Chouhan6d760662016-02-20 16:05:43 +05301008 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1009 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001011 hdd_notice("ftEvent.ies_len %zu", ftEvent.ies_len);
1012 hdd_notice("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1013 hdd_notice("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 ftEvent.target_ap[0], ftEvent.target_ap[1],
1015 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1016 ftEvent.target_ap[5]);
1017
1018 (void)cfg80211_ft_event(dev, &ftEvent);
1019
1020#else
1021 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001022 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001024 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 return;
1026 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027
1028 /* Sme needs to send the RIC IEs first */
1029 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1030 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1031 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1032 &ric_ies_length);
1033 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001034 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 } else {
1036 wrqu.data.length = str_len + ric_ies_length;
1037 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1038 }
1039
1040 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301041 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1043 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1044 (u8 *) &buff[str_len],
1045 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1046
1047 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001048 qdf_mem_free(buff);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001049 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 return;
1051 }
1052
1053 wrqu.data.length = str_len + auth_resp_len;
1054 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1055
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001056 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057#endif
1058}
1059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060#ifdef FEATURE_WLAN_ESE
1061/**
1062 * hdd_send_new_ap_channel_info() - send new ap channel info
1063 * @dev: pointer to net device
1064 * @pAdapter: pointer to adapter
1065 * @pCsrRoamInfo: pointer to roam info
1066 *
1067 * Send the ESE required "new AP Channel info" to the supplicant.
1068 * (This keeps the supplicant "up to date" on the current channel.)
1069 *
1070 * The current (new AP) channel information is passed in.
1071 *
1072 * Return: none
1073 */
1074static void
1075hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1076 tCsrRoamInfo *pCsrRoamInfo)
1077{
1078 union iwreq_data wrqu;
1079 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1080
1081 if (descriptor == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001082 hdd_err("pCsrRoamInfo->pBssDesc(%p)", descriptor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 return;
1084 }
1085 /*
1086 * Send the Channel event, the supplicant needs this to generate
1087 * the Adjacent AP report.
1088 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001089 hdd_warn("Sending up an SIOCGIWFREQ, channelId(%d)",
1090 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 memset(&wrqu, '\0', sizeof(wrqu));
1092 wrqu.freq.m = descriptor->channelId;
1093 wrqu.freq.e = 0;
1094 wrqu.freq.i = 0;
1095 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1096}
1097
1098#endif /* FEATURE_WLAN_ESE */
1099
1100/**
1101 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1102 * @pAdapter: pointer to adapter
1103 * @pCsrRoamInfo: pointer to roam info
1104 *
1105 * Return: none
1106 */
1107static void
1108hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1109 tCsrRoamInfo *pCsrRoamInfo)
1110{
1111 union iwreq_data wrqu;
1112 u8 *pBeaconIes;
1113 u8 currentLen = 0;
1114 char *buff;
1115 int totalIeLen = 0, currentOffset = 0, strLen;
1116
1117 memset(&wrqu, '\0', sizeof(wrqu));
1118
1119 if (0 == pCsrRoamInfo->nBeaconLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001120 hdd_warn("pCsrRoamInfo->nBeaconFrameLength = 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 return;
1122 }
1123 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1124 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001125 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126 return;
1127 }
1128 /* pBeaconIes needs to point to the IEs */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001129 hdd_notice("Beacon IEs is now at %02x%02x",
1130 (unsigned int)pBeaconIes[0],
1131 (unsigned int)pBeaconIes[1]);
1132 hdd_notice("Beacon IEs length = %d",
1133 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134
1135 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001136 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001138 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 return;
1140 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001141
1142 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1143 currentLen = strLen + 1;
1144
1145 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1146 do {
1147 /*
1148 * If the beacon size exceeds max CUSTOM event size, break it
1149 * into chunks of CUSTOM event max size and send it to
1150 * supplicant. Changes are done in supplicant to handle this.
1151 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301152 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301154 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301155 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156 currentLen);
1157 currentOffset += currentLen;
1158 totalIeLen -= currentLen;
1159 wrqu.data.length = strLen + 1 + currentLen;
1160 if (totalIeLen)
1161 buff[strLen] = 1; /* more chunks pending */
1162 else
1163 buff[strLen] = 0; /* last chunk */
1164
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001165 hdd_notice("Beacon IEs length to supplicant = %d",
1166 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1168 } while (totalIeLen > 0);
1169
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001170 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171}
1172
1173/**
1174 * hdd_send_association_event() - send association event
1175 * @dev: pointer to net device
1176 * @pCsrRoamInfo: pointer to roam info
1177 *
1178 * Return: none
1179 */
1180static void hdd_send_association_event(struct net_device *dev,
1181 tCsrRoamInfo *pCsrRoamInfo)
1182{
Rajeev Kumar78427682017-01-13 16:13:11 -08001183 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1185 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1186 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1187 union iwreq_data wrqu;
1188 int we_event;
1189 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301190 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 /* Added to find the auth type on the fly at run time */
1193 /* rather than with cfg to see if FT is enabled */
1194 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1195 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196
1197 memset(&wrqu, '\0', sizeof(wrqu));
1198 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1199 we_event = SIOCGIWAP;
1200#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1201 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301202 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 /* change logging before release */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001204 hdd_info("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301205 /* Update tdls module about the disconnection event */
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301206 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301207 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208#endif
1209 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Abhishek Singh1c676222016-05-09 14:20:28 +05301210 tSirSmeChanInfo chan_info;
1211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 if (!pCsrRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001213 hdd_err("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 return;
1215 }
1216
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001217 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
1218 cds_incr_active_session(pAdapter->device_mode,
1219 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1221 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1222
1223#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001224 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 if (global_p2p_connection_status ==
1226 P2P_CLIENT_CONNECTING_STATE_1) {
1227 global_p2p_connection_status =
1228 P2P_CLIENT_CONNECTED_STATE_1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001229 hdd_err("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230 } else if (global_p2p_connection_status ==
1231 P2P_CLIENT_CONNECTING_STATE_2) {
1232 global_p2p_connection_status =
1233 P2P_CLIENT_COMPLETED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001234 hdd_err("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 }
1236 }
1237#endif
1238 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1239 MAC_ADDRESS_STR "\n",
1240 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1241 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1242 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1243
1244 /*
1245 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1246 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001247 * fFTEnable is true.
1248 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 if ((pRoamProfile->AuthType.authType[0] ==
1251 eCSR_AUTH_TYPE_FT_RSN_PSK)
1252 || (pRoamProfile->AuthType.authType[0] ==
1253 eCSR_AUTH_TYPE_FT_RSN)
1254#ifdef FEATURE_WLAN_ESE
1255 || (pRoamProfile->AuthType.authType[0] ==
1256 eCSR_AUTH_TYPE_CCKM_RSN)
1257 || (pRoamProfile->AuthType.authType[0] ==
1258 eCSR_AUTH_TYPE_CCKM_WPA)
1259#endif
1260 ) {
1261 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1262 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301263 qdf_copy_macaddr(&peerMacAddr,
1264 &pHddStaCtx->conn_info.bssId);
1265 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1266 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1267 chan_info.info = pCsrRoamInfo->chan_info.info;
1268 chan_info.band_center_freq1 =
1269 pCsrRoamInfo->chan_info.band_center_freq1;
1270 chan_info.band_center_freq2 =
1271 pCsrRoamInfo->chan_info.band_center_freq2;
1272 chan_info.reg_info_1 =
1273 pCsrRoamInfo->chan_info.reg_info_1;
1274 chan_info.reg_info_2 =
1275 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301276
Rajeev Kumar78427682017-01-13 16:13:11 -08001277 ret = hdd_add_peer_object(pAdapter->hdd_vdev,
1278 pAdapter->device_mode,
1279 peerMacAddr.bytes);
1280 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301281 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1282 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Mukul Sharma5678be42017-01-24 12:20:01 +05301283 ret = hdd_set_peer_mlme_state(pAdapter->hdd_vdev,
1284 WLAN_ASSOC_STATE);
1285 if (ret)
1286 hdd_err("Peer object %pM fail to set associated state",
1287 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301288
Abhishek Singh1c676222016-05-09 14:20:28 +05301289 /* send peer status indication to oem app */
1290 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
1291 ePeerConnected,
1292 pCsrRoamInfo->
1293 timingMeasCap,
1294 pAdapter->sessionId,
1295 &chan_info,
1296 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001297 /* Update tdls module about connection event */
1298 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001299
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001301#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 /* start timer in sta/p2p_cli */
1303 spin_lock_bh(&pHddCtx->bus_bw_lock);
1304 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1305 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001306 cdp_get_intra_bss_fwd_pkts_count(
1307 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301308 &pAdapter->prev_fwd_tx_packets,
1309 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1311 hdd_start_bus_bw_compute_timer(pAdapter);
1312#endif
1313#endif
1314 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1315 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001316 cds_update_connection_info(pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
1318 ETH_ALEN);
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301319 hdd_err("wlan: new IBSS connection to " MAC_ADDRESS_STR,
1320 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301321
Rajeev Kumar78427682017-01-13 16:13:11 -08001322 ret = hdd_add_peer_object(pAdapter->hdd_vdev,
1323 QDF_IBSS_MODE,
1324 pCsrRoamInfo->bssid.bytes);
1325 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301326 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1327 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301328 ret = hdd_set_peer_mlme_state(pAdapter->hdd_vdev,
1329 WLAN_ASSOC_STATE);
1330 if (ret)
1331 hdd_err("Peer object %pM fail to set associated state",
1332 peerMacAddr.bytes);
1333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 } else { /* Not Associated */
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301335 hdd_err("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301337 cds_decr_session_set_pcl(pAdapter->device_mode,
1338 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1341 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1342#endif
1343
Abhishek Singh1c676222016-05-09 14:20:28 +05301344 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1345 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301346 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 &pHddStaCtx->conn_info.bssId);
1348
1349 /* send peer status indication to oem app */
1350 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301351 ePeerDisconnected, 0,
1352 pAdapter->sessionId,
1353 NULL,
1354 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301356
Rajeev Kumardfa37072017-01-13 16:27:22 -08001357 ret = hdd_remove_peer_object(pAdapter->hdd_vdev,
1358 peerMacAddr.bytes);
1359 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301360 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1361 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1362
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001363 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001364 /* Update tdls module about the disconnection event */
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301365 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001366
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367#ifdef MSM_PLATFORM
1368 /* stop timer in sta/p2p_cli */
1369 spin_lock_bh(&pHddCtx->bus_bw_lock);
1370 pAdapter->prev_tx_packets = 0;
1371 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301372 pAdapter->prev_fwd_tx_packets = 0;
1373 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1375 hdd_stop_bus_bw_compute_timer(pAdapter);
1376#endif
1377 }
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001378 cds_dump_concurrency_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 /* Send SCC/MCC Switching event to IPA */
1380 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1381
1382 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001383 /* During the WLAN uninitialization,supplicant is stopped before the
1384 * driver so not sending the status of the connection to supplicant
1385 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001386 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 wireless_send_event(dev, we_event, &wrqu, msg);
1388#ifdef FEATURE_WLAN_ESE
1389 if (eConnectionState_Associated ==
1390 pHddStaCtx->conn_info.connState) {
1391 if ((pRoamProfile->AuthType.authType[0] ==
1392 eCSR_AUTH_TYPE_CCKM_RSN) ||
1393 (pRoamProfile->AuthType.authType[0] ==
1394 eCSR_AUTH_TYPE_CCKM_WPA))
1395 hdd_send_new_ap_channel_info(dev, pAdapter,
1396 pCsrRoamInfo);
1397 }
1398#endif
1399 }
1400}
1401
1402/**
1403 * hdd_conn_remove_connect_info() - remove connection info
1404 * @pHddStaCtx: pointer to global HDD station context
1405 * @pCsrRoamInfo: pointer to roam info
1406 *
1407 * Return: none
1408 */
1409static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1410{
1411 /* Remove staId, bssId and peerMacAddress */
1412 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301413 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1414 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301415 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416
1417 /* Clear all security settings */
1418 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1419 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1420 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1421
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301422 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1423 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 pHddStaCtx->conn_info.proxyARPService = 0;
1426
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301427 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428}
1429
1430/**
1431 * hdd_roam_deregister_sta() - deregister station
1432 * @pAdapter: pointer to adapter
1433 * @staId: station identifier
1434 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301435 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 */
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07001437QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301439 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1441
1442 if (eConnectionState_IbssDisconnected ==
1443 pHddStaCtx->conn_info.connState) {
1444 /*
1445 * Do not set the carrier off when the last peer leaves.
1446 * We will set the carrier off while stopping the IBSS.
1447 */
1448 }
1449
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001450 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001451 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
1452 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301453 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001454 hdd_err("cdp_clear_peer() failed for staID %d. Status(%d) [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301455 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301457 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458}
1459
1460/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301461 * hdd_print_bss_info() - print bss info
1462 * @hdd_sta_ctx: pointer to hdd station context
1463 *
1464 * Return: None
1465 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001466static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301467{
1468 uint32_t *cap_info;
1469
1470 hdd_info("WIFI DATA LOGGER");
1471 hdd_info("channel: %d",
1472 hdd_sta_ctx->conn_info.freq);
1473 hdd_info("dot11mode: %d",
1474 hdd_sta_ctx->conn_info.dot11Mode);
1475 hdd_info("AKM: %d",
1476 hdd_sta_ctx->conn_info.authType);
1477 hdd_info("ssid: %.*s",
1478 hdd_sta_ctx->conn_info.SSID.SSID.length,
1479 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1480 hdd_info("roam count: %d",
1481 hdd_sta_ctx->conn_info.roam_count);
1482 hdd_info("ant_info: %d",
1483 hdd_sta_ctx->conn_info.txrate.nss);
1484 hdd_info("datarate legacy %d",
1485 hdd_sta_ctx->conn_info.txrate.legacy);
1486 hdd_info("datarate mcs: %d",
1487 hdd_sta_ctx->conn_info.txrate.mcs);
1488 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1489 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1490 hdd_info("ht caps: %x", *cap_info);
1491 }
1492 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1493 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1494 hdd_info("vht caps: %x", *cap_info);
1495 }
1496 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1497 hdd_info("hs20 info: %x",
1498 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1499 hdd_info("signal: %d",
1500 hdd_sta_ctx->conn_info.signal);
1501 hdd_info("noise: %d",
1502 hdd_sta_ctx->conn_info.noise);
1503}
1504
1505/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 * hdd_dis_connect_handler() - disconnect event handler
1507 * @pAdapter: pointer to adapter
1508 * @pRoamInfo: pointer to roam info
1509 * @roamId: roam identifier
1510 * @roamStatus: roam status
1511 * @roamResult: roam result
1512 *
1513 * This function handles disconnect event:
1514 * 1. Disable transmit queues;
1515 * 2. Clean up internal connection states and data structures;
1516 * 3. Send disconnect indication to supplicant.
1517 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301518 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301520static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 tCsrRoamInfo *pRoamInfo,
1522 uint32_t roamId,
1523 eRoamCmdStatus roamStatus,
1524 eCsrRoamResult roamResult)
1525{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301526 QDF_STATUS status = QDF_STATUS_SUCCESS;
1527 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 struct net_device *dev = pAdapter->dev;
1529 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1530 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1531 uint8_t sta_id;
1532 bool sendDisconInd = true;
1533
1534 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001535 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301536 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 }
1538 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001539 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER,
1541 WLAN_CONTROL_PATH);
1542
1543 if (hdd_ipa_is_enabled(pHddCtx))
1544 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001545 HDD_IPA_STA_DISCONNECT,
1546 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547
1548#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1549 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1550#endif
1551
Nirav Shah1da77682016-05-03 20:16:39 +05301552 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1553 pAdapter->sessionId,
1554 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555
1556 /* HDD has initiated disconnect, do not send disconnect indication
1557 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301558 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 * to cfg80211_disconnected.
1560 */
1561 if ((eConnectionState_Disconnecting ==
1562 pHddStaCtx->conn_info.connState) ||
1563 (eConnectionState_NotConnected ==
1564 pHddStaCtx->conn_info.connState)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001565 hdd_notice("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 sendDisconInd = false;
1567 }
1568
1569 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1570 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 hdd_conn_set_connection_state(pAdapter,
1572 eConnectionState_Disconnecting);
1573 }
1574
1575 hdd_clear_roam_profile_ie(pAdapter);
1576 hdd_wmm_init(pAdapter);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301577 hdd_info("Invoking packetdump deregistration API");
1578 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579
1580 /* indicate 'disconnect' status to wpa_supplicant... */
1581 hdd_send_association_event(dev, pRoamInfo);
1582 /* indicate disconnected event to nl80211 */
1583 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1584 /*
1585 * Only send indication to kernel if not initiated
1586 * by kernel
1587 */
1588 if (sendDisconInd) {
1589 /*
1590 * To avoid wpa_supplicant sending "HANGED" CMD
1591 * to ICS UI.
1592 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001593 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1594 if (pRoamInfo->reasonCode ==
1595 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1596 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301597 wlan_hdd_cfg80211_indicate_disconnect(
1598 dev, false,
1599 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001600 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301601 wlan_hdd_cfg80211_indicate_disconnect(
1602 dev, false,
1603 WLAN_REASON_UNSPECIFIED
1604 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001605 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301607 hdd_info("sent disconnected event to nl80211, reason code %d",
1608 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1609 pRoamInfo->reasonCode :
1610 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 }
1612 /*
1613 * During the WLAN uninitialization,supplicant is stopped
1614 * before the driver so not sending the status of the
1615 * connection to supplicant.
1616 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001617 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001619 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 if (global_p2p_connection_status ==
1621 P2P_CLIENT_CONNECTED_STATE_1) {
1622 global_p2p_connection_status =
1623 P2P_CLIENT_DISCONNECTED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001624 hdd_err("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 } else if (global_p2p_connection_status ==
1626 P2P_CLIENT_COMPLETED_STATE) {
1627 global_p2p_connection_status =
1628 P2P_NOT_ACTIVE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001629 hdd_err("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 }
1631 }
1632#endif
1633
1634 }
1635 }
1636
1637 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001639 if (hdd_remove_beacon_filter(pAdapter) != 0)
1640 hdd_err("hdd_remove_beacon_filter() failed");
1641
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301643 uint8_t i;
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001644 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301646 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301647 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]",
1648 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301649 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 }
1651 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301652 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001653 for (i = 0; i < MAX_PEERS; i++) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301654 if (0 == pHddStaCtx->conn_info.staId[i])
1655 continue;
1656 sta_id = pHddStaCtx->conn_info.staId[i];
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001657 hdd_info("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301658 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301659 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001660 hdd_err("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301661 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301662 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301663 }
1664 /* set the staid and peer mac as 0, all other
1665 * reset are done in hdd_connRemoveConnectInfo.
1666 */
1667 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301668 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301669 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301670 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1671 pHddCtx->sta_to_adapter[sta_id] = NULL;
1672 }
1673 } else {
1674 sta_id = pHddStaCtx->conn_info.staId[0];
Nitesh Shahcc962812017-02-01 11:58:15 +05301675 hdd_info("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301676
1677 /* clear scan cache for Link Lost */
1678 if (pRoamInfo && !pRoamInfo->reasonCode &&
1679 (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult)) {
1680 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1681 pHddStaCtx->conn_info.bssId.bytes);
1682 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1683 pHddStaCtx->conn_info.bssId.bytes);
1684 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301685 /* We should clear all sta register with TL,
1686 * for now, only one.
1687 */
1688 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301689 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001690 hdd_err("hdd_roam_deregister_sta() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301691 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301692 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301693 }
1694 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 /* Clear saved connection information in HDD */
1697 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301699 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700
1701#ifdef FEATURE_WLAN_TDLS
1702 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1703 wlan_hdd_tdls_disconnection_callback(pAdapter);
1704#endif
1705
Krunal Sonibe766b02016-03-10 13:00:44 -08001706 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1707 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1709 (pAdapter),
1710 pAdapter->sessionId);
1711 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301712 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 /* Unblock anyone waiting for disconnect to complete */
1714 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301715 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 return status;
1717}
1718
1719/**
1720 * hdd_set_peer_authorized_event() - set peer_authorized_event
1721 * @vdev_id: vdevid
1722 *
1723 * Return: None
1724 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001725static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301727 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 hdd_adapter_t *adapter = NULL;
1729
1730 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1731 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001732 hdd_err("Invalid vdev_id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 }
1734 complete(&adapter->sta_authorized_event);
1735}
1736
1737/**
1738 * hdd_change_peer_state() - change peer state
1739 * @pAdapter: HDD adapter
1740 * @sta_state: peer state
1741 * @roam_synch_in_progress: roam synch in progress
1742 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301743 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301745QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 uint8_t sta_id,
1747 enum ol_txrx_peer_state sta_state,
1748 bool roam_synch_in_progress)
1749{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301750 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001751 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001752 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1753 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1754 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755
1756 if (!pdev) {
1757 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301758 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 }
1760
1761 if (sta_id >= WLAN_MAX_STA_COUNT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001762 hdd_err("Invalid sta id :%d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301763 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 }
1765
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001766 peer = cdp_peer_find_by_local_id(soc,
1767 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301769 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770
Leo Changfdb45c32016-10-28 11:09:23 -07001771 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001772 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001773 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001774 return QDF_STATUS_E_FAULT;
1775 }
1776
Leo Changfdb45c32016-10-28 11:09:23 -07001777 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301778 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001779 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301780 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 }
1782#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1783 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301784 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785#endif
1786
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001787 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1789 /* make sure event is reset */
1790 INIT_COMPLETION(pAdapter->sta_authorized_event);
1791#endif
1792
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001793 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 hdd_set_peer_authorized_event,
1795 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301796 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001797 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301798 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 }
1800
Krunal Sonibe766b02016-03-10 13:00:44 -08001801 if (pAdapter->device_mode == QDF_STA_MODE ||
1802 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001804 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 unsigned long rc;
1806
1807 /* wait for event from firmware to set the event */
1808 rc = wait_for_completion_timeout(
1809 &pAdapter->sta_authorized_event,
1810 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
1811 if (!rc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001812 hdd_notice("timeout waiting for sta_authorized_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 }
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001814 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1815 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001816 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817#endif
1818 }
1819 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301820 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821}
1822
1823/**
1824 * hdd_roam_register_sta() - register station
1825 * @pAdapter: pointer to adapter
1826 * @pRoamInfo: pointer to roam info
1827 * @staId: station identifier
1828 * @pPeerMacAddress: peer MAC address
1829 * @pBssDesc: pointer to BSS description
1830 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301831 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001833QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 tCsrRoamInfo *pRoamInfo,
1835 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301836 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 tSirBssDescription *pBssDesc)
1838{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301839 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 struct ol_txrx_desc_type staDesc = { 0 };
1841 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001842 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001843 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1844 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845
1846 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848
1849 /* Get the Station ID from the one saved during the association */
1850 staDesc.sta_id = staId;
1851
1852 /* set the QoS field appropriately */
1853 if (hdd_wmm_is_active(pAdapter))
1854 staDesc.is_qos_enabled = 1;
1855 else
1856 staDesc.is_qos_enabled = 0;
1857
1858#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001859 hdd_notice("WAPI STA Registered: %d",
1860 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 if (pAdapter->wapi_info.fIsWapiSta)
1862 staDesc.is_wapi_supported = 1;
1863 else
1864 staDesc.is_wapi_supported = 0;
1865#endif /* FEATURE_WLAN_WAPI */
1866
Dhanashri Atre50141c52016-04-07 13:15:29 -07001867 /* Register the vdev transmit and receive functions */
1868 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1869 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001870
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001871 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1872 (struct cdp_pdev *)pdev,
1873 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001874 if (!pAdapter->txrx_vdev) {
1875 hdd_err("%s find vdev fail", __func__);
1876 return QDF_STATUS_E_FAILURE;
1877 }
1878
1879 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001880 cdp_vdev_register(soc,
1881 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001882 if (!txrx_ops.tx.tx) {
1883 hdd_err("%s vdev register fail", __func__);
1884 return QDF_STATUS_E_FAILURE;
1885 }
1886
Dhanashri Atre50141c52016-04-07 13:15:29 -07001887 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001888 qdf_status = cdp_peer_register(soc,
1889 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301890 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001891 hdd_warn("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001892 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301893 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 }
1895
1896 if (!pRoamInfo->fAuthRequired) {
1897 /*
1898 * Connections that do not need Upper layer auth, transition
1899 * TLSHIM directly to 'Authenticated' state
1900 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301901 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001903 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1905 pRoamInfo->roamSynchInProgress
1906#else
1907 false
1908#endif
1909 );
1910
1911 hdd_conn_set_authenticated(pAdapter, true);
1912 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001913 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301915 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001917 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1919 pRoamInfo->roamSynchInProgress
1920#else
1921 false
1922#endif
1923 );
1924 hdd_conn_set_authenticated(pAdapter, false);
1925 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301926 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927}
1928
1929/**
1930 * hdd_send_re_assoc_event() - send reassoc event
1931 * @dev: pointer to net device
1932 * @pAdapter: pointer to adapter
1933 * @pCsrRoamInfo: pointer to roam info
1934 * @reqRsnIe: pointer to RSN Information element
1935 * @reqRsnLength: length of RSN IE
1936 *
1937 * Return: none
1938 */
1939static void hdd_send_re_assoc_event(struct net_device *dev,
1940 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
1941 uint8_t *reqRsnIe, uint32_t reqRsnLength)
1942{
1943 unsigned int len = 0;
1944 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001945 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
1946 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 uint32_t rspRsnLength = 0;
1948 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1950 uint8_t *buf_ptr, ssid_ie_len;
1951 struct cfg80211_bss *bss = NULL;
1952 uint8_t *final_req_ie = NULL;
1953 tCsrRoamConnectedProfile roam_profile;
1954 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1955
Jeff Johnsonfdb73432016-10-11 08:07:27 -07001956 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
1957
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001959 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001960 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 }
1962
Naveen Rawat14298b92015-11-25 16:27:41 -08001963 if (!assoc_req_ies) {
1964 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001965 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001966 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001968 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 goto done;
1970 }
1971
1972 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001973 hdd_err("Invalid assoc response length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 goto done;
1975 }
1976
1977 pFTAssocRsp =
1978 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1979 pCsrRoamInfo->nAssocReqLength);
1980 if (pFTAssocRsp == NULL)
1981 goto done;
1982
1983 /* pFTAssocRsp needs to point to the IEs */
1984 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001985 hdd_info("AssocRsp is now at %02x%02x",
1986 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987
1988 /*
1989 * Active session count is decremented upon disconnection, but during
1990 * roaming, there is no disconnect indication and hence active session
1991 * count is not decremented.
1992 * After roaming is completed, active session count is incremented
1993 * as a part of connect indication but effectively after roaming the
1994 * active session count should still be the same and hence upon
1995 * successful reassoc decrement the active session count here.
1996 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001997 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301998 cds_decr_session_set_pcl(pAdapter->device_mode,
1999 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000
2001 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2002 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2003 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302004 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2005 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006
2007 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302008 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2010 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302011
2012 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2013 chan, pCsrRoamInfo->bssid.bytes,
2014 &roam_profile.SSID.ssId[0],
2015 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016
2017 if (bss == NULL)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002018 hdd_err("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 buf_ptr = buf_ssid_ie;
2020 *buf_ptr = SIR_MAC_SSID_EID;
2021 buf_ptr++;
2022 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2023 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 roam_profile.SSID.length);
2026 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08002027 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302028 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002029 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002030 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 if (final_req_ie == NULL)
2032 goto done;
2033 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302034 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302036 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2037 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2038 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08002040 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302041 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002042 final_req_ie, (ssid_ie_len + reqRsnLength));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 cfg80211_roamed_bss(dev, bss,
2044 final_req_ie, (ssid_ie_len + reqRsnLength),
2045 rspRsnIe, rspRsnLength, GFP_KERNEL);
2046
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302047 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002048 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2049 pCsrRoamInfo->nAssocReqLength);
2050
2051 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302052 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002053 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2054
Prakash Dhavali989127d2016-11-29 14:56:44 +05302055 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002056 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2057 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002058 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002060 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002062 qdf_mem_free(final_req_ie);
2063 qdf_mem_free(rspRsnIe);
2064 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065}
2066
2067/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302068 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002069 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302070 *
2071 * Return: roam sync status if roaming offloaded else false
2072 */
2073#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002074bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302075{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002076 if (roaminfo)
2077 return roaminfo->roamSynchInProgress;
2078 else
2079 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302080}
2081#endif
2082
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002083/**
2084 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2085 * @hddstactx: pointer to HDD sta context
2086 * @roaminfo: pointer to roaminfo structure
2087 *
2088 * This function returns staid for IBSS peer. If peer is broadcast
2089 * MAC address return self staid(0) else find the peer sta id of
2090 * the peer.
2091 *
2092 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2093 */
2094static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2095 tCsrRoamInfo *roaminfo)
2096{
2097 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2098 QDF_STATUS status;
2099
2100 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2101 staid = 0;
2102 } else {
2103 status = hdd_get_peer_sta_id(hddstactx,
2104 &roaminfo->peerMac, &staid);
2105 if (status != QDF_STATUS_SUCCESS) {
2106 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2107 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2108 }
2109 }
2110
2111 return staid;
2112}
Govind Singhedc5cda2015-10-23 17:11:35 +05302113
2114/**
2115 * hdd_change_sta_state_authenticated()-
2116 * This function changes STA state to authenticated
2117 * @adapter: pointer to the adapter structure.
2118 * @roaminfo: pointer to the RoamInfo structure.
2119 *
2120 * This is called from hdd_RoamSetKeyCompleteHandler
2121 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2122 *
2123 * Return: 0 on success and errno on failure
2124 */
2125static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2126 tCsrRoamInfo *roaminfo)
2127{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002128 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002129 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002130 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302131 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002132 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302133
Dustin Brownf660fb42016-09-09 12:04:00 -07002134 timeout = hddstactx->hdd_ReassocScenario ?
2135 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002136 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002137
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002138 if (QDF_IBSS_MODE == adapter->device_mode)
2139 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2140 else
2141 staid = hddstactx->conn_info.staId[0];
2142
2143 hdd_info("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302144
2145 /* Connections that do not need Upper layer authentication,
2146 * transition TL to 'Authenticated' state after the keys are set
2147 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002148 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302149 hdd_is_roam_sync_in_progress(roaminfo));
2150 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08002151 if ((QDF_STA_MODE == adapter->device_mode) ||
2152 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302153 sme_ps_enable_auto_ps_timer(
2154 WLAN_HDD_GET_HAL_CTX(adapter),
2155 adapter->sessionId,
Dustin Brownf660fb42016-09-09 12:04:00 -07002156 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302157 }
2158
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002159 return qdf_status_to_os_return(status);
2160}
2161
2162/**
2163 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2164 * if key installation is required
2165 * @encr_type: encryption type
2166 *
2167 * Return: true if key installation is required and false otherwise.
2168 */
2169static inline bool hdd_is_key_install_required_for_ibss(
2170 eCsrEncryptionType encr_type)
2171{
2172 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2173 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2174 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
2175 eCSR_ENCRYPT_TYPE_AES == encr_type)
2176 return true;
2177 else
2178 return false;
2179}
2180
2181/**
2182 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2183 * complete
2184 * @adapter: pointer to HDD adapter
2185 * @roaminfo: pointer to roam info
2186 * @roam_result: roam result
2187 *
2188 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2189 * This function checks for the successful set key completion and update
2190 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2191 *
2192 * Return: None
2193 */
2194static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2195 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2196{
2197 tHalHandle hal_ctx = WLAN_HDD_GET_HAL_CTX(adapter);
2198 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
2199 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2200 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2201
2202 /*
2203 * If the security mode is one of the following, IBSS peer will be
2204 * waiting in CONN state and we will move the peer state to AUTH
2205 * here. For non-secure connection, no need to wait for set-key complete
2206 * peer will be moved to AUTH in hdd_roam_register_sta.
2207 */
2208 if (QDF_IBSS_MODE == adapter->device_mode) {
2209 if (hdd_is_key_install_required_for_ibss(encr_type))
2210 hdd_change_sta_state_authenticated(adapter, roaminfo);
2211
2212 return;
2213 }
2214
2215 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2216 hdd_sta_ctx->conn_info.gtk_installed = true;
2217 /*
2218 * PTK exchange happens in preauthentication itself if key_mgmt
2219 * is FT-PSK, ptk_installed was false as there is no set PTK
2220 * after roaming. STA TL state moves to authenticated only if
2221 * ptk_installed is true. So, make ptk_installed to true in
2222 * case of 11R roaming.
2223 */
2224 if (csr_neighbor_roam_is11r_assoc(mac_ctx, adapter->sessionId))
2225 hdd_sta_ctx->conn_info.ptk_installed = true;
2226 } else {
2227 hdd_sta_ctx->conn_info.ptk_installed = true;
2228 }
2229
2230 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2231 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2232 * unicast key and it was resulting in sending few un-encrypted packet.
2233 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2234 * set the unicast and broadcast key.
2235 */
2236 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2237 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2238 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2239 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2240 if (hdd_sta_ctx->conn_info.gtk_installed &&
2241 hdd_sta_ctx->conn_info.ptk_installed)
2242 hdd_change_sta_state_authenticated(adapter, roaminfo);
2243 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2244 hdd_change_sta_state_authenticated(adapter, roaminfo);
2245 }
2246
2247 if (hdd_sta_ctx->conn_info.gtk_installed &&
2248 hdd_sta_ctx->conn_info.ptk_installed) {
2249 hdd_sta_ctx->conn_info.gtk_installed = false;
2250 hdd_sta_ctx->conn_info.ptk_installed = false;
2251 }
2252
2253 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2254
2255 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302256}
2257
2258/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 * hdd_roam_set_key_complete_handler() - Update the security parameters
2260 * @pAdapter: pointer to adapter
2261 * @pRoamInfo: pointer to roam info
2262 * @roamId: roam id
2263 * @roamStatus: roam status
2264 * @roamResult: roam result
2265 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302266 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302268static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 tCsrRoamInfo *pRoamInfo,
2270 uint32_t roamId,
2271 eRoamCmdStatus roamStatus,
2272 eCsrRoamResult roamResult)
2273{
2274 eCsrEncryptionType connectedCipherAlgo;
2275 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302277
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278 ENTER();
2279
2280 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002281 hdd_info("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302282 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 }
2284 /*
2285 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2286 * then go to 'authenticated'. For all other authentication types
2287 * (those that do not require upper layer authentication) we can put TL
2288 * directly into 'authenticated' state.
2289 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002290 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 MAC_ADDRESS_STR, roamStatus, roamResult,
2292 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2293
2294 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2295 &connectedCipherAlgo);
2296 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002297 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2298 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 } else {
2300 /*
2301 * possible disassoc after issuing set key and waiting
2302 * set key complete.
2303 */
2304 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2305 }
2306
2307 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302308 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309}
2310
2311/**
2312 * hdd_perform_roam_set_key_complete() - perform set key complete
2313 * @pAdapter: pointer to adapter
2314 *
2315 * Return: none
2316 */
2317void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2318{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302319 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2321 tCsrRoamInfo roamInfo;
2322 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302323 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302324 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302325 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302326 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302328 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 hdd_roam_set_key_complete_handler(pAdapter,
2330 &roamInfo,
2331 pHddStaCtx->roam_info.roamId,
2332 pHddStaCtx->roam_info.roamStatus,
2333 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302334 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002335 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336
2337 pHddStaCtx->roam_info.deferKeyComplete = false;
2338}
2339
2340/**
2341 * hdd_association_completion_handler() - association completion handler
2342 * @pAdapter: pointer to adapter
2343 * @pRoamInfo: pointer to roam info
2344 * @roamId: roam id
2345 * @roamStatus: roam status
2346 * @roamResult: roam result
2347 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302348 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302350static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 tCsrRoamInfo *pRoamInfo,
2352 uint32_t roamId,
2353 eRoamCmdStatus roamStatus,
2354 eCsrRoamResult roamResult)
2355{
2356 struct net_device *dev = pAdapter->dev;
2357 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2358 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302359 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2361 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 bool hddDisconInProgress = false;
2364 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302365 tSirResultCodes timeout_reason = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366
2367 if (!pHddCtx) {
2368 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302369 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 }
2371
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302372 /* validate config */
2373 if (!pHddCtx->config) {
2374 hdd_err("config is NULL");
2375 return QDF_STATUS_E_NULL_VALUE;
2376 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 /* HDD has initiated disconnect, do not send connect result indication
2378 * to kernel as it will be handled by __cfg80211_disconnect.
2379 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302380 if (((eConnectionState_Disconnecting ==
2381 pHddStaCtx->conn_info.connState) ||
2382 (eConnectionState_NotConnected ==
2383 pHddStaCtx->conn_info.connState)) &&
2384 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2385 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002386 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 hddDisconInProgress = true;
2388 }
2389
2390 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2391 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002392 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302393 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 }
2395 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 hdd_conn_set_connection_state(pAdapter,
2397 eConnectionState_Associated);
2398 }
2399 /* Save the connection info from CSR... */
2400 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2401 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002402
2403 if (hdd_add_beacon_filter(pAdapter) != 0)
2404 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405#ifdef FEATURE_WLAN_WAPI
2406 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2407 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2408 || pRoamInfo->u.pConnectedProfile->AuthType ==
2409 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2410 pAdapter->wapi_info.fIsWapiSta = 1;
2411 } else {
2412 pAdapter->wapi_info.fIsWapiSta = 0;
2413 }
2414#endif /* FEATURE_WLAN_WAPI */
2415
2416 /* Indicate 'connect' status to user space */
2417 hdd_send_association_event(dev, pRoamInfo);
2418
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002419 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 if (pHddCtx->miracast_value)
2421 cds_set_mas(pAdapter, pHddCtx->miracast_value);
2422 }
2423
2424 /* Initialize the Linkup event completion variable */
2425 INIT_COMPLETION(pAdapter->linkup_event_var);
2426
2427 /*
2428 * Sometimes Switching ON the Carrier is taking time to activate
2429 * the device properly. Before allowing any packet to go up to
2430 * the application, device activation has to be ensured for
2431 * proper queue mapping by the kernel. we have registered net
2432 * device notifier for device change notification. With this we
2433 * will come to know that the device is getting
2434 * activated properly.
2435 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002437 /*
2438 * Enable Linkup Event Servicing which allows the net
2439 * device notifier to set the linkup event variable.
2440 */
2441 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002443 /* Switch on the Carrier to activate the device */
2444 wlan_hdd_netif_queue_control(pAdapter,
2445 WLAN_NETIF_CARRIER_ON,
2446 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002448 /*
2449 * Wait for the Link to up to ensure all the queues
2450 * are set properly by the kernel.
2451 */
2452 rc = wait_for_completion_timeout(
2453 &pAdapter->linkup_event_var,
2454 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2455 );
2456 if (!rc)
2457 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002459 /*
2460 * Disable Linkup Event Servicing - no more service
2461 * required from the net device notifier call.
2462 */
2463 pAdapter->isLinkUpSvcNeeded = false;
2464 } else {
2465 pHddStaCtx->ft_carrier_on = false;
2466 ft_carrier_on = true;
2467 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2469 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2470 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002471 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472
2473 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2474
2475 if (hdd_ipa_is_enabled(pHddCtx))
2476 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002477 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 pRoamInfo->bssid.bytes);
2479
2480#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2481 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2482#endif
2483
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302484 hdd_info("check for SAP restart");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002485 cds_check_concurrent_intf_and_restart_sap(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486
Nirav Shah1da77682016-05-03 20:16:39 +05302487 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2488 pAdapter->sessionId,
2489 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 /*
2492 * For reassoc, the station is already registered, all we need
2493 * is to change the state of the STA in TL.
2494 * If authentication is required (WPA/WPA2/DWEP), change TL to
2495 * CONNECTED instead of AUTHENTICATED.
2496 */
2497 if (!pRoamInfo->fReassocReq) {
2498 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 u8 *pFTAssocRsp = NULL;
2500 unsigned int assocRsplen = 0;
2501 u8 *pFTAssocReq = NULL;
2502 unsigned int assocReqlen = 0;
2503 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2505 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2506
2507 /* add bss_id to cfg80211 data base */
2508 bss =
2509 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2510 pRoamInfo);
2511 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302512 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 wlan_hdd_netif_queue_control(pAdapter,
2514 WLAN_NETIF_CARRIER_OFF,
2515 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302516 if (!hddDisconInProgress) {
2517 /*
2518 * Here driver was not able to add bss
2519 * in cfg80211 database this can happen
2520 * if connected channel is not valid,
2521 * i.e reg domain was changed during
2522 * connection. Queue disconnect for the
2523 * session if disconnect is not in
2524 * progress.
2525 */
2526 hdd_err("Disconnecting...");
2527 sme_roam_disconnect(
2528 WLAN_HDD_GET_HAL_CTX(pAdapter),
2529 pAdapter->sessionId,
2530 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2531 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302532 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2535 eCSR_AUTH_TYPE_FT_RSN
2536 || pRoamInfo->u.pConnectedProfile->AuthType ==
2537 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2538
2539 /* Association Response */
2540 pFTAssocRsp =
2541 (u8 *) (pRoamInfo->pbFrames +
2542 pRoamInfo->nBeaconLength +
2543 pRoamInfo->nAssocReqLength);
2544 if (pFTAssocRsp != NULL) {
2545 /*
2546 * pFTAssocRsp needs to point to the IEs
2547 */
2548 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002549 hdd_info("AssocRsp is now at %02x%02x",
2550 (unsigned int)pFTAssocRsp[0],
2551 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 assocRsplen =
2553 pRoamInfo->nAssocRspLength -
2554 FT_ASSOC_RSP_IES_OFFSET;
2555 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002556 hdd_err("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 assocRsplen = 0;
2558 }
2559
2560 /* Association Request */
2561 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2562 pRoamInfo->nBeaconLength);
2563 if (pFTAssocReq != NULL) {
2564 if (!ft_carrier_on) {
2565 /*
2566 * pFTAssocReq needs to point to
2567 * the IEs
2568 */
2569 pFTAssocReq +=
2570 FT_ASSOC_REQ_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002571 hdd_info("pFTAssocReq is now at %02x%02x",
2572 (unsigned int)
2573 pFTAssocReq[0],
2574 (unsigned int)
2575 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 assocReqlen =
2577 pRoamInfo->nAssocReqLength -
2578 FT_ASSOC_REQ_IES_OFFSET;
2579 } else {
2580 /*
2581 * This should contain only the
2582 * FTIEs
2583 */
2584 assocReqlen =
2585 pRoamInfo->nAssocReqLength;
2586 }
2587 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002588 hdd_err("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 assocReqlen = 0;
2590 }
2591
2592 if (ft_carrier_on) {
2593 if (!hddDisconInProgress) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302594 struct cfg80211_bss *roam_bss;
2595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 /*
2597 * After roaming is completed,
2598 * active session count is
2599 * incremented as a part of
2600 * connect indication but
2601 * effectively the active
2602 * session count should still
2603 * be the same and hence upon
2604 * successful reassoc
2605 * decrement the active session
2606 * count here.
2607 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002608 if (!hdd_is_roam_sync_in_progress
2609 (pRoamInfo))
2610 cds_decr_session_set_pcl
2611 (pAdapter->device_mode,
2612 pAdapter->sessionId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002613 hdd_info("ft_carrier_on is %d, sending roamed indication",
2614 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615 chan =
2616 ieee80211_get_channel
2617 (pAdapter->wdev.wiphy,
2618 (int)pRoamInfo->pBssDesc->
2619 channelId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002620 hdd_info(
2621 "assocReqlen %d assocRsplen %d",
2622 assocReqlen,
2623 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002624
2625 hdd_notice(
2626 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302627 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302628 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302629 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002630 pFTAssocReq,
2631 assocReqlen);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302632 roam_bss =
2633 hdd_cfg80211_get_bss(
2634 pAdapter->wdev.wiphy,
2635 chan,
2636 pRoamInfo->bssid.bytes,
2637 pRoamInfo->u.
2638 pConnectedProfile->SSID.ssId,
2639 pRoamInfo->u.
2640 pConnectedProfile->SSID.length);
2641 cfg80211_roamed_bss(dev,
2642 roam_bss,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 pFTAssocReq,
2644 assocReqlen,
2645 pFTAssocRsp,
2646 assocRsplen,
2647 GFP_KERNEL);
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002648 wlan_hdd_send_roam_auth_event(
Prakash Dhavali989127d2016-11-29 14:56:44 +05302649 pAdapter,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002650 pRoamInfo->bssid.bytes,
2651 pFTAssocReq,
2652 assocReqlen,
2653 pFTAssocRsp,
2654 assocRsplen,
2655 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 }
2657 if (sme_get_ftptk_state
2658 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2659 pAdapter->sessionId)) {
2660 sme_set_ftptk_state
2661 (WLAN_HDD_GET_HAL_CTX
2662 (pAdapter),
2663 pAdapter->sessionId,
2664 false);
2665 pRoamInfo->fAuthRequired =
2666 false;
2667
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302668 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 roam_info.bssid,
2670 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302671 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302672 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 roam_info.peerMac,
2674 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302675 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 pHddStaCtx->roam_info.roamId =
2677 roamId;
2678 pHddStaCtx->roam_info.
2679 roamStatus = roamStatus;
2680 pHddStaCtx->roam_info.
2681 deferKeyComplete = true;
2682 }
2683 } else if (!hddDisconInProgress) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002684 hdd_info("ft_carrier_on is %d, sending connect indication",
2685 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302686 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302687 pRoamInfo->
2688 bssid.bytes,
2689 pRoamInfo,
2690 pFTAssocReq,
2691 assocReqlen,
2692 pFTAssocRsp,
2693 assocRsplen,
2694 WLAN_STATUS_SUCCESS,
2695 GFP_KERNEL,
2696 false,
2697 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002699 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 /*
2701 * wpa supplicant expecting WPA/RSN IE in
2702 * connect result.
2703 */
2704 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2705 (pAdapter),
2706 pAdapter->sessionId,
2707 &reqRsnLength,
2708 reqRsnIe);
2709
2710 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2711 (pAdapter),
2712 pAdapter->sessionId,
2713 &rspRsnLength,
2714 rspRsnIe);
2715 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 if (ft_carrier_on)
2717 hdd_send_re_assoc_event(dev,
2718 pAdapter,
2719 pRoamInfo,
2720 reqRsnIe,
2721 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002722 else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002723 hdd_info("sending connect indication to nl80211:for bssid "
2724 MAC_ADDRESS_STR
2725 " result:%d and Status:%d",
2726 MAC_ADDR_ARRAY
2727 (pRoamInfo->bssid.bytes),
2728 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729
2730 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302731 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302732 pRoamInfo->
2733 bssid.bytes,
2734 pRoamInfo,
2735 reqRsnIe,
2736 reqRsnLength,
2737 rspRsnIe,
2738 rspRsnLength,
2739 WLAN_STATUS_SUCCESS,
2740 GFP_KERNEL,
2741 false,
2742 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 }
2744 }
2745 }
2746 if (!hddDisconInProgress) {
2747 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 bss);
2750
2751 /*
2752 * Perform any WMM-related association
2753 * processing.
2754 */
2755 hdd_wmm_assoc(pAdapter, pRoamInfo,
2756 eCSR_BSS_TYPE_INFRASTRUCTURE);
2757
2758 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002759 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002761 qdf_status = hdd_roam_register_sta(pAdapter,
2762 pRoamInfo,
2763 pHddStaCtx->conn_info.staId[0],
2764 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002765 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 wlan_hdd_netif_queue_control(pAdapter,
2767 WLAN_WAKE_ALL_NETIF_QUEUE,
2768 WLAN_CONTROL_PATH);
2769
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 }
2771 } else {
2772 /*
2773 * wpa supplicant expecting WPA/RSN IE in connect result
2774 * in case of reassociation also need to indicate it to
2775 * supplicant.
2776 */
2777 csr_roam_get_wpa_rsn_req_ie(
2778 WLAN_HDD_GET_HAL_CTX(pAdapter),
2779 pAdapter->sessionId,
2780 &reqRsnLength, reqRsnIe);
2781
2782 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2783 reqRsnIe, reqRsnLength);
2784 /* Reassoc successfully */
2785 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302786 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 hdd_change_peer_state(pAdapter,
2788 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002789 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2791 pRoamInfo->roamSynchInProgress
2792#else
2793 false
2794#endif
2795 );
2796 hdd_conn_set_authenticated(pAdapter, false);
2797 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002798 hdd_info("staId: %d Changing TL state to AUTHENTICATED",
2799 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302800 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 hdd_change_peer_state(pAdapter,
2802 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002803 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2805 pRoamInfo->roamSynchInProgress
2806#else
2807 false
2808#endif
2809 );
2810 hdd_conn_set_authenticated(pAdapter, true);
2811 }
2812
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302813 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 /*
2815 * Perform any WMM-related association
2816 * processing
2817 */
2818 hdd_wmm_assoc(pAdapter, pRoamInfo,
2819 eCSR_BSS_TYPE_INFRASTRUCTURE);
2820 }
2821
2822 /* Start the tx queues */
2823#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2824 if (pRoamInfo->roamSynchInProgress)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002825 hdd_info("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002827 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 wlan_hdd_netif_queue_control(pAdapter,
2829 WLAN_WAKE_ALL_NETIF_QUEUE,
2830 WLAN_CONTROL_PATH);
2831 }
2832
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302833#ifdef FEATURE_WLAN_TDLS
2834 wlan_hdd_tdls_connection_callback(pAdapter);
2835#endif
2836
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302837 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002838 hdd_err("STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302839 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 }
2841#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302842 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 sizeof(pAdapter->hdd_stats.hddPmfStats));
2844#endif
2845 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302846 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 hdd_wext_state_t *pWextState =
2848 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2849 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302850 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2851 " result:%d and Status:%d",
2852 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2853 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302855 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2856 " result:%d and Status:%d",
2857 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2858 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302859
2860 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2861 (pRoamInfo &&
2862 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2863 pRoamInfo->statusCode) ||
2864 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2865 pRoamInfo->statusCode) ||
2866 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2867 pRoamInfo->statusCode)))) {
2868 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2869 pRoamInfo ?
2870 pRoamInfo->bssid.bytes :
2871 pWextState->req_bssId.bytes);
2872 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2873 pRoamInfo ?
2874 pRoamInfo->bssid.bytes :
2875 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05302876 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05302877 }
2878
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 /*
2880 * CR465478: Only send up a connection failure result when CSR
2881 * has completed operation - with a ASSOCIATION_FAILURE status.
2882 */
2883 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2884 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302885 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002886 hdd_err("send connect failure to nl80211: for bssid "
2887 MAC_ADDRESS_STR
2888 " result:%d and Status:%d reasoncode %d",
2889 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2890 roamResult, roamStatus,
2891 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302892 pHddStaCtx->conn_info.assoc_status_code =
2893 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08002894 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002895 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 MAC_ADDRESS_STR
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002897 " result:%d and Status:%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2899 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08002900 }
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05302901 hdd_err("Invoking packetdump deregistration API");
2902 wlan_deregister_txrx_packetdump();
2903
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 /* inform association failure event to nl80211 */
2905 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
2906 roamResult) {
2907 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302908 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302910 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302912 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302913 connect_timeout,
2914 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302916 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302918 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302920 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302921 connect_timeout,
2922 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 } else {
Wu Gao77d28352016-11-23 17:50:56 +08002924 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302925 hdd_connect_result(dev,
2926 pRoamInfo->bssid.bytes,
2927 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08002928 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05302929 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302931 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302932 connect_timeout,
2933 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08002934 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302935 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302937 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302939 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302940 connect_timeout,
2941 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 }
Abhishek Singhac2be142015-12-03 16:16:25 +05302943 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002944 } else if ((eCSR_ROAM_CANCELLED == roamStatus
2945 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05302946 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002947 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05302948 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002949 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302950 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302951 connect_timeout,
2952 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 }
2954
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 /*
2956 * Set connection state to eConnectionState_NotConnected only
2957 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002958 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002960 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
2961 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 hdd_conn_set_connection_state(pAdapter,
2964 eConnectionState_NotConnected);
2965 }
2966 hdd_wmm_init(pAdapter);
2967
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002968 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 wlan_hdd_netif_queue_control(pAdapter,
2970 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2971 WLAN_CONTROL_PATH);
2972 }
2973
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302974 if (QDF_STATUS_SUCCESS != cds_check_and_restart_sap(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 roamResult, pHddStaCtx))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302976 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977
Govind Singh24db1ed2015-12-18 15:54:59 +05302978 if (NULL != pRoamInfo && NULL != pRoamInfo->pBssDesc) {
2979 cds_force_sap_on_scc(roamResult,
2980 pRoamInfo->pBssDesc->channelId);
2981 } else {
2982 hdd_err("pRoamInfo profile is not set properly");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302983 return QDF_STATUS_E_FAILURE;
Govind Singh24db1ed2015-12-18 15:54:59 +05302984 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302986 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987}
2988
2989/**
2990 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
2991 * @pAdapter: pointer to adapter
2992 * @pRoamInfo: pointer to roam info
2993 * @roamId: roam id
2994 * @roamStatus: roam status
2995 * @roamResult: roam result
2996 *
2997 * Here we update the status of the Ibss when we receive information that we
2998 * have started/joined an ibss session.
2999 *
3000 * Return: none
3001 */
3002static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3003 tCsrRoamInfo *pRoamInfo,
3004 uint32_t roamId,
3005 eRoamCmdStatus roamStatus,
3006 eCsrRoamResult roamResult)
3007{
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003008 hdd_info("%s: id %d, status %d, result %d",
3009 pAdapter->dev->name, roamId,
3010 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011
3012 switch (roamResult) {
3013 /* both IBSS Started and IBSS Join should come in here. */
3014 case eCSR_ROAM_RESULT_IBSS_STARTED:
3015 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3016 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3017 {
3018 hdd_context_t *pHddCtx =
3019 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303020 hdd_station_ctx_t *hdd_sta_ctx =
3021 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303022 struct qdf_mac_addr broadcastMacAddr =
3023 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024
3025 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303026 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 return;
3028 }
3029
3030 /* When IBSS Started comes from CSR, we need to move
3031 * connection state to IBSS Disconnected (meaning no peers
3032 * are in the IBSS).
3033 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 hdd_conn_set_connection_state(pAdapter,
3035 eConnectionState_IbssDisconnected);
3036 /* notify wmm */
3037 hdd_wmm_connect(pAdapter, pRoamInfo,
3038 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303039
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003040 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303041
3042 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 pAdapter;
3044 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303045 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 &broadcastMacAddr,
3047 pRoamInfo->pBssDesc);
3048
3049 if (pRoamInfo->pBssDesc) {
3050 struct cfg80211_bss *bss;
3051#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3052 struct ieee80211_channel *chan;
3053 int chan_no;
3054 unsigned int freq;
3055#endif
3056 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003057 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3058 pAdapter->dev->name,
3059 MAC_ADDR_ARRAY(
3060 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061
3062 /* we must first give cfg80211 the BSS information */
3063 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3064 pRoamInfo);
3065 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003066 hdd_err("%s: unable to create IBSS entry",
3067 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 return;
3069 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003070 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 wlan_hdd_netif_queue_control(pAdapter,
3072 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3073 WLAN_CONTROL_PATH);
3074
3075#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3076 chan_no = pRoamInfo->pBssDesc->channelId;
3077
3078 if (chan_no <= 14)
3079 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003080 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 else
3082 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003083 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084
3085 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3086
3087 if (chan)
3088 cfg80211_ibss_joined(pAdapter->dev,
3089 bss->bssid, chan,
3090 GFP_KERNEL);
3091 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003092 hdd_err("%s: chanId: %d, can't find channel",
3093 pAdapter->dev->name,
3094 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095#else
3096 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3097 GFP_KERNEL);
3098#endif
3099 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 bss);
3102 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003103 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003104 cds_incr_active_session(pAdapter->device_mode,
Krunal Soni2c68f232015-10-26 20:52:51 -07003105 pAdapter->sessionId);
3106 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3107 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003108 cds_update_connection_info(pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003109 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 break;
3111 }
3112
3113 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3114 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003115 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 break;
3117 }
3118
3119 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003120 hdd_err("%s: unexpected result %d",
3121 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 break;
3123 }
3124
3125 return;
3126}
3127
3128/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003129 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3130 * @sta_ctx: pointer to hdd station context
3131 * @sta_id: station ID
3132 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 *
3134 * This information is passed to iwconfig later. The peer that joined
3135 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003136
3137 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003139bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3140 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003142 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003144 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3145 if (0 == sta_ctx->conn_info.staId[idx]) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003146 hdd_info("adding peer: %pM, sta_id: %d, at idx: %d",
3147 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003148 sta_ctx->conn_info.staId[idx] = sta_id;
3149 qdf_copy_macaddr(
3150 &sta_ctx->conn_info.peerMacAddress[idx],
3151 peer_mac_addr);
3152 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 }
3154 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003155 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156}
3157
3158/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003159 * hdd_delete_peer() - removes peer from hdd station context peer table
3160 * @sta_ctx: pointer to hdd station context
3161 * @sta_id: station ID
3162 *
3163 * Return: None
3164 */
3165void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3166{
3167 int i;
3168
3169 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3170 if (sta_id == sta_ctx->conn_info.staId[i]) {
3171 sta_ctx->conn_info.staId[i] = 0;
3172 return;
3173 }
3174 }
3175
3176 hdd_err(FL("sta_id %d is not present in peer table"), sta_id);
3177}
3178
3179/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3181 * @pAdapter: pointer to adapter
3182 * @staId: station id
3183 *
3184 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003185 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 * false otherwise.
3187 */
3188static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3189{
3190 bool fSuccess = false;
3191 int idx = 0;
3192 uint8_t valid_idx = 0;
3193 uint8_t del_idx = 0;
3194 uint8_t empty_slots = 0;
3195 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3196
Naveen Rawatc45d1622016-07-05 12:20:09 -07003197 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3199 pHddStaCtx->conn_info.staId[idx] = 0;
3200
Anurag Chouhanc5548422016-02-24 18:33:27 +05303201 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 peerMacAddress[idx]);
3203
3204 fSuccess = true;
3205
3206 /*
3207 * Note the deleted Index, if its 0 we need special
3208 * handling.
3209 */
3210 del_idx = idx;
3211
3212 empty_slots++;
3213 } else {
3214 if (pHddStaCtx->conn_info.staId[idx] != 0) {
3215 valid_idx = idx;
3216 } else {
3217 /* Found an empty slot */
3218 empty_slots++;
3219 }
3220 }
3221 }
3222
Naveen Rawatc45d1622016-07-05 12:20:09 -07003223 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 /* Last peer departed, set the IBSS state appropriately */
3225 pHddStaCtx->conn_info.connState =
3226 eConnectionState_IbssDisconnected;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003227 hdd_err("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 }
3229 /* Find next active staId, to have a valid sta trigger for TL. */
3230 if (fSuccess == true) {
3231 if (del_idx == 0) {
3232 if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
3233 pHddStaCtx->conn_info.staId[0] =
3234 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303235 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 peerMacAddress[0],
3237 &pHddStaCtx->conn_info.
3238 peerMacAddress[valid_idx]);
3239
3240 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303241 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 peerMacAddress[valid_idx]);
3243 }
3244 }
3245 }
3246 return fSuccess;
3247}
3248
3249/**
3250 * roam_ibss_connect_handler() - IBSS connection handler
3251 * @pAdapter: pointer to adapter
3252 * @pRoamInfo: pointer to roam info
3253 *
3254 * We update the status of the IBSS to connected in this function.
3255 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303256 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303258static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 tCsrRoamInfo *pRoamInfo)
3260{
3261 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 /*
3263 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3264 * a partner stations).
3265 */
3266 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3267
3268 /* Save the connection info from CSR... */
3269 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3270
3271 /* Send the bssid address to the wext. */
3272 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3273 /* add bss_id to cfg80211 data base */
3274 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3275 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003276 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303278 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 }
3280 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282 bss);
3283
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303284 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285}
3286
3287/**
3288 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3289 * @pAdapter: pointer to adapter
3290 * @pRoamInfo: pointer to roam info
3291 * @roamId: roam id
3292 * @roamStatus: roam status
3293 * @roamResult: roam result
3294 *
3295 * This function indicates the Mic failure to the supplicant
3296 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303297 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303299static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3301 tCsrRoamInfo *pRoamInfo,
3302 uint32_t roamId,
3303 eRoamCmdStatus roamStatus,
3304 eCsrRoamResult roamResult)
3305{
3306 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3307
3308 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3309 TKIP_COUNTER_MEASURE_STOPED ==
3310 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3311 struct iw_michaelmicfailure msg;
3312 union iwreq_data wreq;
3313 memset(&msg, '\0', sizeof(msg));
3314 msg.src_addr.sa_family = ARPHRD_ETHER;
3315 memcpy(msg.src_addr.sa_data,
3316 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3317 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003318 hdd_info("MIC MAC " MAC_ADDRESS_STR,
3319 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320
3321 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3322 msg.flags = IW_MICFAILURE_GROUP;
3323 else
3324 msg.flags = IW_MICFAILURE_PAIRWISE;
3325 memset(&wreq, 0, sizeof(wreq));
3326 wreq.data.length = sizeof(msg);
3327 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3328 (char *)&msg);
3329 /* inform mic failure to nl80211 */
3330 cfg80211_michael_mic_failure(pAdapter->dev,
3331 pRoamInfo->u.pMICFailureInfo->
3332 taMacAddr,
3333 ((pRoamInfo->u.pMICFailureInfo->
3334 multicast ==
3335 eSIR_TRUE) ?
3336 NL80211_KEYTYPE_GROUP :
3337 NL80211_KEYTYPE_PAIRWISE),
3338 pRoamInfo->u.pMICFailureInfo->
3339 keyId,
3340 pRoamInfo->u.pMICFailureInfo->TSC,
3341 GFP_KERNEL);
3342
3343 }
3344
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303345 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346}
3347
3348/**
3349 * roam_roam_connect_status_update_handler() - IBSS connect status update
3350 * @pAdapter: pointer to adapter
3351 * @pRoamInfo: pointer to roam info
3352 * @roamId: roam id
3353 * @roamStatus: roam status
3354 * @roamResult: roam result
3355 *
3356 * The Ibss connection status is updated regularly here in this function.
3357 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303358 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303360static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3362 tCsrRoamInfo *pRoamInfo,
3363 uint32_t roamId,
3364 eRoamCmdStatus roamStatus,
3365 eCsrRoamResult roamResult)
3366{
Rajeev Kumardfa37072017-01-13 16:27:22 -08003367 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003369 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303370
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 switch (roamResult) {
3372 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3373 {
3374 hdd_station_ctx_t *pHddStaCtx =
3375 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003376 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003377 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303379 hdd_err("IBSS New Peer indication from SME "
3380 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3381 MAC_ADDRESS_STR " and stationID= %d",
3382 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3383 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3384 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003386 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3388 pRoamInfo->staId,
3389 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003390 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 break;
3392 }
3393
3394 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3395
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003396 if (hdd_is_key_install_required_for_ibss(encr_type))
3397 pRoamInfo->fAuthRequired = true;
3398
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303400 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401 pRoamInfo,
3402 pRoamInfo->staId,
3403 &pRoamInfo->peerMac,
3404 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303405 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003406 hdd_err("Cannot register STA with TL for IBSS. Failed with qdf_status = %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303407 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 }
3409 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003410 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3411 if (stainfo == NULL) {
3412 hdd_err("memory allocation for station_info failed");
3413 return QDF_STATUS_E_NOMEM;
3414 }
3415 stainfo->filled = 0;
3416 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417
3418 cfg80211_new_sta(pAdapter->dev,
3419 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003420 stainfo, GFP_KERNEL);
3421 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003423 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 pHddStaCtx->ibss_enc_key.keyDirection =
3425 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303426 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 &pRoamInfo->peerMac);
3428
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003429 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003430 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303432 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3434 (pAdapter),
3435 pAdapter->sessionId,
3436 &pHddStaCtx->ibss_enc_key,
3437 &roamId);
3438
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303439 if (QDF_STATUS_SUCCESS != qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003440 hdd_err("sme_roam_set_key failed, status=%d",
3441 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303442 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 }
3444 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003445 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 wlan_hdd_netif_queue_control(pAdapter,
3447 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3448 WLAN_CONTROL_PATH);
3449 break;
3450 }
3451
3452 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3453 {
3454
3455 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3456
3457 break;
3458 }
3459 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3460 {
3461 hdd_station_ctx_t *pHddStaCtx =
3462 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3463
3464 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003465 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303467 hdd_err("IBSS Peer Departed from SME "
3468 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3469 MAC_ADDRESS_STR " and stationID= %d",
3470 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3471 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3472 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473
3474 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3475
3476 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3477 pHddStaCtx->ibss_sta_generation++;
3478
Rajeev Kumardfa37072017-01-13 16:27:22 -08003479 ret = hdd_remove_peer_object(pAdapter->hdd_vdev,
3480 pRoamInfo->peerMac.bytes);
3481 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303482 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
3483 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 cfg80211_del_sta(pAdapter->dev,
3486 (const u8 *)&pRoamInfo->peerMac.bytes,
3487 GFP_KERNEL);
3488 break;
3489 }
3490 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3491 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003492 hdd_info("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003494 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 wlan_hdd_netif_queue_control(pAdapter,
3496 WLAN_NETIF_TX_DISABLE_N_CARRIER,
3497 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 hdd_conn_set_connection_state(pAdapter,
3499 eConnectionState_NotConnected);
3500
3501 /* Send the bssid address to the wext. */
3502 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3503 break;
3504 }
3505 default:
3506 break;
3507
3508 }
3509
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303510 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511}
3512
3513#ifdef FEATURE_WLAN_TDLS
3514/**
3515 * hdd_roam_register_tdlssta() - register new TDLS station
3516 * @pAdapter: pointer to adapter
3517 * @peerMac: pointer to peer MAC address
3518 * @staId: station identifier
3519 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303520 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 *
3522 * Construct the staDesc and register with TL the new STA.
3523 * This is called as part of ADD_STA in the TDLS setup.
3524 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303525 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303527QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303529 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303531 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003533 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003534 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3535 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536
3537 /*
3538 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3539 * be peer MAC, here we are working on direct Link
3540 */
3541 staDesc.sta_id = staId;
3542
3543 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303544 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545
Dhanashri Atre50141c52016-04-07 13:15:29 -07003546 /* Register the vdev transmit and receive functions */
3547 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3548 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003549 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003550 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3551 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003552 pAdapter, &txrx_ops);
3553 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554
3555 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003556 qdf_status = cdp_peer_register(soc,
3557 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303558 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003559 hdd_err("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303560 qdf_status, qdf_status);
3561 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 }
3563
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303564 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565}
3566
3567/**
3568 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3569 * @pAdapter: pointer to adapter
3570 * @staId: station identifier
3571 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303572 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303574static QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575 uint8_t staId)
3576{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303577 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003578 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003579 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3580 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303581 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003582 hdd_warn("cdp_clear_peer() failed for staID %d. Status=%d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003583 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303585 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586}
3587
3588/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003589 * hdd_tdls_connection_tracker_update() - update connection tracker state
3590 * @adapter: pointer to adapter
3591 * @roam_info: pointer to roam info
3592 * @hdd_tdls_ctx: tdls context
3593 *
3594 * Return: QDF_STATUS enumeration
3595 */
3596static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3597 tCsrRoamInfo *roam_info,
3598 tdlsCtx_t *hdd_tdls_ctx)
3599{
3600 hddTdlsPeer_t *curr_peer;
3601 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3602
3603 curr_peer = wlan_hdd_tdls_find_peer(adapter,
3604 roam_info->peerMac.bytes, true);
3605
3606 if (!curr_peer) {
3607 hdd_err("curr_peer is null");
3608 return QDF_STATUS_E_FAILURE;
3609 }
3610
3611 mutex_lock(&hdd_ctx->tdls_lock);
3612
3613 if (eTDLS_LINK_CONNECTED ==
3614 curr_peer->link_status) {
3615 hdd_err("Received CONNECTION_TRACKER_NOTIFICATION "
3616 MAC_ADDRESS_STR
3617 " staId: %d, reason: %d",
3618 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3619 roam_info->staId,
3620 roam_info->reasonCode);
3621
3622 if (roam_info->reasonCode ==
3623 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3624 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003625 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3626 roam_info->reasonCode ==
3627 eWMI_TDLS_SCAN_STARTED_EVENT)
3628 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003629 else if (roam_info->reasonCode ==
3630 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3631 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003632 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3633 roam_info->reasonCode ==
3634 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3635 hdd_ctx->enable_tdls_connection_tracker = true;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003636
3637 } else {
3638 hdd_err("TDLS not connected, ignore notification, reason: %d",
3639 roam_info->reasonCode);
3640 }
3641
3642 mutex_unlock(&hdd_ctx->tdls_lock);
3643
3644 return QDF_STATUS_SUCCESS;
3645}
3646
3647
3648
3649
3650/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3652 * @pAdapter: pointer to adapter
3653 * @pRoamInfo: pointer to roam info
3654 * @roamId: roam id
3655 * @roamStatus: roam status
3656 * @roamResult: roam result
3657 *
3658 * HDD interface between SME and TL to ensure TDLS client registration with
3659 * TL in case of new TDLS client is added and deregistration at the time
3660 * TDLS client is deleted.
3661 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303662 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303664static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3666 tCsrRoamInfo *pRoamInfo,
3667 uint32_t roamId,
3668 eRoamCmdStatus roamStatus,
3669 eCsrRoamResult roamResult)
3670{
3671 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3672 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
3673 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303674 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 uint8_t staIdx;
3676 hddTdlsPeer_t *curr_peer;
3677 uint32_t reason;
3678
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003679 hdd_info("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 roamResult ==
3681 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3682 ==
3683 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3684 roamResult ==
3685 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3686 : roamResult ==
3687 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3688 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3689 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3690 roamResult ==
3691 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3692 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3693 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3694 : roamResult ==
3695 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3696 : roamResult ==
3697 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3698 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3699 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3700
3701 if (!pHddTdlsCtx) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003702 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
3703 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704 return status;
3705 }
3706
3707 switch (roamResult) {
3708 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3709 {
3710 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003711 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303713 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715 } else {
3716 /*
3717 * Check if there is available index for this new TDLS
3718 * STA.
3719 */
3720 for (staIdx = 0;
3721 staIdx < pHddCtx->max_num_tdls_sta;
3722 staIdx++) {
3723 if (0 ==
3724 pHddCtx->tdlsConnInfo[staIdx].
3725 staId) {
3726 pHddCtx->tdlsConnInfo[staIdx].
3727 sessionId =
3728 pRoamInfo->sessionId;
3729 pHddCtx->tdlsConnInfo[staIdx].
3730 staId = pRoamInfo->staId;
3731
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003732 hdd_warn("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003734 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003735 staIdx,
3736 pHddCtx->
3737 tdlsConnInfo[staIdx].
3738 staId,
3739 MAC_ADDR_ARRAY
3740 (pRoamInfo->peerMac.bytes));
3741
Anurag Chouhanc5548422016-02-24 18:33:27 +05303742 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 tdlsConnInfo
3744 [staIdx].
3745 peerMac,
3746 &pRoamInfo->
3747 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303748 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749 break;
3750 }
3751 }
3752 if (staIdx < pHddCtx->max_num_tdls_sta) {
3753 if (-1 ==
3754 wlan_hdd_tdls_set_sta_id(pAdapter,
3755 pRoamInfo->
3756 peerMac.bytes,
3757 pRoamInfo->
3758 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003759 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303760 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761 }
3762
3763 (WLAN_HDD_GET_CTX(pAdapter))->
3764 sta_to_adapter[pRoamInfo->staId] =
3765 pAdapter;
3766 /*
3767 * store the ucast signature,
3768 * if required for further reference.
3769 */
3770
3771 wlan_hdd_tdls_set_signature(pAdapter,
3772 pRoamInfo->
3773 peerMac.bytes,
3774 pRoamInfo->
3775 ucastSig);
3776 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303777 status = QDF_STATUS_E_FAILURE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003778 hdd_err("no available slot in conn_info. staId %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779 pRoamInfo->staId);
3780 }
3781 pAdapter->tdlsAddStaStatus = status;
3782 }
3783 complete(&pAdapter->tdls_add_station_comp);
3784 break;
3785 }
3786 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3787 {
3788 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003789 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 pRoamInfo->statusCode);
3791 }
3792 /* store the ucast signature which will be used later when
3793 * registering to TL
3794 */
3795 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3796 complete(&pAdapter->tdls_add_station_comp);
3797 break;
3798 }
3799 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3800 {
3801 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003802 hdd_err("Link Establish Request failed. status(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 pRoamInfo->statusCode);
3804 }
3805 complete(&pAdapter->tdls_link_establish_req_comp);
3806 break;
3807 }
3808 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3809 {
3810 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3811 staIdx++) {
3812 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3813 pRoamInfo->sessionId)
3814 && pRoamInfo->staId ==
3815 pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003816 hdd_warn("HDD: del STA IDX = %x",
3817 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818
3819 curr_peer =
3820 wlan_hdd_tdls_find_peer(pAdapter,
3821 pRoamInfo->
3822 peerMac.bytes,
3823 true);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303824 if (NULL != curr_peer) {
3825 hdd_info("Current status for peer " MAC_ADDRESS_STR " is %d",
3826 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3827 curr_peer->link_status);
3828 if (TDLS_IS_CONNECTED(curr_peer)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829 hdd_roam_deregister_tdlssta
3830 (pAdapter,
3831 pRoamInfo->staId);
3832 wlan_hdd_tdls_decrement_peer_count
3833 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303834 } else if (eTDLS_LINK_CONNECTING ==
3835 curr_peer->link_status) {
3836 hdd_roam_deregister_tdlssta
3837 (pAdapter,
3838 pRoamInfo->staId);
3839 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 }
3841 wlan_hdd_tdls_reset_peer(pAdapter,
3842 pRoamInfo->
3843 peerMac.bytes);
3844
3845 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3846 pHddCtx->tdlsConnInfo[staIdx].
3847 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303848 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 tdlsConnInfo[staIdx].
3850 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303851 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303852 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 break;
3854 }
3855 }
3856 complete(&pAdapter->tdls_del_station_comp);
3857 }
3858 break;
3859 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3860 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003861 hdd_err("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 pRoamInfo->reasonCode);
3863
3864 curr_peer =
3865 wlan_hdd_tdls_find_peer(pAdapter,
3866 pRoamInfo->peerMac.bytes, true);
3867 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
3868 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303869 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3870 curr_peer->peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303871 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 break;
3873 }
3874 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3875 {
3876 /* 0 staIdx is assigned to AP we dont want to touch that */
3877 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3878 staIdx++) {
3879 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3880 pRoamInfo->sessionId)
3881 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003882 hdd_warn("hdd_tdlsStatusUpdate: staIdx %d "
3883 MAC_ADDRESS_STR,
3884 pHddCtx->tdlsConnInfo[staIdx].
3885 staId,
3886 MAC_ADDR_ARRAY(pHddCtx->
3887 tdlsConnInfo
3888 [staIdx].
3889 peerMac.
3890 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 wlan_hdd_tdls_reset_peer(pAdapter,
3892 pHddCtx->
3893 tdlsConnInfo
3894 [staIdx].
3895 peerMac.bytes);
3896 hdd_roam_deregister_tdlssta(pAdapter,
3897 pHddCtx->
3898 tdlsConnInfo
3899 [staIdx].
3900 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303901 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902 sizeof
3903 (smeTdlsPeerStateParams));
3904 smeTdlsPeerStateParams.vdevId =
3905 pHddCtx->tdlsConnInfo[staIdx].
3906 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303907 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 peerMacAddr,
3909 &pHddCtx->
3910 tdlsConnInfo[staIdx].
3911 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303912 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 smeTdlsPeerStateParams.peerState =
3914 eSME_TDLS_PEER_STATE_TEARDOWN;
3915
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003916 hdd_info("calling sme_update_tdls_peer_state for staIdx %d "
3917 MAC_ADDRESS_STR,
3918 pHddCtx->tdlsConnInfo[staIdx].
3919 staId,
3920 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921 tdlsConnInfo
3922 [staIdx].
3923 peerMac.
3924 bytes));
3925 status =
3926 sme_update_tdls_peer_state(
3927 pHddCtx->hHal,
3928 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303929 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003930 hdd_err("sme_update_tdls_peer_state failed for "
3931 MAC_ADDRESS_STR,
3932 MAC_ADDR_ARRAY
3933 (pHddCtx->
3934 tdlsConnInfo[staIdx].
3935 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 }
3937 wlan_hdd_tdls_decrement_peer_count
3938 (pAdapter);
3939
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303940 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 tdlsConnInfo[staIdx].
3942 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303943 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3945 pHddCtx->tdlsConnInfo[staIdx].
3946 sessionId = 255;
3947
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303948 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 }
3950 }
3951 break;
3952 }
3953 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
3954 {
3955 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07003956 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
3957 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303958 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 break;
3960 }
3961
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07003962 if (pHddCtx->tdls_nss_switch_in_progress) {
3963 hdd_err("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
3964 status = QDF_STATUS_SUCCESS;
3965 break;
3966 }
3967
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 curr_peer =
3969 wlan_hdd_tdls_get_peer(pAdapter,
Kabilan Kannan36090ce2016-05-03 19:28:44 -07003970 pRoamInfo->peerMac.bytes,
3971 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303973 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303974 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 } else {
3976 if (eTDLS_LINK_CONNECTED ==
3977 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003978 hdd_err("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 } else {
3980 /*
3981 * If external control is enabled then initiate
3982 * TDLS only if forced peer is set otherwise
3983 * ignore should Discover trigger from fw.
3984 */
3985 if (pHddCtx->config->
3986 fTDLSExternalControl
3987 && (false ==
3988 curr_peer->isForcedPeer)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003989 hdd_info("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303990 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 }
Jeff Johnson68755312017-02-10 11:46:55 -08003993 hdd_info("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
3994 pHddCtx->config->
3995 fTDLSExternalControl,
3996 curr_peer->isForcedPeer,
3997 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05303998 pHddTdlsCtx->curr_candidate = curr_peer;
3999 wlan_hdd_tdls_implicit_send_discovery_request(
4000 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304002 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 }
4004 break;
4005 }
4006
4007 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4008 {
4009 curr_peer =
4010 wlan_hdd_tdls_find_peer(pAdapter,
4011 pRoamInfo->peerMac.bytes, true);
4012 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05304013 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304014 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 } else {
4016 if (eTDLS_LINK_CONNECTED ==
4017 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004018 hdd_err("Received SHOULD_TEARDOWN for peer "
4019 MAC_ADDRESS_STR
4020 " staId: %d, reason: %d",
4021 MAC_ADDR_ARRAY(pRoamInfo->
4022 peerMac.bytes),
4023 pRoamInfo->staId,
4024 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025
4026 if (pRoamInfo->reasonCode ==
4027 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4028 pRoamInfo->reasonCode ==
4029 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4030 pRoamInfo->reasonCode ==
4031 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4032 pRoamInfo->reasonCode ==
4033 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4034 reason =
4035 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4036 } else
4037 reason =
4038 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4039
4040 wlan_hdd_tdls_indicate_teardown
4041 (pHddTdlsCtx->pAdapter, curr_peer,
4042 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304043 hdd_send_wlan_tdls_teardown_event(
4044 eTDLS_TEARDOWN_BSS_DISCONNECT,
4045 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004047 hdd_err("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
4048 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304050 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 }
4052 break;
4053 }
4054
4055 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4056 {
4057 curr_peer =
4058 wlan_hdd_tdls_find_peer(pAdapter,
4059 pRoamInfo->peerMac.bytes, true);
4060 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05304061 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304062 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063 } else {
4064 if (eTDLS_LINK_CONNECTED ==
4065 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004066 hdd_err("Received SHOULD_PEER_DISCONNECTED for peer "
4067 MAC_ADDRESS_STR
4068 " staId: %d, reason: %d",
4069 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4070 pRoamInfo->staId,
4071 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072
4073 if (pRoamInfo->reasonCode ==
4074 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4075 pRoamInfo->reasonCode ==
4076 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4077 pRoamInfo->reasonCode ==
4078 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4079 pRoamInfo->reasonCode ==
4080 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4081 reason =
4082 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4083 } else
4084 reason =
4085 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4086
4087 wlan_hdd_tdls_indicate_teardown
4088 (pHddTdlsCtx->pAdapter, curr_peer,
4089 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304090 hdd_send_wlan_tdls_teardown_event(
4091 eTDLS_TEARDOWN_BSS_DISCONNECT,
4092 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004094 hdd_err("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
4095 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304097 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 }
4099 break;
4100 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004101
4102 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
4103 status = hdd_tdls_connection_tracker_update(pAdapter,
4104 pRoamInfo,
4105 pHddTdlsCtx);
4106 break;
4107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004108 default:
4109 {
4110 break;
4111 }
4112 }
4113
4114 return status;
4115}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004116#else
4117
4118static inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
4119 uint8_t staId)
4120{
4121 return QDF_STATUS_SUCCESS;
4122}
4123
4124static inline QDF_STATUS
4125hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4126 tCsrRoamInfo *pRoamInfo,
4127 uint32_t roamId,
4128 eRoamCmdStatus roamStatus,
4129 eCsrRoamResult roamResult)
4130{
4131 return QDF_STATUS_SUCCESS;
4132}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133#endif
4134
4135#ifdef WLAN_FEATURE_11W
4136/**
4137 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4138 * @pAdapter: pointer to the adapter
4139 * @nFrameLength: Length of the unprotected frame being passed
4140 * @pbFrames: Pointer to the frame buffer
4141 * @frameType: 802.11 frame type
4142 *
4143 * This function forwards the unprotected management frame to the supplicant.
4144 *
4145 * Return: nothing
4146 */
4147static void
4148hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4149 uint8_t *pbFrames, uint8_t frameType)
4150{
4151 uint8_t type = 0;
4152 uint8_t subType = 0;
4153
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004154 hdd_info("Frame Type = %d Frame Length = %d",
4155 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156
4157 /* Sanity Checks */
4158 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004159 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 return;
4161 }
4162
4163 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004164 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 return;
4166 }
4167
4168 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004169 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 return;
4171 }
4172
4173 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004174 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 return;
4176 }
4177
4178 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004179 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 return;
4181 }
4182
4183 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4184 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4185
4186 /* Get pAdapter from Destination mac address of the frame */
4187 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4188#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4189 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4190 nFrameLength);
4191#else
4192 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4193 nFrameLength);
4194#endif
4195 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4196 } else if (type == SIR_MAC_MGMT_FRAME &&
4197 subType == SIR_MAC_MGMT_DEAUTH) {
4198#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4199 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4200 nFrameLength);
4201#else
4202 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4203 nFrameLength);
4204#endif
4205 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4206 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004207 hdd_err("Frame type %d and subtype %d are not valid",
4208 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 return;
4210 }
4211}
4212#endif
4213
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004214#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215/**
4216 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4217 * @pAdapter: pointer to adapter
4218 * @tid: traffic identifier
4219 * @state: state
4220 * @measInterval: measurement interval
4221 *
4222 * This function sends traffic stream metrics IE information to
4223 * the supplicant via wireless event.
4224 *
4225 * Return: none
4226 */
4227static void
4228hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4229 uint8_t state, uint16_t measInterval)
4230{
4231 union iwreq_data wrqu;
4232 char buf[IW_CUSTOM_MAX + 1];
4233 int nBytes = 0;
4234
4235 if (NULL == pAdapter)
4236 return;
4237
4238 /* create the event */
4239 memset(&wrqu, '\0', sizeof(wrqu));
4240 memset(buf, '\0', sizeof(buf));
4241
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004242 hdd_info("TSM Ind tid(%d) state(%d) MeasInt(%d)",
4243 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244
4245 nBytes =
4246 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4247 measInterval);
4248
4249 wrqu.data.pointer = buf;
4250 wrqu.data.length = nBytes;
4251 /* send the event */
4252 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4253}
4254
4255/**
4256 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4257 * @pAdapter: pointer to adapter
4258 * @pRoamInfo: pointer to roam info
4259 *
4260 * This function sends cckm preauth indication to the supplicant
4261 * via wireless custom event.
4262 *
4263 * Return: none
4264 */
4265static void
4266hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4267{
4268 union iwreq_data wrqu;
4269 char buf[IW_CUSTOM_MAX + 1];
4270 char *pos = buf;
4271 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4272
4273 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4274 return;
4275
4276 /* create the event */
4277 memset(&wrqu, '\0', sizeof(wrqu));
4278 memset(buf, '\0', sizeof(buf));
4279
4280 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004281 hdd_info("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
4282 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4283 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284
4285 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4286 pos += nBytes;
4287 freeBytes -= nBytes;
4288
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304289 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304290 pos += QDF_MAC_ADDR_SIZE;
4291 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292
4293 nBytes = snprintf(pos, freeBytes, " %u:%u",
4294 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4295 freeBytes -= nBytes;
4296
4297 wrqu.data.pointer = buf;
4298 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4299
4300 /* send the event */
4301 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4302}
4303
4304/**
4305 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4306 * @pAdapter: pointer to adapter
4307 * @pRoamInfo: pointer to roam info
4308 *
4309 * Return: none
4310 */
4311static void
4312hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4313 tCsrRoamInfo *pRoamInfo)
4314{
4315 union iwreq_data wrqu;
4316 char buf[IW_CUSTOM_MAX + 1];
4317 int nBytes = 0;
4318
4319 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4320 return;
4321
4322 /* create the event */
4323 memset(&wrqu, '\0', sizeof(wrqu));
4324 memset(buf, '\0', sizeof(buf));
4325
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004326 hdd_info("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327
4328 nBytes =
4329 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4330 pRoamInfo->tsmRoamDelay);
4331
4332 wrqu.data.pointer = buf;
4333 wrqu.data.length = nBytes;
4334
4335 /* send the event */
4336 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4337}
4338
4339/**
4340 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4341 * @pAdapter: pointer to adapter
4342 * @measurementToken: measurement token
4343 * @flag: flag
4344 * @numBss: number of bss
4345 *
4346 * If the measurement is none and no scan results found,
4347 * indicate the supplicant about measurement done.
4348 *
4349 * Return: none
4350 */
4351void
4352hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4353 const uint16_t measurementToken,
4354 const bool flag, const uint8_t numBss)
4355{
4356 union iwreq_data wrqu;
4357 char buf[IW_CUSTOM_MAX];
4358 char *pos = buf;
4359 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4360
4361 memset(&wrqu, '\0', sizeof(wrqu));
4362 memset(buf, '\0', sizeof(buf));
4363
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004364 hdd_info("CCXBCNREP=%d %d %d", measurementToken,
4365 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366
4367 nBytes =
4368 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4369 flag, numBss);
4370
4371 wrqu.data.pointer = buf;
4372 wrqu.data.length = nBytes;
4373 /* send the event */
4374 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4375}
4376
4377/**
4378 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4379 * @pAdapter: pointer to adapter
4380 * @pRoamInfo: pointer to roam info
4381 *
4382 * If the measurement is none and no scan results found,
4383 * indicate the supplicant about measurement done.
4384 *
4385 * Return: none
4386 */
4387static void
4388hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4389 const tCsrRoamInfo *pRoamInfo)
4390{
4391 union iwreq_data wrqu;
4392 char buf[IW_CUSTOM_MAX];
4393 char *pos = buf;
4394 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4395 uint8_t i = 0, len = 0;
4396 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4397 uint8_t lastSent = 0, sendBss = 0;
4398 int bcnRepFieldSize =
4399 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4400 bcnReportFields);
4401 uint8_t ieLenByte = 1;
4402 /*
4403 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4404 */
4405#define ESEBCNREPHEADER_LEN (18)
4406
4407 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4408 return;
4409
4410 /*
4411 * Custom event can pass maximum of 256 bytes of data,
4412 * based on the IE len we need to identify how many BSS info can
4413 * be filled in to custom event data.
4414 */
4415 /*
4416 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4417 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4418 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4419 */
4420
4421 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4422 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004423 hdd_info("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004425 * indicate the supplicant about measurement done
4426 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004427 hdd_indicate_ese_bcn_report_no_results(
4428 pAdapter,
4429 pRoamInfo->pEseBcnReportRsp->
4430 measurementToken,
4431 pRoamInfo->pEseBcnReportRsp->flag,
4432 pRoamInfo->pEseBcnReportRsp->numBss);
4433 } else {
4434 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4435 memset(&wrqu, '\0', sizeof(wrqu));
4436 memset(buf, '\0', sizeof(buf));
4437 tot_bcn_ieLen = 0;
4438 sendBss = 0;
4439 pos = buf;
4440 freeBytes = IW_CUSTOM_MAX;
4441
4442 for (i = lastSent;
4443 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4444 len =
4445 bcnRepFieldSize + ieLenByte +
4446 pRoamInfo->pEseBcnReportRsp->
4447 bcnRepBssInfo[i].ieLen;
4448 if ((len + tot_bcn_ieLen) >
4449 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4450 break;
4451 }
4452 tot_bcn_ieLen += len;
4453 sendBss++;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004454 hdd_info("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
4455 i, bcnRepFieldSize, 1,
4456 pRoamInfo->pEseBcnReportRsp->
4457 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 }
4459
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004460 hdd_info("Sending %d BSS Info", sendBss);
4461 hdd_info("CCXBCNREP=%d %d %d %d",
4462 pRoamInfo->pEseBcnReportRsp->measurementToken,
4463 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4464 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465
4466 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4467 pRoamInfo->pEseBcnReportRsp->
4468 measurementToken,
4469 pRoamInfo->pEseBcnReportRsp->flag,
4470 sendBss);
4471 pos += nBytes;
4472 freeBytes -= nBytes;
4473
4474 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304475 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476 sizeof(tot_bcn_ieLen));
4477 pos += sizeof(tot_bcn_ieLen);
4478 freeBytes -= sizeof(tot_bcn_ieLen);
4479
4480 for (i = 0; i < sendBss; i++) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004481 hdd_info("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4483 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4484 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4485 pRoamInfo->pEseBcnReportRsp->
4486 bcnRepBssInfo[i +
4487 lastSent].bcnReportFields.
4488 ChanNum,
4489 pRoamInfo->pEseBcnReportRsp->
4490 bcnRepBssInfo[i +
4491 lastSent].bcnReportFields.
4492 Spare,
4493 pRoamInfo->pEseBcnReportRsp->
4494 bcnRepBssInfo[i +
4495 lastSent].bcnReportFields.
4496 MeasDuration,
4497 pRoamInfo->pEseBcnReportRsp->
4498 bcnRepBssInfo[i +
4499 lastSent].bcnReportFields.
4500 PhyType,
4501 pRoamInfo->pEseBcnReportRsp->
4502 bcnRepBssInfo[i +
4503 lastSent].bcnReportFields.
4504 RecvSigPower,
4505 pRoamInfo->pEseBcnReportRsp->
4506 bcnRepBssInfo[i +
4507 lastSent].bcnReportFields.
4508 ParentTsf,
4509 pRoamInfo->pEseBcnReportRsp->
4510 bcnRepBssInfo[i +
4511 lastSent].bcnReportFields.
4512 TargetTsf[0],
4513 pRoamInfo->pEseBcnReportRsp->
4514 bcnRepBssInfo[i +
4515 lastSent].bcnReportFields.
4516 TargetTsf[1],
4517 pRoamInfo->pEseBcnReportRsp->
4518 bcnRepBssInfo[i +
4519 lastSent].bcnReportFields.
4520 BcnInterval,
4521 pRoamInfo->pEseBcnReportRsp->
4522 bcnRepBssInfo[i +
4523 lastSent].bcnReportFields.
4524 CapabilityInfo,
4525 pRoamInfo->pEseBcnReportRsp->
4526 bcnRepBssInfo[i +
4527 lastSent].bcnReportFields.
4528 Bssid[0],
4529 pRoamInfo->pEseBcnReportRsp->
4530 bcnRepBssInfo[i +
4531 lastSent].bcnReportFields.
4532 Bssid[1],
4533 pRoamInfo->pEseBcnReportRsp->
4534 bcnRepBssInfo[i +
4535 lastSent].bcnReportFields.
4536 Bssid[2],
4537 pRoamInfo->pEseBcnReportRsp->
4538 bcnRepBssInfo[i +
4539 lastSent].bcnReportFields.
4540 Bssid[3],
4541 pRoamInfo->pEseBcnReportRsp->
4542 bcnRepBssInfo[i +
4543 lastSent].bcnReportFields.
4544 Bssid[4],
4545 pRoamInfo->pEseBcnReportRsp->
4546 bcnRepBssInfo[i +
4547 lastSent].bcnReportFields.
4548 Bssid[5]);
4549
4550 /* bcn report fields are copied */
4551 len =
4552 sizeof(pRoamInfo->pEseBcnReportRsp->
4553 bcnRepBssInfo[i +
4554 lastSent].
4555 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304556 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 (char *)&pRoamInfo->
4558 pEseBcnReportRsp->bcnRepBssInfo[i +
4559 lastSent].
4560 bcnReportFields, len);
4561 pos += len;
4562 freeBytes -= len;
4563
4564 /* Add 1 byte of ie len */
4565 len =
4566 pRoamInfo->pEseBcnReportRsp->
4567 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304568 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 pos += sizeof(len);
4570 freeBytes -= sizeof(len);
4571
4572 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304573 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 (char *)pRoamInfo->
4575 pEseBcnReportRsp->bcnRepBssInfo[i +
4576 lastSent].
4577 pBuf, len);
4578 pos += len;
4579 freeBytes -= len;
4580 }
4581
4582 wrqu.data.pointer = buf;
4583 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4584
4585 /* send the event */
4586 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4587 buf);
4588 lastSent += sendBss;
4589 }
4590 }
4591}
4592
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004593#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594
4595/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304596 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4597 * @pHddStaCtx: Station Context
4598 *
4599 * API to check if the connection authentication type is 8021x_sha256.
4600 *
4601 * Return: bool
4602 */
4603#ifdef WLAN_FEATURE_11W
4604static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4605{
4606 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4607 pHddStaCtx->conn_info.authType;
4608}
4609#else
4610static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4611{
4612 return false;
4613}
4614#endif
4615
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304616/*
4617 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4618 * @adapter: Pointer to adapter context
4619 * @roam_info: Pointer to roam info
4620 *
4621 * Return: None
4622 */
4623static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4624 tCsrRoamInfo *roam_info)
4625{
4626 struct hdd_chan_change_params chan_change;
4627 struct cfg80211_bss *bss;
4628 struct net_device *dev = adapter->dev;
4629 struct wireless_dev *wdev = dev->ieee80211_ptr;
4630 struct wiphy *wiphy = wdev->wiphy;
4631 QDF_STATUS status;
4632
4633 hdd_info("channel switch for session:%d to channel:%d",
4634 adapter->sessionId, roam_info->chan_info.chan_id);
4635
4636 chan_change.chan = roam_info->chan_info.chan_id;
4637 chan_change.chan_params.ch_width =
4638 roam_info->chan_info.ch_width;
4639 chan_change.chan_params.sec_ch_offset =
4640 roam_info->chan_info.sec_ch_offset;
4641 chan_change.chan_params.center_freq_seg0 =
4642 roam_info->chan_info.band_center_freq1;
4643 chan_change.chan_params.center_freq_seg1 =
4644 roam_info->chan_info.band_center_freq2;
4645
4646 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4647 if (NULL == bss)
4648 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4649 else
4650 cfg80211_put_bss(wiphy, bss);
4651
4652 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4653 if (QDF_IS_STATUS_ERROR(status))
4654 hdd_err("channel change notification failed");
4655
4656 status = cds_set_hw_mode_on_channel_switch(adapter->sessionId);
4657 if (QDF_IS_STATUS_ERROR(status))
4658 hdd_info("set hw mode change not done");
4659}
4660
Komal Seelam98760ba2015-12-15 11:05:18 +05304661/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 * hdd_sme_roam_callback() - hdd sme roam callback
4663 * @pContext: pointer to adapter context
4664 * @pRoamInfo: pointer to roam info
4665 * @roamId: roam id
4666 * @roamStatus: roam status
4667 * @roamResult: roam result
4668 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304669 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304671QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4673 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4674{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304675 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4677 hdd_wext_state_t *pWextState = NULL;
4678 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304679 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304680 struct cfg80211_bss *bss_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004682 hdd_info("CSR Callback: status= %d result= %d roamID=%d",
4683 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684
4685 /* Sanity check */
4686 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004687 hdd_alert("invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304688 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004689 }
4690
4691 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4692 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4693
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304694 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304695 pAdapter->sessionId, roamStatus));
4696
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697 switch (roamStatus) {
4698 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304699 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4700 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004701 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 break;
4703
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 /*
4705 * We did pre-auth,then we attempted a 11r or ese reassoc.
4706 * reassoc failed due to failure, timeout, reject from ap
4707 * in any case tell the OS, our carrier is off and mark
4708 * interface down.
4709 */
4710 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004711 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4712 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304713 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4715 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 pHddStaCtx->ft_carrier_on = false;
4717 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004718 hdd_info("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
4719 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720 break;
4721
4722 case eCSR_ROAM_FT_START:
4723 /*
4724 * When we roam for ESE and 11r, we dont want the OS to be
4725 * informed that the link is down. So mark the link ready for
4726 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4727 * be received. Where in we will not mark the link down
4728 * Also we want to stop tx at this point when we will be
4729 * doing disassoc at this time. This saves 30-60 msec
4730 * after reassoc.
4731 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004732 hdd_info("Disabling queues");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004733 hdd_info("Roam Synch Ind: NAPI Serialize ON");
4734 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004735 wlan_hdd_netif_queue_control(pAdapter,
4736 WLAN_NETIF_TX_DISABLE,
4737 WLAN_CONTROL_PATH);
4738 status = hdd_roam_deregister_sta(pAdapter,
4739 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304740 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304741 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 pHddStaCtx->ft_carrier_on = true;
4743 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004744 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4745 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004747 case eCSR_ROAM_NAPI_OFF:
4748 hdd_info("After Roam Synch Comp: NAPI Serialize OFF");
4749 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004750 hdd_set_roaming_in_progress(false);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004751 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004754 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 wlan_hdd_netif_queue_control(pAdapter,
4756 WLAN_NETIF_TX_DISABLE,
4757 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 wlan_hdd_netif_queue_control(pAdapter,
4760 WLAN_NETIF_CARRIER_OFF,
4761 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 break;
4764 case eCSR_ROAM_LOSTLINK:
4765 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004766 hdd_info("Roaming started due to connection lost");
4767 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 wlan_hdd_netif_queue_control(pAdapter,
4769 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4770 WLAN_CONTROL_PATH);
4771 break;
4772 }
4773 case eCSR_ROAM_DISASSOCIATED:
4774 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004775 hdd_info("****eCSR_ROAM_DISASSOCIATED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776 /* Call to clear any MC Addr List filter applied after
4777 * successful connection.
4778 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304779 hdd_disable_and_flush_mc_addr_list(pAdapter,
4780 pmo_peer_disconnect);
4781 qdf_ret_status =
4782 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4783 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004784 }
4785 break;
4786 case eCSR_ROAM_IBSS_LEAVE:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004787 hdd_info("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304788 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4790 roamStatus, roamResult);
4791 break;
4792 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004793 hdd_info("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 /*
4795 * To Do - address probable memory leak with WEP encryption upon
4796 * successful association.
4797 */
4798 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4799 /* Clear saved connection information in HDD */
4800 hdd_conn_remove_connect_info(
4801 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4802 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304803 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004804 hdd_association_completion_handler(pAdapter, pRoamInfo,
4805 roamId, roamStatus,
4806 roamResult);
4807#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4808 if (pRoamInfo)
4809 pRoamInfo->roamSynchInProgress = false;
4810#endif
4811 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004812 case eCSR_ROAM_CANCELLED:
4813 hdd_info("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304815 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004816 pRoamInfo,
4817 roamId,
4818 roamStatus,
4819 roamResult);
4820 break;
4821 case eCSR_ROAM_IBSS_IND:
4822 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4823 roamStatus, roamResult);
4824 break;
4825
4826 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304827 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828 roam_roam_connect_status_update_handler(pAdapter,
4829 pRoamInfo,
4830 roamId,
4831 roamStatus,
4832 roamResult);
4833 break;
4834
4835 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304836 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837 hdd_roam_mic_error_indication_handler(pAdapter,
4838 pRoamInfo,
4839 roamId,
4840 roamStatus,
4841 roamResult);
4842 break;
4843
4844 case eCSR_ROAM_SET_KEY_COMPLETE:
4845 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304846 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4848 roamId, roamStatus,
4849 roamResult);
4850 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4851 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004852 hdd_info("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 pHddStaCtx->hdd_ReassocScenario,
4854 pAdapter->sessionId);
4855 }
4856 }
4857#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4858 if (pRoamInfo != NULL)
4859 pRoamInfo->roamSynchInProgress = false;
4860#endif
4861 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 case eCSR_ROAM_FT_RESPONSE:
4864 hdd_send_ft_event(pAdapter);
4865 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004867 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304868 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4869 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304871 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 wlan_hdd_cfg80211_pmksa_candidate_notify(
4873 pAdapter, pRoamInfo, 1, false);
4874 }
4875 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876
4877#ifdef FEATURE_WLAN_LFR_METRICS
4878 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4879 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304880 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4882 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304883 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884 }
4885 break;
4886 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4887 /*
4888 * This event will notify pre-auth completion in case of success
4889 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304890 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4892 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304893 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894 }
4895 break;
4896 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4897 /*
4898 * This event will notify pre-auth completion incase of failure.
4899 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304900 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4902 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304903 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904 }
4905 break;
4906 case eCSR_ROAM_HANDOVER_SUCCESS:
4907 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004908 * It will be only invoked on success
4909 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304910 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4912 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304913 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 }
4915 break;
4916#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 case eCSR_ROAM_REMAIN_CHAN_READY:
4918 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4919 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920#ifdef FEATURE_WLAN_TDLS
4921 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304922 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004923 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4924 roamId,
4925 roamStatus,
4926 roamResult);
4927 break;
4928 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4929 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4930 pRoamInfo->reasonCode);
4931 break;
4932#endif
4933#ifdef WLAN_FEATURE_11W
4934 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4935 hdd_indicate_unprot_mgmt_frame(pAdapter,
4936 pRoamInfo->nFrameLength,
4937 pRoamInfo->pbFrames,
4938 pRoamInfo->frameType);
4939 break;
4940#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004941#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 case eCSR_ROAM_TSM_IE_IND:
4943 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
4944 pRoamInfo->tsmIe.state,
4945 pRoamInfo->tsmIe.msmt_interval);
4946 break;
4947
4948 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4949 {
4950 if (eCSR_AUTH_TYPE_CCKM_WPA ==
4951 pHddStaCtx->conn_info.authType
4952 || eCSR_AUTH_TYPE_CCKM_RSN ==
4953 pHddStaCtx->conn_info.authType) {
4954 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
4955 }
4956 break;
4957 }
4958
4959 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4960 {
4961 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
4962 break;
4963 }
4964
4965 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4966 {
4967 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
4968 break;
4969 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004970#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304971 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304972 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304973 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304974
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304975 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4976 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
4977 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
4978 pAdapter, pRoamInfo->pBssDesc);
4979 if (NULL == bss_status)
4980 hdd_info("UPDATE_SCAN_RESULT returned NULL");
4981 else
4982 cfg80211_put_bss(
4983#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4984 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4985#endif
4986 bss_status);
4987 }
4988 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004989 case eCSR_ROAM_NDP_STATUS_UPDATE:
4990 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
4991 roamResult);
4992 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004993 case eCSR_ROAM_START:
4994 hdd_info("Process ROAM_START from firmware");
4995 wlan_hdd_netif_queue_control(pAdapter,
4996 WLAN_NETIF_TX_DISABLE,
4997 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004998 hdd_napi_serialize(1);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004999 cds_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005000 hdd_set_roaming_in_progress(true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005001 cds_restart_opportunistic_timer(true);
5002 break;
5003 case eCSR_ROAM_ABORT:
5004 hdd_info("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005005 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005006 wlan_hdd_netif_queue_control(pAdapter,
5007 WLAN_WAKE_ALL_NETIF_QUEUE,
5008 WLAN_CONTROL_PATH);
5009 cds_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005010 hdd_set_roaming_in_progress(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005011 break;
5012
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013 default:
5014 break;
5015 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305016 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017}
5018
5019/**
5020 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5021 * @auth_suite: auth suite
5022 *
5023 * Return: eCsrAuthType enumeration
5024 */
5025eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5026{
5027 eCsrAuthType auth_type;
5028 /* is the auth type supported? */
5029 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5030 auth_type = eCSR_AUTH_TYPE_RSN;
5031 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5032 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005033 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005034 /* Check for 11r FT Authentication with PSK */
5035 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5036 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5037 /* Check for 11R FT Authentication with 802.1X */
5038 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5039 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040#ifdef FEATURE_WLAN_ESE
5041 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5042 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5043 } else
5044#endif /* FEATURE_WLAN_ESE */
5045#ifdef WLAN_FEATURE_11W
5046 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5047 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5048 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5049 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5050 } else
5051#endif
5052 {
5053 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5054 }
5055 return auth_type;
5056}
5057
5058/**
5059 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5060 * @auth_suite: auth suite
5061 *
5062 * Return: eCsrAuthType enumeration
5063 */
5064eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5065{
5066 eCsrAuthType auth_type;
5067 /* is the auth type supported? */
5068 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5069 auth_type = eCSR_AUTH_TYPE_WPA;
5070 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5071 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5072 } else
5073#ifdef FEATURE_WLAN_ESE
5074 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5075 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5076 } else
5077#endif /* FEATURE_WLAN_ESE */
5078 {
5079 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5080 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005081 hdd_info("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 return auth_type;
5083}
5084
5085/**
5086 * hdd_translate_rsn_to_csr_encryption_type() -
5087 * Translate RSN to CSR encryption type
5088 * @cipher_suite: cipher suite
5089 *
5090 * Return: eCsrEncryptionType enumeration
5091 */
5092eCsrEncryptionType
5093hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5094{
5095 eCsrEncryptionType cipher_type;
5096
5097 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5098 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5099 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5100 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5101 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5102 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5103 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5104 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5105 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5106 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5107 else
5108 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5109
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005110 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005111 return cipher_type;
5112}
5113
5114/**
5115 * hdd_translate_wpa_to_csr_encryption_type() -
5116 * Translate WPA to CSR encryption type
5117 * @cipher_suite: cipher suite
5118 *
5119 * Return: eCsrEncryptionType enumeration
5120 */
5121eCsrEncryptionType
5122hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5123{
5124 eCsrEncryptionType cipher_type;
5125
5126 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5127 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5128 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5129 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5130 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5131 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5132 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5133 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5134 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5135 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5136 else
5137 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5138
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005139 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005140 return cipher_type;
5141}
5142
5143/**
5144 * hdd_process_genie() - process gen ie
5145 * @pAdapter: pointer to adapter
5146 * @bssid: pointer to mac address
5147 * @pEncryptType: pointer to encryption type
5148 * @mcEncryptType: pointer to multicast encryption type
5149 * @pAuthType: pointer to auth type
5150 *
5151 * Return: 0 on success, error number otherwise
5152 */
5153static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5154 u8 *bssid,
5155 eCsrEncryptionType *pEncryptType,
5156 eCsrEncryptionType *mcEncryptType,
5157 eCsrAuthType *pAuthType,
5158#ifdef WLAN_FEATURE_11W
5159 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5160#endif
5161 uint16_t gen_ie_len, uint8_t *gen_ie)
5162{
5163 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305164 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 tDot11fIERSN dot11RSNIE;
5166 tDot11fIEWPA dot11WPAIE;
5167 uint32_t i;
5168 uint8_t *pRsnIe;
5169 uint16_t RSNIeLen;
5170 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5171 bool updatePMKCache = false;
5172
5173 /*
5174 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5175 * setting present flag to 0.
5176 */
5177 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5178 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5179
5180 /* Type check */
5181 if (gen_ie[0] == DOT11F_EID_RSN) {
5182 /* Validity checks */
5183 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5184 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005185 hdd_err("Invalid DOT11F RSN IE length :%d",
5186 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005187 return -EINVAL;
5188 }
5189 /* Skip past the EID byte and length byte */
5190 pRsnIe = gen_ie + 2;
5191 RSNIeLen = gen_ie_len - 2;
5192 /* Unpack the RSN IE */
5193 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
5194 pRsnIe, RSNIeLen, &dot11RSNIE);
5195 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005196 hdd_info("pairwise cipher suite count: %d",
5197 dot11RSNIE.pwise_cipher_suite_count);
5198 hdd_info("authentication suite count: %d",
5199 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 /* dot11RSNIE.akm_suite_count */
5201 /* Just translate the FIRST one */
5202 *pAuthType =
5203 hdd_translate_rsn_to_csr_auth_type(
5204 dot11RSNIE.akm_suites[0]);
5205 /* dot11RSNIE.pwise_cipher_suite_count */
5206 *pEncryptType =
5207 hdd_translate_rsn_to_csr_encryption_type(
5208 dot11RSNIE.pwise_cipher_suites[0]);
5209 /* dot11RSNIE.gp_cipher_suite_count */
5210 *mcEncryptType =
5211 hdd_translate_rsn_to_csr_encryption_type(
5212 dot11RSNIE.gp_cipher_suite);
5213#ifdef WLAN_FEATURE_11W
5214 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5215 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5216#endif
5217 /* Set the PMKSA ID Cache for this interface */
5218 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5219 if (is_zero_ether_addr(bssid)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005220 hdd_err("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221 break;
5222 }
5223 updatePMKCache = true;
5224 /*
5225 * For right now, I assume setASSOCIATE() has passed
5226 * in the bssid.
5227 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305228 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305229 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305230 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5232 }
5233
5234 if (updatePMKCache) {
5235 /*
5236 * Calling csr_roam_set_pmkid_cache to configure the
5237 * PMKIDs into the cache.
5238 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005239 hdd_info("Calling sme_roam_set_pmkid_cache with cache entry %d.",
5240 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241 /* Finally set the PMKSA ID Cache in CSR */
5242 result =
5243 sme_roam_set_pmkid_cache(halHandle,
5244 pAdapter->sessionId,
5245 PMKIDCache,
5246 dot11RSNIE.pmkid_count,
5247 false);
5248 }
5249 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5250 /* Validity checks */
5251 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5252 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005253 hdd_err("Invalid DOT11F WPA IE length :%d",
5254 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 return -EINVAL;
5256 }
5257 /* Skip past the EID and length byte - and four byte WiFi OUI */
5258 pRsnIe = gen_ie + 2 + 4;
5259 RSNIeLen = gen_ie_len - (2 + 4);
5260 /* Unpack the WPA IE */
5261 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
5262 pRsnIe, RSNIeLen, &dot11WPAIE);
5263 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005264 hdd_info("WPA unicast cipher suite count: %d",
5265 dot11WPAIE.unicast_cipher_count);
5266 hdd_info("WPA authentication suite count: %d",
5267 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 /* dot11WPAIE.auth_suite_count */
5269 /* Just translate the FIRST one */
5270 *pAuthType =
5271 hdd_translate_wpa_to_csr_auth_type(
5272 dot11WPAIE.auth_suites[0]);
5273 /* dot11WPAIE.unicast_cipher_count */
5274 *pEncryptType =
5275 hdd_translate_wpa_to_csr_encryption_type(
5276 dot11WPAIE.unicast_ciphers[0]);
5277 /* dot11WPAIE.unicast_cipher_count */
5278 *mcEncryptType =
5279 hdd_translate_wpa_to_csr_encryption_type(
5280 dot11WPAIE.multicast_cipher);
5281 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005282 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 return -EINVAL;
5284 }
5285 return 0;
5286}
5287
5288/**
5289 * hdd_set_genie_to_csr() - set genie to csr
5290 * @pAdapter: pointer to adapter
5291 * @RSNAuthType: pointer to auth type
5292 *
5293 * Return: 0 on success, error number otherwise
5294 */
5295int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5296{
5297 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5298 uint32_t status = 0;
5299 eCsrEncryptionType RSNEncryptType;
5300 eCsrEncryptionType mcRSNEncryptType;
5301#ifdef WLAN_FEATURE_11W
5302 uint8_t RSNMfpRequired = 0;
5303 uint8_t RSNMfpCapable = 0;
5304#endif
5305 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5306 /* MAC address of assoc peer */
5307 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305308 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 pWextState->roamProfile.BSSIDs.bssid,
5310 sizeof(bssid));
5311 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5312 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5313 /* continue */
5314 } else {
5315 return 0;
5316 }
5317 /* The actual processing may eventually be more extensive than this. */
5318 /* Right now, just consume any PMKIDs that are sent in by the app. */
5319 status = hdd_process_genie(pAdapter, bssid,
5320 &RSNEncryptType,
5321 &mcRSNEncryptType, RSNAuthType,
5322#ifdef WLAN_FEATURE_11W
5323 &RSNMfpRequired, &RSNMfpCapable,
5324#endif
5325 pWextState->WPARSNIE[1] + 2,
5326 pWextState->WPARSNIE);
5327 if (status == 0) {
5328 /*
5329 * Now copy over all the security attributes
5330 * you have parsed out.
5331 */
5332 pWextState->roamProfile.EncryptionType.numEntries = 1;
5333 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5334
5335 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5336 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5337 mcRSNEncryptType;
5338
Krunal Sonibe766b02016-03-10 13:00:44 -08005339 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5341 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5342 /*
5343 * For wpa none supplicant sends the WPA IE with unicast
5344 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5345 * multicast cipher as either AES/TKIP based on group
5346 * cipher configuration mentioned in the
5347 * wpa_supplicant.conf.
5348 */
5349
5350 /* Set the unicast cipher same as multicast cipher */
5351 pWextState->roamProfile.EncryptionType.encryptionType[0]
5352 = mcRSNEncryptType;
5353 }
5354#ifdef WLAN_FEATURE_11W
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005355 hdd_info("RSNMfpRequired = %d, RSNMfpCapable = %d",
5356 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5358 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5359#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005360 hdd_info("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
5361 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005362 }
5363 return 0;
5364}
5365
5366/**
5367 * hdd_set_csr_auth_type() - set csr auth type
5368 * @pAdapter: pointer to adapter
5369 * @RSNAuthType: auth type
5370 *
5371 * Return: 0 on success, error number otherwise
5372 */
5373int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5374{
5375 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5376 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5377 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378
5379 pRoamProfile->AuthType.numEntries = 1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005380 hdd_info("pHddStaCtx->conn_info.authType = %d",
5381 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382
5383 switch (pHddStaCtx->conn_info.authType) {
5384 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5385#ifdef FEATURE_WLAN_ESE
5386 case eCSR_AUTH_TYPE_CCKM_WPA:
5387 case eCSR_AUTH_TYPE_CCKM_RSN:
5388#endif
5389 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5390
5391 pRoamProfile->AuthType.authType[0] =
5392 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5393 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5394
5395#ifdef FEATURE_WLAN_ESE
5396 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5397 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5398 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005399 hdd_info("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400 pRoamProfile->AuthType.authType[0] =
5401 eCSR_AUTH_TYPE_CCKM_WPA;
5402 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005403 hdd_info("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005404 pRoamProfile->AuthType.authType[0] =
5405 eCSR_AUTH_TYPE_CCKM_WPA;
5406 } else
5407#endif
5408 if ((pWextState->
5409 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5410 == IW_AUTH_KEY_MGMT_802_1X) {
5411 pRoamProfile->AuthType.authType[0] =
5412 eCSR_AUTH_TYPE_WPA;
5413 } else
5414 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5415 == IW_AUTH_KEY_MGMT_PSK) {
5416 pRoamProfile->AuthType.authType[0] =
5417 eCSR_AUTH_TYPE_WPA_PSK;
5418 } else {
5419 pRoamProfile->AuthType.authType[0] =
5420 eCSR_AUTH_TYPE_WPA_NONE;
5421 }
5422 }
5423 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5424#ifdef FEATURE_WLAN_ESE
5425 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5426 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5427 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005428 hdd_info("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429 pRoamProfile->AuthType.authType[0] =
5430 eCSR_AUTH_TYPE_CCKM_RSN;
5431 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005432 hdd_info("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 pRoamProfile->AuthType.authType[0] =
5434 eCSR_AUTH_TYPE_CCKM_RSN;
5435 } else
5436#endif
5437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5439 ((pWextState->
5440 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5441 == IW_AUTH_KEY_MGMT_802_1X)) {
5442 pRoamProfile->AuthType.authType[0] =
5443 eCSR_AUTH_TYPE_FT_RSN;
5444 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5445 &&
5446 ((pWextState->
5447 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5448 == IW_AUTH_KEY_MGMT_PSK)) {
5449 pRoamProfile->AuthType.authType[0] =
5450 eCSR_AUTH_TYPE_FT_RSN_PSK;
5451 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452
5453#ifdef WLAN_FEATURE_11W
5454 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5455 pRoamProfile->AuthType.authType[0] =
5456 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5457 } else if (RSNAuthType ==
5458 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5459 pRoamProfile->AuthType.authType[0] =
5460 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5461 } else
5462#endif
5463
5464 if ((pWextState->
5465 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5466 == IW_AUTH_KEY_MGMT_802_1X) {
5467 pRoamProfile->AuthType.authType[0] =
5468 eCSR_AUTH_TYPE_RSN;
5469 } else
5470 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5471 == IW_AUTH_KEY_MGMT_PSK) {
5472 pRoamProfile->AuthType.authType[0] =
5473 eCSR_AUTH_TYPE_RSN_PSK;
5474 } else {
5475 pRoamProfile->AuthType.authType[0] =
5476 eCSR_AUTH_TYPE_UNKNOWN;
5477 }
5478 }
5479 break;
5480
5481 case eCSR_AUTH_TYPE_SHARED_KEY:
5482
5483 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5484 break;
5485 default:
5486
5487#ifdef FEATURE_WLAN_ESE
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005488 hdd_info("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489#endif /* FEATURE_WLAN_ESE */
5490 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5491 break;
5492 }
5493
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005494 hdd_info("Set roam Authtype to %d",
5495 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 return 0;
5498}
5499
5500/**
5501 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5502 * to the CSR roam profile.
5503 *
5504 * @dev: Pointer to the net device.
5505 * @info: Pointer to the iw_request_info.
5506 * @wrqu: Pointer to the iwreq_data.
5507 * @extra: Pointer to the data.
5508 *
5509 * Return: 0 for success, error number on failure
5510 */
5511static int __iw_set_essid(struct net_device *dev,
5512 struct iw_request_info *info,
5513 union iwreq_data *wrqu, char *extra)
5514{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 uint32_t status = 0;
5516 hdd_wext_state_t *pWextState;
5517 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5518 hdd_context_t *hdd_ctx;
5519 uint32_t roamId;
5520 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 eCsrAuthType RSNAuthType;
5522 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523 int ret;
5524
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005525 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526
5527 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5528 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305529 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 return ret;
5531
Jeff Johnson441e1f72017-02-07 08:50:49 -08005532 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5533 if (0 != ret)
5534 return ret;
5535
Krunal Sonibe766b02016-03-10 13:00:44 -08005536 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005537 pAdapter->device_mode != QDF_IBSS_MODE &&
5538 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005539 hdd_warn("device mode %s(%d) is not allowed",
5540 hdd_device_mode_to_string(pAdapter->device_mode),
5541 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542 return -EINVAL;
5543 }
5544
5545 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5546
5547 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005548 hdd_info("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 return -EBUSY;
5550 }
5551 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5552 return -EINVAL;
5553
5554 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305555 /*Try disconnecting if already in connected state*/
5556 status = wlan_hdd_try_disconnect(pAdapter);
5557 if (0 > status) {
5558 hdd_err("Failed to disconnect the existing connection");
5559 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 }
5561
5562 /*
5563 * when cfg80211 defined, wpa_supplicant wext driver uses
5564 * zero-length, null-string ssid for force disconnection.
5565 * after disconnection (if previously connected) and cleaning ssid,
5566 * driver MUST return success.
5567 */
5568 if (0 == wrqu->essid.length)
5569 return 0;
5570
5571 status = hdd_wmm_get_uapsd_mask(pAdapter,
5572 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305573 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 pWextState->roamProfile.uapsd_mask = 0;
5575
5576 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5577
5578 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5579 wrqu->essid.length;
5580
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305581 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305583 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 ssId), extra, wrqu->essid.length);
5585 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5586 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5587
5588 /* set gen ie */
5589 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5590
5591 /* set auth */
5592 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5593 }
5594#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005595 hdd_notice("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 if (pAdapter->wapi_info.nWapiMode) {
5597 switch (pAdapter->wapi_info.wapiAuthMode) {
5598 case WAPI_AUTH_MODE_PSK:
5599 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005600 hdd_notice("WAPI AUTH TYPE: PSK: %d",
5601 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 pRoamProfile->AuthType.numEntries = 1;
5603 pRoamProfile->AuthType.authType[0] =
5604 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5605 break;
5606 }
5607 case WAPI_AUTH_MODE_CERT:
5608 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005609 hdd_notice("WAPI AUTH TYPE: CERT: %d",
5610 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 pRoamProfile->AuthType.numEntries = 1;
5612 pRoamProfile->AuthType.authType[0] =
5613 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5614 break;
5615 }
5616 } /* End of switch */
5617 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5618 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005619 hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 pRoamProfile->EncryptionType.numEntries = 1;
5621 pRoamProfile->EncryptionType.encryptionType[0] =
5622 eCSR_ENCRYPT_TYPE_WPI;
5623 pRoamProfile->mcEncryptionType.numEntries = 1;
5624 pRoamProfile->mcEncryptionType.encryptionType[0] =
5625 eCSR_ENCRYPT_TYPE_WPI;
5626 }
5627 }
5628#endif /* FEATURE_WLAN_WAPI */
5629 /* if previous genIE is not NULL, update AssocIE */
5630 if (0 != pWextState->genIE.length) {
5631 memset(&pWextState->assocAddIE, 0,
5632 sizeof(pWextState->assocAddIE));
5633 memcpy(pWextState->assocAddIE.addIEdata,
5634 pWextState->genIE.addIEdata, pWextState->genIE.length);
5635 pWextState->assocAddIE.length = pWextState->genIE.length;
5636 pWextState->roamProfile.pAddIEAssoc =
5637 pWextState->assocAddIE.addIEdata;
5638 pWextState->roamProfile.nAddIEAssocLength =
5639 pWextState->assocAddIE.length;
5640
5641 /* clear previous genIE after use it */
5642 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5643 }
5644
5645 /*
5646 * Assumes it is not WPS Association by default, except when
5647 * pAddIEAssoc has WPS IE.
5648 */
5649 pWextState->roamProfile.bWPSAssociation = false;
5650
5651 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5652 pWextState->roamProfile.
5653 nAddIEAssocLength))
5654 pWextState->roamProfile.bWPSAssociation = true;
5655
5656 /* Disable auto BMPS entry by PMC until DHCP is done */
5657 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5658 true);
5659
5660 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5661
5662 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005663 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005665 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5666 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005668
Agrawal Ashish6b015762016-05-05 11:22:18 +05305669 /*
5670 * Change conn_state to connecting before sme_roam_connect(),
5671 * because sme_roam_connect() has a direct path to call
5672 * hdd_sme_roam_callback(), which will change the conn_state
5673 * If direct path, conn_state will be accordingly changed to
5674 * NotConnected or Associated by either
5675 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5676 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5677 * Connecting state will remain until it is completed.
5678 *
5679 * If connection state is not changed,
5680 * connection state will remain in eConnectionState_NotConnected state.
5681 * In hdd_association_completion_handler, "hddDisconInProgress" is
5682 * set to true if conn state is eConnectionState_NotConnected.
5683 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5684 * informed of connect result indication which is an issue.
5685 */
5686 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305687 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305688 hdd_conn_set_connection_state(pAdapter,
5689 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691 status = sme_roam_connect(hHal, pAdapter->sessionId,
5692 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305693 if ((QDF_STATUS_SUCCESS != status) &&
5694 (QDF_STA_MODE == pAdapter->device_mode ||
5695 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
5696 hdd_err("sme_roam_connect (session %d) failed with status %d. -> NotConnected",
5697 pAdapter->sessionId, status);
5698 /* change back to NotAssociated */
5699 hdd_conn_set_connection_state(pAdapter,
5700 eConnectionState_NotConnected);
5701 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 pRoamProfile->ChannelInfo.ChannelList = NULL;
5703 pRoamProfile->ChannelInfo.numOfChannels = 0;
5704
5705 EXIT();
5706 return status;
5707}
5708
5709/**
5710 * iw_set_essid() - set essid handler function
5711 * @dev: Pointer to the net device.
5712 * @info: Pointer to the iw_request_info.
5713 * @wrqu: Pointer to the iwreq_data.
5714 * @extra: Pointer to the data.
5715 *
5716 * Return: 0 for success, error number on failure
5717 */
5718int iw_set_essid(struct net_device *dev,
5719 struct iw_request_info *info,
5720 union iwreq_data *wrqu, char *extra)
5721{
5722 int ret;
5723
5724 cds_ssr_protect(__func__);
5725 ret = __iw_set_essid(dev, info, wrqu, extra);
5726 cds_ssr_unprotect(__func__);
5727
5728 return ret;
5729}
5730
5731/**
5732 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5733 * @dev: pointer to the net device
5734 * @info: pointer to the iw request info
5735 * @dwrq: pointer to iw_point
5736 * @extra: pointer to the data
5737 *
5738 * Return: 0 on success, error number otherwise
5739 */
5740static int __iw_get_essid(struct net_device *dev,
5741 struct iw_request_info *info,
5742 struct iw_point *dwrq, char *extra)
5743{
5744 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5745 hdd_context_t *hdd_ctx;
5746 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5747 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5748 int ret;
5749
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005750 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751
5752 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5753 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305754 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 return ret;
5756
Jeff Johnson441e1f72017-02-07 08:50:49 -08005757 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5758 if (0 != ret)
5759 return ret;
5760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5762 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5763 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5764 || pHddStaCtx->conn_info.connState ==
5765 eConnectionState_IbssDisconnected)
5766 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5767 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5768 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5769 dwrq->length);
5770 dwrq->flags = 1;
5771 } else {
5772 memset(extra, 0, dwrq->length);
5773 dwrq->length = 0;
5774 dwrq->flags = 0;
5775 }
5776 EXIT();
5777 return 0;
5778}
5779
5780/**
5781 * iw_get_essid() - get essid handler function
5782 * @dev: Pointer to the net device.
5783 * @info: Pointer to the iw_request_info.
5784 * @wrqu: Pointer to the iwreq_data.
5785 * @extra: Pointer to the data.
5786 *
5787 * Return: 0 for success, error number on failure
5788 */
5789int iw_get_essid(struct net_device *dev,
5790 struct iw_request_info *info,
5791 struct iw_point *wrqu, char *extra)
5792{
5793 int ret;
5794
5795 cds_ssr_protect(__func__);
5796 ret = __iw_get_essid(dev, info, wrqu, extra);
5797 cds_ssr_unprotect(__func__);
5798
5799 return ret;
5800}
5801
5802/**
5803 * __iw_set_auth() -
5804 * This function sets the auth type received from the wpa_supplicant
5805 * @dev: pointer to the net device
5806 * @info: pointer to the iw request info
5807 * @wrqu: pointer to iwreq_data
5808 * @extra: pointer to the data
5809 *
5810 * Return: 0 on success, error number otherwise
5811 */
5812static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5813 union iwreq_data *wrqu, char *extra)
5814{
5815 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5816 hdd_context_t *hdd_ctx;
5817 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5818 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5819 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5820 eCsrEncryptionType mcEncryptionType;
5821 eCsrEncryptionType ucEncryptionType;
5822 int ret;
5823
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005824 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005825
5826 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5827 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305828 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005829 return ret;
5830
Jeff Johnson441e1f72017-02-07 08:50:49 -08005831 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5832 if (0 != ret)
5833 return ret;
5834
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 switch (wrqu->param.flags & IW_AUTH_INDEX) {
5836 case IW_AUTH_WPA_VERSION:
5837 pWextState->wpaVersion = wrqu->param.value;
5838 break;
5839
5840 case IW_AUTH_CIPHER_PAIRWISE:
5841 {
5842 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5843 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5844 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5845 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5846 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5847 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5848 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5849 if ((IW_AUTH_KEY_MGMT_802_1X
5850 ==
5851 (pWextState->
5852 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5853 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5854 pHddStaCtx->conn_info.authType))
5855 /*Dynamic WEP key */
5856 ucEncryptionType =
5857 eCSR_ENCRYPT_TYPE_WEP40;
5858 else
5859 /*Static WEP key */
5860 ucEncryptionType =
5861 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5862 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5863 if ((IW_AUTH_KEY_MGMT_802_1X
5864 ==
5865 (pWextState->
5866 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5867 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5868 pHddStaCtx->conn_info.authType))
5869 /*Dynamic WEP key */
5870 ucEncryptionType =
5871 eCSR_ENCRYPT_TYPE_WEP104;
5872 else
5873 /*Static WEP key */
5874 ucEncryptionType =
5875 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5876 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005877 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
5878 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 return -EINVAL;
5880 }
5881
5882 pRoamProfile->EncryptionType.numEntries = 1;
5883 pRoamProfile->EncryptionType.encryptionType[0] =
5884 ucEncryptionType;
5885 }
5886 break;
5887 case IW_AUTH_CIPHER_GROUP:
5888 {
5889 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5890 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5891 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5892 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5893 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5894 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5895 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5896 if ((IW_AUTH_KEY_MGMT_802_1X
5897 ==
5898 (pWextState->
5899 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5900 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5901 pHddStaCtx->conn_info.authType))
5902 mcEncryptionType =
5903 eCSR_ENCRYPT_TYPE_WEP40;
5904 else
5905 mcEncryptionType =
5906 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5907 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5908 /* Dynamic WEP keys won't work with shared keys */
5909 if ((IW_AUTH_KEY_MGMT_802_1X
5910 ==
5911 (pWextState->
5912 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5913 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5914 pHddStaCtx->conn_info.authType)) {
5915 mcEncryptionType =
5916 eCSR_ENCRYPT_TYPE_WEP104;
5917 } else {
5918 mcEncryptionType =
5919 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5920 }
5921 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005922 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 wrqu->param.value);
5924 return -EINVAL;
5925 }
5926
5927 pRoamProfile->mcEncryptionType.numEntries = 1;
5928 pRoamProfile->mcEncryptionType.encryptionType[0] =
5929 mcEncryptionType;
5930 }
5931 break;
5932
5933 case IW_AUTH_80211_AUTH_ALG:
5934 {
Jeff Johnson5a062372017-01-12 09:51:25 -08005935 /* Save the auth algo here and set auth type to SME
5936 * Roam profile in the iw_set_ap_address
5937 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
5939 pHddStaCtx->conn_info.authType =
5940 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5941
5942 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5943 pHddStaCtx->conn_info.authType =
5944 eCSR_AUTH_TYPE_SHARED_KEY;
5945
5946 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
5947 /*Not supported */
5948 pHddStaCtx->conn_info.authType =
5949 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5950 pWextState->roamProfile.AuthType.authType[0] =
5951 pHddStaCtx->conn_info.authType;
5952 }
5953 break;
5954
5955 case IW_AUTH_KEY_MGMT:
5956 {
5957#ifdef FEATURE_WLAN_ESE
5958#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5959 /*Check for CCKM AKM type */
5960 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005961 hdd_info("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962 /* Set the CCKM bit in authKeyMgmt */
5963 /*
5964 * Right now, this breaks all ref to authKeyMgmt because
5965 * our code doesn't realize it is a "bitfield"
5966 */
5967 pWextState->authKeyMgmt |=
5968 IW_AUTH_KEY_MGMT_CCKM;
5969 /* Set the key management to 802.1X */
5970 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
5971 pWextState->isESEConnection = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5973 /* Save the key management */
5974 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08005975 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005976 /* Save the key management anyway */
5977 pWextState->authKeyMgmt = wrqu->param.value;
5978 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
5979 /* Save the key management */
5980 pWextState->authKeyMgmt |=
5981 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 }
5983#else
5984 /* Save the key management */
5985 pWextState->authKeyMgmt = wrqu->param.value;
5986#endif /* FEATURE_WLAN_ESE */
5987 }
5988 break;
5989
5990 case IW_AUTH_TKIP_COUNTERMEASURES:
5991 {
5992 if (wrqu->param.value) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005993 hdd_info("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 wrqu->param.value);
5995 pWextState->mTKIPCounterMeasures =
5996 TKIP_COUNTER_MEASURE_STARTED;
5997 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005998 hdd_info("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 wrqu->param.value);
6000 pWextState->mTKIPCounterMeasures =
6001 TKIP_COUNTER_MEASURE_STOPED;
6002 }
6003 }
6004 break;
6005 case IW_AUTH_DROP_UNENCRYPTED:
6006 case IW_AUTH_WPA_ENABLED:
6007 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6008 case IW_AUTH_ROAMING_CONTROL:
6009 case IW_AUTH_PRIVACY_INVOKED:
6010
6011 default:
6012
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006013 hdd_warn("called with unsupported auth type %d",
6014 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 break;
6016 }
6017
6018 EXIT();
6019 return 0;
6020}
6021
6022/**
6023 * iw_set_auth() - set auth callback function
6024 * @dev: Pointer to the net device.
6025 * @info: Pointer to the iw_request_info.
6026 * @wrqu: Pointer to the iwreq_data.
6027 * @extra: Pointer to the data.
6028 *
6029 * Return: 0 for success, error number on failure.
6030 */
6031int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6032 union iwreq_data *wrqu, char *extra)
6033{
6034 int ret;
6035
6036 cds_ssr_protect(__func__);
6037 ret = __iw_set_auth(dev, info, wrqu, extra);
6038 cds_ssr_unprotect(__func__);
6039
6040 return ret;
6041}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006042/**
6043 * __iw_get_auth() -
6044 * This function returns the auth type to the wpa_supplicant
6045 * @dev: pointer to the net device
6046 * @info: pointer to the iw request info
6047 * @wrqu: pointer to iwreq_data
6048 * @extra: pointer to the data
6049 *
6050 * Return: 0 on success, error number otherwise
6051 */
6052static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6053 union iwreq_data *wrqu, char *extra)
6054{
6055 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6056 hdd_context_t *hdd_ctx;
6057 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6058 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6059 int ret;
6060
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006061 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062
6063 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6064 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306065 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066 return ret;
6067
Jeff Johnson441e1f72017-02-07 08:50:49 -08006068 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6069 if (0 != ret)
6070 return ret;
6071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006072 switch (pRoamProfile->negotiatedAuthType) {
6073 case eCSR_AUTH_TYPE_WPA_NONE:
6074 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6075 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6076 break;
6077 case eCSR_AUTH_TYPE_WPA:
6078 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6079 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6080 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006083 case eCSR_AUTH_TYPE_RSN:
6084 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6085 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6086 break;
6087 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6088 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6089 break;
6090 case eCSR_AUTH_TYPE_SHARED_KEY:
6091 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6092 break;
6093 case eCSR_AUTH_TYPE_UNKNOWN:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006094 hdd_info("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006095 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6096 break;
6097 case eCSR_AUTH_TYPE_AUTOSWITCH:
6098 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6099 break;
6100 case eCSR_AUTH_TYPE_WPA_PSK:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006101 hdd_info("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006102 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6103 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006105 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006106 case eCSR_AUTH_TYPE_RSN_PSK:
6107#ifdef WLAN_FEATURE_11W
6108 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6109 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6110#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006111 hdd_info("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6113 return -EIO;
6114 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006115 hdd_err("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006116 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6117 return -EIO;
6118 }
6119 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6120 switch (pRoamProfile->negotiatedUCEncryptionType) {
6121 case eCSR_ENCRYPT_TYPE_NONE:
6122 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6123 break;
6124 case eCSR_ENCRYPT_TYPE_WEP40:
6125 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6126 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6127 break;
6128 case eCSR_ENCRYPT_TYPE_TKIP:
6129 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6130 break;
6131 case eCSR_ENCRYPT_TYPE_WEP104:
6132 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6133 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6134 break;
6135 case eCSR_ENCRYPT_TYPE_AES:
6136 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6137 break;
6138 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006139 hdd_notice("called with unknown auth type %d",
6140 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006141 return -EIO;
6142 }
6143 }
6144
6145 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6146 switch (pRoamProfile->negotiatedMCEncryptionType) {
6147 case eCSR_ENCRYPT_TYPE_NONE:
6148 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6149 break;
6150 case eCSR_ENCRYPT_TYPE_WEP40:
6151 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6152 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6153 break;
6154 case eCSR_ENCRYPT_TYPE_TKIP:
6155 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6156 break;
6157 case eCSR_ENCRYPT_TYPE_WEP104:
6158 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6159 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6160 break;
6161 case eCSR_ENCRYPT_TYPE_AES:
6162 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6163 break;
6164 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006165 hdd_info("called with unknown auth type %d",
6166 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006167 return -EIO;
6168 }
6169 }
6170
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006171 hdd_info("called with auth type %d",
6172 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006173 EXIT();
6174 return 0;
6175}
6176
6177/**
6178 * iw_get_auth() - get auth callback function
6179 * @dev: Pointer to the net device.
6180 * @info: Pointer to the iw_request_info.
6181 * @wrqu: Pointer to the iwreq_data.
6182 * @extra: Pointer to the data.
6183 *
6184 * Return: 0 for success, error number on failure.
6185 */
6186int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6187 union iwreq_data *wrqu, char *extra)
6188{
6189 int ret;
6190
6191 cds_ssr_protect(__func__);
6192 ret = __iw_get_auth(dev, info, wrqu, extra);
6193 cds_ssr_unprotect(__func__);
6194
6195 return ret;
6196}
6197
6198/**
6199 * __iw_set_ap_address() - set ap address
6200 * @dev: pointer to the net device
6201 * @info: pointer to the iw request info
6202 * @wrqu: pointer to iwreq_data
6203 * @extra: pointer to the data
6204 *
6205 * This function updates the HDD global station context connection info
6206 * BSSID with the MAC address received from the wpa_supplicant.
6207 *
6208 * Return: 0 on success, error number otherwise
6209 */
6210static int __iw_set_ap_address(struct net_device *dev,
6211 struct iw_request_info *info,
6212 union iwreq_data *wrqu, char *extra)
6213{
6214
6215 hdd_adapter_t *adapter;
6216 hdd_context_t *hdd_ctx;
6217 hdd_station_ctx_t *pHddStaCtx =
6218 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6219 uint8_t *pMacAddress = NULL;
6220 int ret;
6221
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006222 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006223
6224 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6225
6226 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6227 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306228 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006229 return ret;
6230
Jeff Johnson441e1f72017-02-07 08:50:49 -08006231 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6232 if (0 != ret)
6233 return ret;
6234
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006235 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006236 hdd_info(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306237 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306238 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006239 EXIT();
6240
6241 return 0;
6242}
6243
6244/**
6245 * iw_set_ap_address() - set ap addresses callback function
6246 * @dev: Pointer to the net device.
6247 * @info: Pointer to the iw_request_info.
6248 * @wrqu: Pointer to the iwreq_data.
6249 * @extra: Pointer to the data.
6250 *
6251 * Return: 0 for success, error number on failure.
6252 */
6253int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6254 union iwreq_data *wrqu, char *extra)
6255{
6256 int ret;
6257
6258 cds_ssr_protect(__func__);
6259 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6260 cds_ssr_unprotect(__func__);
6261
6262 return ret;
6263}
6264
6265/**
6266 * __iw_get_ap_address() - get ap address
6267 * @dev: pointer to the net device
6268 * @info: pointer to the iw request info
6269 * @wrqu: pointer to iwreq_data
6270 * @extra: pointer to the data
6271 *
6272 * This function returns currently associated BSSID.
6273 *
6274 * Return: 0 on success, error number otherwise
6275 */
6276static int __iw_get_ap_address(struct net_device *dev,
6277 struct iw_request_info *info,
6278 union iwreq_data *wrqu, char *extra)
6279{
6280 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6281 hdd_context_t *hdd_ctx;
6282 hdd_station_ctx_t *pHddStaCtx =
6283 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6284 int ret;
6285
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006286 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006287
6288 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6289 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306290 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006291 return ret;
6292
Jeff Johnson441e1f72017-02-07 08:50:49 -08006293 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6294 if (0 != ret)
6295 return ret;
6296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006297 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6298 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306299 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006300 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306301 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006302 } else {
6303 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6304 }
6305 EXIT();
6306 return 0;
6307}
6308
6309/**
6310 * iw_get_ap_address() - get ap addresses callback function
6311 * @dev: Pointer to the net device.
6312 * @info: Pointer to the iw_request_info.
6313 * @wrqu: Pointer to the iwreq_data.
6314 * @extra: Pointer to the data.
6315 *
6316 * Return: 0 for success, error number on failure.
6317 */
6318int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6319 union iwreq_data *wrqu, char *extra)
6320{
6321 int ret;
6322
6323 cds_ssr_protect(__func__);
6324 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6325 cds_ssr_unprotect(__func__);
6326
6327 return ret;
6328}