blob: def3ccb4b76ddcb479c44fd6f23e4f3eec06ff61 [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>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
64/* These are needed to recognize WPA and RSN suite types */
65#define HDD_WPA_OUI_SIZE 4
66#define HDD_RSN_OUI_SIZE 4
67uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
68uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
69uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
70uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
71uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
72uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
73
74#ifdef FEATURE_WLAN_ESE
75/* CCKM */
76uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
77/* CCKM */
78uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
79#endif /* FEATURE_WLAN_ESE */
80
81/* group cipher */
82uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
83
84/* WEP-40 or RSN */
85uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
86
87/* TKIP or RSN-PSK */
88uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
89
90/* Reserved */
91uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
92
93/* AES-CCMP */
94uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
95
96/* WEP-104 */
97uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
98
99#ifdef WLAN_FEATURE_11W
100/* RSN-PSK-SHA256 */
101uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
102
103/* RSN-8021X-SHA256 */
104uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
105#endif
106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107/* Offset where the EID-Len-IE, start. */
108#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
109#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110
111#define BEACON_FRAME_IES_OFFSET 12
112#define HDD_PEER_AUTHORIZE_WAIT 10
113
114/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700115 * beacon_filter_table - table of IEs used for beacon filtering
116 */
117static const int beacon_filter_table[] = {
118 SIR_MAC_DS_PARAM_SET_EID,
119 SIR_MAC_ERP_INFO_EID,
120 SIR_MAC_EDCA_PARAM_SET_EID,
121 SIR_MAC_QOS_CAPABILITY_EID,
122 SIR_MAC_HT_INFO_EID,
123 SIR_MAC_VHT_OPMODE_EID,
124 SIR_MAC_VHT_OPERATION_EID,
125};
126
127/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128 * hdd_conn_set_authenticated() - set authentication state
129 * @pAdapter: pointer to the adapter
130 * @authState: authentication state
131 *
132 * This function updates the global HDD station context
133 * authentication state.
134 *
135 * Return: none
136 */
137static void
138hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
139{
140 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
141 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
142
143 /* save the new connection state */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700144 hdd_notice("Authenticated state Changed from oldState:%d to State:%d",
145 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 pHddStaCtx->conn_info.uIsAuthenticated = authState;
147
148 /* Check is pending ROC request or not when auth state changed */
149 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
150}
151
152/**
153 * hdd_conn_set_connection_state() - set connection state
154 * @pAdapter: pointer to the adapter
155 * @connState: connection state
156 *
157 * This function updates the global HDD station context connection state.
158 *
159 * Return: none
160 */
161void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
162 eConnectionState connState)
163{
164 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
165 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
166
167 /* save the new connection state */
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530168 hdd_info("%pS Changed connectionState Changed from oldState:%d to State:%d",
169 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
170 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 pHddStaCtx->conn_info.connState = connState;
172
173 /* Check is pending ROC request or not when connection state changed */
174 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
175}
176
177/**
178 * hdd_conn_get_connection_state() - get connection state
179 * @pAdapter: pointer to the adapter
180 * @pConnState: pointer to connection state
181 *
182 * This function updates the global HDD station context connection state.
183 *
184 * Return: true if (Infra Associated or IBSS Connected)
185 * and sets output parameter pConnState;
186 * false otherwise
187 */
188static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
189 eConnectionState *pConnState)
190{
191 bool fConnected = false;
192 eConnectionState connState;
193
194 /* get the connection state. */
195 connState = pHddStaCtx->conn_info.connState;
196
197 if (eConnectionState_Associated == connState ||
198 eConnectionState_IbssConnected == connState ||
199 eConnectionState_IbssDisconnected == connState) {
200 fConnected = true;
201 }
202
203 if (pConnState)
204 *pConnState = connState;
205
206 return fConnected;
207}
208
209/**
210 * hdd_is_connecting() - Function to check connection progress
211 * @hdd_sta_ctx: pointer to global HDD Station context
212 *
213 * Return: true if connecting, false otherwise
214 */
215bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
216{
217 return hdd_sta_ctx->conn_info.connState ==
218 eConnectionState_Connecting;
219}
220
221/**
222 * hdd_conn_is_connected() - Function to check connection status
223 * @pHddStaCtx: pointer to global HDD Station context
224 *
225 * Return: false if any errors encountered, true otherwise
226 */
227bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
228{
229 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
230}
231
232/**
233 * hdd_conn_get_connected_band() - get current connection radio band
234 * @pHddStaCtx: pointer to global HDD Station context
235 *
236 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
237 * eCSR_BAND_ALL if not connected
238 */
239eCsrBand hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
240{
241 uint8_t staChannel = 0;
242
243 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
244 staChannel = pHddStaCtx->conn_info.operationChannel;
245
246 if (staChannel > 0 && staChannel < 14)
247 return eCSR_BAND_24;
248 else if (staChannel >= 36 && staChannel <= 184)
249 return eCSR_BAND_5G;
250 else /* If station is not connected return as eCSR_BAND_ALL */
251 return eCSR_BAND_ALL;
252}
253
254/**
255 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
256 * @pHddStaCtx: pointer to global HDD Station context
257 * @pConnectedCipherAlgo: pointer to connected cipher algo
258 *
259 * Return: false if any errors encountered, true otherwise
260 */
261static inline bool
262hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
263 eCsrEncryptionType *pConnectedCipherAlgo)
264{
265 bool fConnected = false;
266
267 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
268
269 if (pConnectedCipherAlgo)
270 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
271
272 return fConnected;
273}
274
275/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700276 * hdd_remove_beacon_filter() - remove beacon filter
277 * @adapter: Pointer to the hdd adapter
278 *
279 * Return: 0 on success and errno on failure
280 */
281static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
282{
283 QDF_STATUS status;
284 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
285
286 status = sme_remove_beacon_filter(hdd_ctx->hHal,
287 adapter->sessionId);
288 if (!QDF_IS_STATUS_SUCCESS(status)) {
289 hdd_err("sme_remove_beacon_filter() failed");
290 return -EFAULT;
291 }
292
293 return 0;
294}
295
296/**
297 * hdd_add_beacon_filter() - add beacon filter
298 * @adapter: Pointer to the hdd adapter
299 *
300 * Return: 0 on success and errno on failure
301 */
302static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
303{
304 int i;
305 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
306 QDF_STATUS status;
307 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
308
309 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530310 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700311 (unsigned long int *)ie_map);
312
313 status = sme_add_beacon_filter(hdd_ctx->hHal,
314 adapter->sessionId, ie_map);
315 if (!QDF_IS_STATUS_SUCCESS(status)) {
316 hdd_err("sme_add_beacon_filter() failed");
317 return -EFAULT;
318 }
319 return 0;
320}
321
322/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530323 * hdd_copy_vht_caps()- copy vht caps info from roam info to
324 * hdd station context.
325 * @hdd_sta_ctx: pointer to hdd station context
326 * @roam_info: pointer to roam info
327 *
328 * Return: None
329 */
330static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
331 tCsrRoamInfo *roam_info)
332{
333 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
334 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
335 uint32_t i, temp_ht_cap;
336
337 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
338
339 if (roam_ht_cap->advCodingCap)
340 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
341 if (roam_ht_cap->supportedChannelWidthSet)
342 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
343 temp_ht_cap = roam_ht_cap->mimoPowerSave &
344 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
345 if (temp_ht_cap)
346 hdd_ht_cap->cap_info |=
347 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
348 if (roam_ht_cap->greenField)
349 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
350 if (roam_ht_cap->shortGI20MHz)
351 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
352 if (roam_ht_cap->shortGI40MHz)
353 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
354 if (roam_ht_cap->txSTBC)
355 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
356 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
357 IEEE80211_HT_CAP_RX_STBC_SHIFT);
358 if (temp_ht_cap)
359 hdd_ht_cap->cap_info |=
360 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
361 if (roam_ht_cap->delayedBA)
362 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
363 if (roam_ht_cap->maximalAMSDUsize)
364 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
365 if (roam_ht_cap->dsssCckMode40MHz)
366 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
367 if (roam_ht_cap->psmp)
368 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
369 if (roam_ht_cap->stbcControlFrame)
370 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
371 if (roam_ht_cap->lsigTXOPProtection)
372 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
373
374 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
375 if (roam_ht_cap->maxRxAMPDUFactor)
376 hdd_ht_cap->ampdu_params_info |=
377 IEEE80211_HT_AMPDU_PARM_FACTOR;
378 temp_ht_cap = roam_ht_cap->mpduDensity &
379 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
380 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
381 if (temp_ht_cap)
382 hdd_ht_cap->ampdu_params_info |=
383 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
384
385 /* 802.11n HT extended capabilities masks */
386 if (roam_ht_cap->pco)
387 hdd_ht_cap->extended_ht_cap_info |=
388 IEEE80211_HT_EXT_CAP_PCO;
389 temp_ht_cap = roam_ht_cap->transitionTime &
390 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
391 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
392 if (temp_ht_cap)
393 hdd_ht_cap->extended_ht_cap_info |=
394 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
395 temp_ht_cap = roam_ht_cap->mcsFeedback &
396 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
397 if (temp_ht_cap)
398 hdd_ht_cap->extended_ht_cap_info |=
399 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
400
401 /* tx_bf_cap_info capabilities */
402 if (roam_ht_cap->txBF)
403 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
404 if (roam_ht_cap->rxStaggeredSounding)
405 hdd_ht_cap->tx_BF_cap_info |=
406 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
407 if (roam_ht_cap->txStaggeredSounding)
408 hdd_ht_cap->tx_BF_cap_info |=
409 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
410 if (roam_ht_cap->rxZLF)
411 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
412 if (roam_ht_cap->txZLF)
413 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
414 if (roam_ht_cap->implicitTxBF)
415 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
416 temp_ht_cap = roam_ht_cap->calibration &
417 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
418 if (temp_ht_cap)
419 hdd_ht_cap->tx_BF_cap_info |=
420 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
421 if (roam_ht_cap->explicitCSITxBF)
422 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
423 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
424 hdd_ht_cap->tx_BF_cap_info |=
425 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
426 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
427 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
428 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
429 if (temp_ht_cap)
430 hdd_ht_cap->tx_BF_cap_info |=
431 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
432 temp_ht_cap =
433 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
434 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
435 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
436 if (temp_ht_cap)
437 hdd_ht_cap->tx_BF_cap_info |=
438 temp_ht_cap <<
439 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
440 temp_ht_cap =
441 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
442 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
443 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
444 if (temp_ht_cap)
445 hdd_ht_cap->tx_BF_cap_info |=
446 temp_ht_cap <<
447 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
448 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
449 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
450 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
451 if (temp_ht_cap)
452 hdd_ht_cap->tx_BF_cap_info |=
453 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
454 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
455 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
456 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
457 if (temp_ht_cap)
458 hdd_ht_cap->tx_BF_cap_info |=
459 temp_ht_cap <<
460 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
461 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
462 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
463 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
464 if (temp_ht_cap)
465 hdd_ht_cap->tx_BF_cap_info |=
466 temp_ht_cap <<
467 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
468
469 /* antenna selection */
470 if (roam_ht_cap->antennaSelection)
471 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
472 if (roam_ht_cap->explicitCSIFeedbackTx)
473 hdd_ht_cap->antenna_selection_info |=
474 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
475 if (roam_ht_cap->antennaIndicesFeedbackTx)
476 hdd_ht_cap->antenna_selection_info |=
477 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
478 if (roam_ht_cap->explicitCSIFeedback)
479 hdd_ht_cap->antenna_selection_info |=
480 ANTENNA_SEL_INFO_EXP_CSI_FB;
481 if (roam_ht_cap->antennaIndicesFeedback)
482 hdd_ht_cap->antenna_selection_info |=
483 ANTENNA_SEL_INFO_ANT_ID_FB;
484 if (roam_ht_cap->rxAS)
485 hdd_ht_cap->antenna_selection_info |=
486 ANTENNA_SEL_INFO_RX_AS;
487 if (roam_ht_cap->txSoundingPPDUs)
488 hdd_ht_cap->antenna_selection_info |=
489 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
490
491 /* mcs data rate */
492 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
493 hdd_ht_cap->mcs.rx_mask[i] =
494 roam_ht_cap->supportedMCSSet[i];
495 hdd_ht_cap->mcs.rx_highest =
496 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
497 ((short) (roam_ht_cap->supportedMCSSet[10]));
498 hdd_ht_cap->mcs.tx_params =
499 roam_ht_cap->supportedMCSSet[12];
500}
501
502#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
503#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
504#define VHT_CAP_RXSTBC_MASK_SHIFT 8
505#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
506#define VHT_CAP_BEAMFORMEE_STS_MASK \
507 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
508#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
509#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
510 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
511#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
512#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
513 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
514#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
515
516/**
517 * hdd_copy_ht_caps()- copy ht caps info from roam info to
518 * hdd station context.
519 * @hdd_sta_ctx: pointer to hdd station context
520 * @roam_info: pointer to roam info
521 *
522 * Return: None
523 */
524static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
525 tCsrRoamInfo *roam_info)
526{
527 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
528 struct ieee80211_vht_cap *hdd_vht_cap =
529 &hdd_sta_ctx->conn_info.vht_caps;
530 uint32_t temp_vht_cap;
531
532 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
533
534 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
535 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
536 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
537 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
538 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
539 if (temp_vht_cap)
540 if (roam_vht_cap->supportedChannelWidthSet &
541 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
542 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
543 hdd_vht_cap->vht_cap_info |=
544 temp_vht_cap <<
545 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
546 if (roam_vht_cap->supportedChannelWidthSet &
547 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
548 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
549 hdd_vht_cap->vht_cap_info |=
550 temp_vht_cap <<
551 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
552 if (roam_vht_cap->ldpcCodingCap)
553 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
554 if (roam_vht_cap->shortGI80MHz)
555 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
556 if (roam_vht_cap->shortGI160and80plus80MHz)
557 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
558 if (roam_vht_cap->txSTBC)
559 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
560 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
561 VHT_CAP_RXSTBC_MASK_SHIFT);
562 if (temp_vht_cap)
563 hdd_vht_cap->vht_cap_info |=
564 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
565 if (roam_vht_cap->suBeamFormerCap)
566 hdd_vht_cap->vht_cap_info |=
567 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
568 if (roam_vht_cap->suBeamformeeCap)
569 hdd_vht_cap->vht_cap_info |=
570 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
571 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
572 (VHT_CAP_BEAMFORMEE_STS_MASK);
573 if (temp_vht_cap)
574 hdd_vht_cap->vht_cap_info |=
575 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
576 temp_vht_cap = roam_vht_cap->numSoundingDim &
577 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
578 if (temp_vht_cap)
579 hdd_vht_cap->vht_cap_info |=
580 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
581 if (roam_vht_cap->muBeamformerCap)
582 hdd_vht_cap->vht_cap_info |=
583 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
584 if (roam_vht_cap->muBeamformeeCap)
585 hdd_vht_cap->vht_cap_info |=
586 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
587 if (roam_vht_cap->vhtTXOPPS)
588 hdd_vht_cap->vht_cap_info |=
589 IEEE80211_VHT_CAP_VHT_TXOP_PS;
590 if (roam_vht_cap->htcVHTCap)
591 hdd_vht_cap->vht_cap_info |=
592 IEEE80211_VHT_CAP_HTC_VHT;
593 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
594 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
595 if (temp_vht_cap)
596 hdd_vht_cap->vht_cap_info |=
597 temp_vht_cap <<
598 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
599 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
600 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
601 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
602 if (temp_vht_cap)
603 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
604 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
605 if (roam_vht_cap->rxAntPattern)
606 hdd_vht_cap->vht_cap_info |=
607 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
608 if (roam_vht_cap->txAntPattern)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
611 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
612 hdd_vht_cap->supp_mcs.rx_highest =
613 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
614 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
615 hdd_vht_cap->supp_mcs.tx_highest =
616 ((uint16_t)roam_vht_cap->txSupDataRate);
617}
618
619/* ht param */
620#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
621#define HT_PARAM_SERVICE_INT_GRAN 0xe0
622#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
623
624/* operatinon mode */
625#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
626
627/* stbc_param */
628#define HT_STBC_PARAM_MCS 0x007f
629
630/**
631 * hdd_copy_ht_operation()- copy HT operation element from roam info to
632 * hdd station context.
633 * @hdd_sta_ctx: pointer to hdd station context
634 * @roam_info: pointer to roam info
635 *
636 * Return: None
637 */
638static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
639 tCsrRoamInfo *roam_info)
640{
641 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
642 struct ieee80211_ht_operation *hdd_ht_ops =
643 &hdd_sta_ctx->conn_info.ht_operation;
644 uint32_t i, temp_ht_ops;
645
646 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
647
648 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
649
650 /* HT_PARAMS */
651 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
652 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
653 if (temp_ht_ops)
654 hdd_ht_ops->ht_param |= temp_ht_ops;
655 else
656 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
657 if (roam_ht_ops->recommendedTxWidthSet)
658 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
659 if (roam_ht_ops->rifsMode)
660 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
661 if (roam_ht_ops->controlledAccessOnly)
662 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
663 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
664 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
665 if (temp_ht_ops)
666 hdd_ht_ops->ht_param |= temp_ht_ops <<
667 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
668
669 /* operation mode */
670 temp_ht_ops = roam_ht_ops->opMode &
671 IEEE80211_HT_OP_MODE_PROTECTION;
672 switch (temp_ht_ops) {
673 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
674 hdd_ht_ops->operation_mode |=
675 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
676 break;
677 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
678 hdd_ht_ops->operation_mode |=
679 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
680 break;
681 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
682 hdd_ht_ops->operation_mode |=
683 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
684 break;
685 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
686 default:
687 hdd_ht_ops->operation_mode |=
688 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
689 }
690 if (roam_ht_ops->nonGFDevicesPresent)
691 hdd_ht_ops->operation_mode |=
692 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
693 if (roam_ht_ops->transmitBurstLimit)
694 hdd_ht_ops->operation_mode |=
695 HT_OP_MODE_TX_BURST_LIMIT;
696 if (roam_ht_ops->obssNonHTStaPresent)
697 hdd_ht_ops->operation_mode |=
698 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
699
700 /* stbc_param */
701 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
702 HT_STBC_PARAM_MCS;
703 if (temp_ht_ops)
704 hdd_ht_ops->stbc_param |= temp_ht_ops;
705 if (roam_ht_ops->dualCTSProtection)
706 hdd_ht_ops->stbc_param |=
707 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
708 if (roam_ht_ops->secondaryBeacon)
709 hdd_ht_ops->stbc_param |=
710 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
711 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
712 hdd_ht_ops->stbc_param |=
713 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
714 if (roam_ht_ops->pcoActive)
715 hdd_ht_ops->stbc_param |=
716 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
717 if (roam_ht_ops->pcoPhase)
718 hdd_ht_ops->stbc_param |=
719 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
720
721 /* basic MCs set */
722 for (i = 0; i < 16; ++i)
723 hdd_ht_ops->basic_set[i] =
724 roam_ht_ops->basicMCSSet[i];
725}
726
727/**
728 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
729 * hdd station context.
730 * @hdd_sta_ctx: pointer to hdd station context
731 * @roam_info: pointer to roam info
732 *
733 * Return: None
734 */
735static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
736 tCsrRoamInfo *roam_info)
737{
738 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
739 struct ieee80211_vht_operation *hdd_vht_ops =
740 &hdd_sta_ctx->conn_info.vht_operation;
741
742 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
743
744 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
745 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
746 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
747 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
748}
749
750
751/**
752 * hdd_save_bss_info() - save connection info in hdd sta ctx
753 * @adapter: Pointer to adapter
754 * @roam_info: pointer to roam info
755 *
756 * Return: None
757 */
758static void hdd_save_bss_info(hdd_adapter_t *adapter,
759 tCsrRoamInfo *roam_info)
760{
761 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
762
763 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
764 hdd_sta_ctx->conn_info.operationChannel);
765 if (roam_info->vht_caps.present) {
766 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
767 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
768 } else {
769 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
770 }
771 if (roam_info->ht_caps.present) {
772 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
773 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
774 } else {
775 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
776 }
777 if (roam_info->reassoc)
778 hdd_sta_ctx->conn_info.roam_count++;
779 if (roam_info->hs20vendor_ie.present) {
780 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
781 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
782 &roam_info->hs20vendor_ie,
783 sizeof(roam_info->hs20vendor_ie));
784 } else {
785 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
786 }
787 if (roam_info->ht_operation.present) {
788 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
789 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
790 } else {
791 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
792 }
793 if (roam_info->vht_operation.present) {
794 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
795 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
796 } else {
797 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
798 }
799}
800
801/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 * hdd_conn_save_connect_info() - save current connection information
803 * @pAdapter: pointer to adapter
804 * @pRoamInfo: pointer to roam info
805 * @eBssType: bss type
806 *
807 * Return: none
808 */
809static void
810hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
811 eCsrRoamBssType eBssType)
812{
813 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
814 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
815
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530816 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817
818 if (pRoamInfo) {
819 /* Save the BSSID for the connection */
820 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530821 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530822 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 &pRoamInfo->bssid);
824
825 /*
826 * Save the Station ID for this station from
827 * the 'Roam Info'. For IBSS mode, staId is
828 * assigned in NEW_PEER_IND. For reassoc,
829 * the staID doesn't change and it may be invalid
830 * in this structure so no change here.
831 */
832 if (!pRoamInfo->fReassocReq) {
833 pHddStaCtx->conn_info.staId[0] =
834 pRoamInfo->staId;
835 }
836 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530837 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 &pRoamInfo->bssid);
839 } else {
840 /*
841 * can't happen. We need a valid IBSS or Infra setting
842 * in the BSSDescription or we can't function.
843 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530844 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 }
846
847 /* notify WMM */
848 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
849
850 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530851 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 } else {
853 /* Get Multicast Encryption Type */
854 encryptType =
855 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
856 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
857 /* Get Unicast Encryption Type */
858 encryptType =
859 pRoamInfo->u.pConnectedProfile->EncryptionType;
860 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
861
862 pHddStaCtx->conn_info.authType =
863 pRoamInfo->u.pConnectedProfile->AuthType;
864
865 pHddStaCtx->conn_info.operationChannel =
866 pRoamInfo->u.pConnectedProfile->operationChannel;
867
868 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530869 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 &pRoamInfo->u.pConnectedProfile->SSID,
871 sizeof(tSirMacSSid));
872
873 /* Save dot11mode in which STA associated to AP */
874 pHddStaCtx->conn_info.dot11Mode =
875 pRoamInfo->u.pConnectedProfile->dot11Mode;
876
877 pHddStaCtx->conn_info.proxyARPService =
878 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530879
880 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
881
882 pHddStaCtx->conn_info.rate_flags =
883 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530885 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887}
888
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889/**
890 * hdd_send_ft_assoc_response() - send fast transition assoc response
891 * @dev: pointer to net device
892 * @pAdapter: pointer to adapter
893 * @pCsrRoamInfo: pointer to roam info
894 *
895 * Send the 11R key information to the supplicant. Only then can the supplicant
896 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
897 * for the same purpose.)
898 *
899 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
900 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
901 * This is the Assoc Response.
902 *
903 * Return: none
904 */
905static void
906hdd_send_ft_assoc_response(struct net_device *dev,
907 hdd_adapter_t *pAdapter,
908 tCsrRoamInfo *pCsrRoamInfo)
909{
910 union iwreq_data wrqu;
911 char *buff;
912 unsigned int len = 0;
913 u8 *pFTAssocRsp = NULL;
914
915 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700916 hdd_err("pCsrRoamInfo->nAssocRspLength=%d",
917 (int)pCsrRoamInfo->nAssocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 return;
919 }
920
921 pFTAssocRsp =
922 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
923 pCsrRoamInfo->nAssocReqLength);
924 if (pFTAssocRsp == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700925 hdd_err("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 return;
927 }
928 /* pFTAssocRsp needs to point to the IEs */
929 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700930 hdd_notice("AssocRsp is now at %02x%02x",
931 (unsigned int)pFTAssocRsp[0],
932 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933
934 /* We need to send the IEs to the supplicant. */
935 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
936 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700937 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 return;
939 }
940 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
941 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
942 wrqu.data.length = len;
943 memset(buff, 0, IW_GENERIC_IE_MAX);
944 memcpy(buff, pFTAssocRsp, len);
945 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
946
947 kfree(buff);
948}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950/**
951 * hdd_send_ft_event() - send fast transition event
952 * @pAdapter: pointer to adapter
953 *
954 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
955 * FT events to the supplicant. At the reception of Auth2 we send the RIC
956 * followed by the auth response IEs to the supplicant.
957 * Once both are received in the supplicant, an FT event is generated
958 * to the supplicant.
959 *
960 * Return: none
961 */
962static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
963{
964 uint16_t auth_resp_len = 0;
965 uint32_t ric_ies_length = 0;
966 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
967
968#if defined(KERNEL_SUPPORT_11R_CFG80211)
969 struct cfg80211_ft_event_params ftEvent;
970 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
971 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
972 struct net_device *dev = pAdapter->dev;
973#else
974 char *buff;
975 union iwreq_data wrqu;
976 uint16_t str_len;
977#endif
978
979#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530980 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
981 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982
983 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
984 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
985 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700986 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 }
988
989 ftEvent.ric_ies = ricIe;
990 ftEvent.ric_ies_len = ric_ies_length;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700991 hdd_notice("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992
993 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
994 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
995 &auth_resp_len);
996
997 if (auth_resp_len == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700998 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 return;
1000 }
1001
1002 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1003
1004 ftEvent.target_ap = ftIe;
1005
Anurag Chouhan6d760662016-02-20 16:05:43 +05301006 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1007 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001009 hdd_notice("ftEvent.ies_len %zu", ftEvent.ies_len);
1010 hdd_notice("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1011 hdd_notice("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 ftEvent.target_ap[0], ftEvent.target_ap[1],
1013 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1014 ftEvent.target_ap[5]);
1015
1016 (void)cfg80211_ft_event(dev, &ftEvent);
1017
1018#else
1019 /* We need to send the IEs to the supplicant */
1020 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
1021 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001022 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 return;
1024 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301025 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026
1027 /* Sme needs to send the RIC IEs first */
1028 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1029 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1030 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1031 &ric_ies_length);
1032 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001033 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 } else {
1035 wrqu.data.length = str_len + ric_ies_length;
1036 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1037 }
1038
1039 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301040 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1042 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1043 (u8 *) &buff[str_len],
1044 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1045
1046 if (auth_resp_len == 0) {
1047 kfree(buff);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001048 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 return;
1050 }
1051
1052 wrqu.data.length = str_len + auth_resp_len;
1053 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1054
1055 kfree(buff);
1056#endif
1057}
1058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059#ifdef FEATURE_WLAN_ESE
1060/**
1061 * hdd_send_new_ap_channel_info() - send new ap channel info
1062 * @dev: pointer to net device
1063 * @pAdapter: pointer to adapter
1064 * @pCsrRoamInfo: pointer to roam info
1065 *
1066 * Send the ESE required "new AP Channel info" to the supplicant.
1067 * (This keeps the supplicant "up to date" on the current channel.)
1068 *
1069 * The current (new AP) channel information is passed in.
1070 *
1071 * Return: none
1072 */
1073static void
1074hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1075 tCsrRoamInfo *pCsrRoamInfo)
1076{
1077 union iwreq_data wrqu;
1078 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1079
1080 if (descriptor == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001081 hdd_err("pCsrRoamInfo->pBssDesc(%p)", descriptor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 return;
1083 }
1084 /*
1085 * Send the Channel event, the supplicant needs this to generate
1086 * the Adjacent AP report.
1087 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001088 hdd_warn("Sending up an SIOCGIWFREQ, channelId(%d)",
1089 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 memset(&wrqu, '\0', sizeof(wrqu));
1091 wrqu.freq.m = descriptor->channelId;
1092 wrqu.freq.e = 0;
1093 wrqu.freq.i = 0;
1094 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1095}
1096
1097#endif /* FEATURE_WLAN_ESE */
1098
1099/**
1100 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1101 * @pAdapter: pointer to adapter
1102 * @pCsrRoamInfo: pointer to roam info
1103 *
1104 * Return: none
1105 */
1106static void
1107hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1108 tCsrRoamInfo *pCsrRoamInfo)
1109{
1110 union iwreq_data wrqu;
1111 u8 *pBeaconIes;
1112 u8 currentLen = 0;
1113 char *buff;
1114 int totalIeLen = 0, currentOffset = 0, strLen;
1115
1116 memset(&wrqu, '\0', sizeof(wrqu));
1117
1118 if (0 == pCsrRoamInfo->nBeaconLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001119 hdd_warn("pCsrRoamInfo->nBeaconFrameLength = 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120 return;
1121 }
1122 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1123 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001124 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125 return;
1126 }
1127 /* pBeaconIes needs to point to the IEs */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001128 hdd_notice("Beacon IEs is now at %02x%02x",
1129 (unsigned int)pBeaconIes[0],
1130 (unsigned int)pBeaconIes[1]);
1131 hdd_notice("Beacon IEs length = %d",
1132 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133
1134 /* We need to send the IEs to the supplicant. */
1135 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
1136 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001137 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 return;
1139 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301140 qdf_mem_zero(buff, IW_CUSTOM_MAX);
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
1170 kfree(buff);
1171}
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{
1183 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1184 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1185 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1186 union iwreq_data wrqu;
1187 int we_event;
1188 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301189 struct qdf_mac_addr peerMacAddr;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301190 QDF_STATUS qdf_status;
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 */
1206 wlan_hdd_tdls_notify_disconnect(pAdapter);
1207 }
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
1277 qdf_status = hdd_add_peer_object(pAdapter->hdd_vdev,
1278 pAdapter->device_mode,
1279 peerMacAddr.bytes);
1280 if (QDF_IS_STATUS_ERROR(qdf_status))
1281 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1282 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1283
Abhishek Singh1c676222016-05-09 14:20:28 +05301284 /* send peer status indication to oem app */
1285 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
1286 ePeerConnected,
1287 pCsrRoamInfo->
1288 timingMeasCap,
1289 pAdapter->sessionId,
1290 &chan_info,
1291 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001292 /* Update tdls module about connection event */
1293 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001296#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 /* start timer in sta/p2p_cli */
1298 spin_lock_bh(&pHddCtx->bus_bw_lock);
1299 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1300 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001301 cdp_get_intra_bss_fwd_pkts_count(
1302 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301303 &pAdapter->prev_fwd_tx_packets,
1304 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1306 hdd_start_bus_bw_compute_timer(pAdapter);
1307#endif
1308#endif
1309 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1310 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001311 cds_update_connection_info(pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
1313 ETH_ALEN);
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301314 hdd_err("wlan: new IBSS connection to " MAC_ADDRESS_STR,
1315 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301316
1317 qdf_status = hdd_add_peer_object(pAdapter->hdd_vdev,
1318 QDF_IBSS_MODE,
1319 pCsrRoamInfo->bssid.bytes);
1320 if (QDF_IS_STATUS_ERROR(qdf_status))
1321 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1322 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 } else { /* Not Associated */
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301324 hdd_err("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301326 cds_decr_session_set_pcl(pAdapter->device_mode,
1327 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328
1329#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1330 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1331#endif
1332
Abhishek Singh1c676222016-05-09 14:20:28 +05301333 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1334 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301335 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 &pHddStaCtx->conn_info.bssId);
1337
1338 /* send peer status indication to oem app */
1339 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301340 ePeerDisconnected, 0,
1341 pAdapter->sessionId,
1342 NULL,
1343 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301345
1346 qdf_status = hdd_remove_peer_object(pAdapter->hdd_vdev,
1347 peerMacAddr.bytes);
1348 if (QDF_IS_STATUS_ERROR(qdf_status))
1349 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1350 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1351
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001352 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001353 /* Update tdls module about the disconnection event */
1354 wlan_hdd_tdls_notify_disconnect(pAdapter);
1355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356#ifdef MSM_PLATFORM
1357 /* stop timer in sta/p2p_cli */
1358 spin_lock_bh(&pHddCtx->bus_bw_lock);
1359 pAdapter->prev_tx_packets = 0;
1360 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301361 pAdapter->prev_fwd_tx_packets = 0;
1362 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1364 hdd_stop_bus_bw_compute_timer(pAdapter);
1365#endif
1366 }
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001367 cds_dump_concurrency_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 /* Send SCC/MCC Switching event to IPA */
1369 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1370
1371 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001372 /* During the WLAN uninitialization,supplicant is stopped before the
1373 * driver so not sending the status of the connection to supplicant
1374 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001375 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 wireless_send_event(dev, we_event, &wrqu, msg);
1377#ifdef FEATURE_WLAN_ESE
1378 if (eConnectionState_Associated ==
1379 pHddStaCtx->conn_info.connState) {
1380 if ((pRoamProfile->AuthType.authType[0] ==
1381 eCSR_AUTH_TYPE_CCKM_RSN) ||
1382 (pRoamProfile->AuthType.authType[0] ==
1383 eCSR_AUTH_TYPE_CCKM_WPA))
1384 hdd_send_new_ap_channel_info(dev, pAdapter,
1385 pCsrRoamInfo);
1386 }
1387#endif
1388 }
1389}
1390
1391/**
1392 * hdd_conn_remove_connect_info() - remove connection info
1393 * @pHddStaCtx: pointer to global HDD station context
1394 * @pCsrRoamInfo: pointer to roam info
1395 *
1396 * Return: none
1397 */
1398static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1399{
1400 /* Remove staId, bssId and peerMacAddress */
1401 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301402 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1403 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301404 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405
1406 /* Clear all security settings */
1407 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1408 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1409 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1410
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301411 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1412 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 pHddStaCtx->conn_info.proxyARPService = 0;
1415
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301416 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417}
1418
1419/**
1420 * hdd_roam_deregister_sta() - deregister station
1421 * @pAdapter: pointer to adapter
1422 * @staId: station identifier
1423 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301424 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 */
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07001426QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301428 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1430
1431 if (eConnectionState_IbssDisconnected ==
1432 pHddStaCtx->conn_info.connState) {
1433 /*
1434 * Do not set the carrier off when the last peer leaves.
1435 * We will set the carrier off while stopping the IBSS.
1436 */
1437 }
1438
Leo Changfdb45c32016-10-28 11:09:23 -07001439 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
1440 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301441 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001442 hdd_err("cdp_peer_clear() failed for staID %d. Status(%d) [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301443 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301445 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446}
1447
1448/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301449 * hdd_print_bss_info() - print bss info
1450 * @hdd_sta_ctx: pointer to hdd station context
1451 *
1452 * Return: None
1453 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001454static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301455{
1456 uint32_t *cap_info;
1457
1458 hdd_info("WIFI DATA LOGGER");
1459 hdd_info("channel: %d",
1460 hdd_sta_ctx->conn_info.freq);
1461 hdd_info("dot11mode: %d",
1462 hdd_sta_ctx->conn_info.dot11Mode);
1463 hdd_info("AKM: %d",
1464 hdd_sta_ctx->conn_info.authType);
1465 hdd_info("ssid: %.*s",
1466 hdd_sta_ctx->conn_info.SSID.SSID.length,
1467 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1468 hdd_info("roam count: %d",
1469 hdd_sta_ctx->conn_info.roam_count);
1470 hdd_info("ant_info: %d",
1471 hdd_sta_ctx->conn_info.txrate.nss);
1472 hdd_info("datarate legacy %d",
1473 hdd_sta_ctx->conn_info.txrate.legacy);
1474 hdd_info("datarate mcs: %d",
1475 hdd_sta_ctx->conn_info.txrate.mcs);
1476 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1477 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1478 hdd_info("ht caps: %x", *cap_info);
1479 }
1480 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1481 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1482 hdd_info("vht caps: %x", *cap_info);
1483 }
1484 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1485 hdd_info("hs20 info: %x",
1486 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1487 hdd_info("signal: %d",
1488 hdd_sta_ctx->conn_info.signal);
1489 hdd_info("noise: %d",
1490 hdd_sta_ctx->conn_info.noise);
1491}
1492
1493/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494 * hdd_dis_connect_handler() - disconnect event handler
1495 * @pAdapter: pointer to adapter
1496 * @pRoamInfo: pointer to roam info
1497 * @roamId: roam identifier
1498 * @roamStatus: roam status
1499 * @roamResult: roam result
1500 *
1501 * This function handles disconnect event:
1502 * 1. Disable transmit queues;
1503 * 2. Clean up internal connection states and data structures;
1504 * 3. Send disconnect indication to supplicant.
1505 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301506 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301508static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 tCsrRoamInfo *pRoamInfo,
1510 uint32_t roamId,
1511 eRoamCmdStatus roamStatus,
1512 eCsrRoamResult roamResult)
1513{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301514 QDF_STATUS status = QDF_STATUS_SUCCESS;
1515 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 struct net_device *dev = pAdapter->dev;
1517 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1518 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1519 uint8_t sta_id;
1520 bool sendDisconInd = true;
1521
1522 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001523 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301524 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 }
1526 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001527 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER,
1529 WLAN_CONTROL_PATH);
1530
1531 if (hdd_ipa_is_enabled(pHddCtx))
1532 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001533 HDD_IPA_STA_DISCONNECT,
1534 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535
1536#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1537 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1538#endif
1539
Nirav Shah1da77682016-05-03 20:16:39 +05301540 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1541 pAdapter->sessionId,
1542 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543
1544 /* HDD has initiated disconnect, do not send disconnect indication
1545 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301546 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 * to cfg80211_disconnected.
1548 */
1549 if ((eConnectionState_Disconnecting ==
1550 pHddStaCtx->conn_info.connState) ||
1551 (eConnectionState_NotConnected ==
1552 pHddStaCtx->conn_info.connState)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001553 hdd_notice("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 sendDisconInd = false;
1555 }
1556
1557 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1558 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 hdd_conn_set_connection_state(pAdapter,
1560 eConnectionState_Disconnecting);
1561 }
1562
1563 hdd_clear_roam_profile_ie(pAdapter);
1564 hdd_wmm_init(pAdapter);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301565 hdd_info("Invoking packetdump deregistration API");
1566 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567
1568 /* indicate 'disconnect' status to wpa_supplicant... */
1569 hdd_send_association_event(dev, pRoamInfo);
1570 /* indicate disconnected event to nl80211 */
1571 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1572 /*
1573 * Only send indication to kernel if not initiated
1574 * by kernel
1575 */
1576 if (sendDisconInd) {
1577 /*
1578 * To avoid wpa_supplicant sending "HANGED" CMD
1579 * to ICS UI.
1580 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001581 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1582 if (pRoamInfo->reasonCode ==
1583 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1584 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301585 wlan_hdd_cfg80211_indicate_disconnect(
1586 dev, false,
1587 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001588 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301589 wlan_hdd_cfg80211_indicate_disconnect(
1590 dev, false,
1591 WLAN_REASON_UNSPECIFIED
1592 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001593 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301595 hdd_info("sent disconnected event to nl80211, reason code %d",
1596 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1597 pRoamInfo->reasonCode :
1598 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 }
1600 /*
1601 * During the WLAN uninitialization,supplicant is stopped
1602 * before the driver so not sending the status of the
1603 * connection to supplicant.
1604 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001605 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001607 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 if (global_p2p_connection_status ==
1609 P2P_CLIENT_CONNECTED_STATE_1) {
1610 global_p2p_connection_status =
1611 P2P_CLIENT_DISCONNECTED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001612 hdd_err("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 } else if (global_p2p_connection_status ==
1614 P2P_CLIENT_COMPLETED_STATE) {
1615 global_p2p_connection_status =
1616 P2P_NOT_ACTIVE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001617 hdd_err("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 }
1619 }
1620#endif
1621
1622 }
1623 }
1624
1625 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001627 if (hdd_remove_beacon_filter(pAdapter) != 0)
1628 hdd_err("hdd_remove_beacon_filter() failed");
1629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301631 uint8_t i;
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001632 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301634 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301635 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]",
1636 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301637 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 }
1639 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301640 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001641 for (i = 0; i < MAX_PEERS; i++) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301642 if (0 == pHddStaCtx->conn_info.staId[i])
1643 continue;
1644 sta_id = pHddStaCtx->conn_info.staId[i];
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001645 hdd_info("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301646 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301647 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001648 hdd_err("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301649 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301650 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301651 }
1652 /* set the staid and peer mac as 0, all other
1653 * reset are done in hdd_connRemoveConnectInfo.
1654 */
1655 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301656 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301657 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301658 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1659 pHddCtx->sta_to_adapter[sta_id] = NULL;
1660 }
1661 } else {
1662 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhc9941602016-08-09 16:06:22 +05301663
1664 /* clear scan cache for Link Lost */
1665 if (pRoamInfo && !pRoamInfo->reasonCode &&
1666 (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult)) {
1667 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1668 pHddStaCtx->conn_info.bssId.bytes);
1669 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1670 pHddStaCtx->conn_info.bssId.bytes);
1671 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301672 /* We should clear all sta register with TL,
1673 * for now, only one.
1674 */
1675 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301676 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001677 hdd_err("hdd_roam_deregister_sta() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301678 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301679 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301680 }
1681 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 /* Clear saved connection information in HDD */
1684 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
1686#ifdef WLAN_FEATURE_GTK_OFFLOAD
Krunal Sonibe766b02016-03-10 13:00:44 -08001687 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1688 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1690 sizeof(tSirGtkOffloadParams));
1691 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
1692 }
1693#endif
1694
1695#ifdef FEATURE_WLAN_TDLS
1696 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1697 wlan_hdd_tdls_disconnection_callback(pAdapter);
1698#endif
1699
Krunal Sonibe766b02016-03-10 13:00:44 -08001700 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1701 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1703 (pAdapter),
1704 pAdapter->sessionId);
1705 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301706 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 /* Unblock anyone waiting for disconnect to complete */
1708 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301709 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 return status;
1711}
1712
1713/**
1714 * hdd_set_peer_authorized_event() - set peer_authorized_event
1715 * @vdev_id: vdevid
1716 *
1717 * Return: None
1718 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001719static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301721 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722 hdd_adapter_t *adapter = NULL;
1723
1724 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1725 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001726 hdd_err("Invalid vdev_id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 }
1728 complete(&adapter->sta_authorized_event);
1729}
1730
1731/**
1732 * hdd_change_peer_state() - change peer state
1733 * @pAdapter: HDD adapter
1734 * @sta_state: peer state
1735 * @roam_synch_in_progress: roam synch in progress
1736 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301737 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301739QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 uint8_t sta_id,
1741 enum ol_txrx_peer_state sta_state,
1742 bool roam_synch_in_progress)
1743{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301744 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001745 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001746 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1747 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1748 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749
1750 if (!pdev) {
1751 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301752 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 }
1754
1755 if (sta_id >= WLAN_MAX_STA_COUNT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001756 hdd_err("Invalid sta id :%d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301757 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 }
1759
Leo Changfdb45c32016-10-28 11:09:23 -07001760 peer = cdp_peer_find_by_local_id(soc, pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301762 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763
Leo Changfdb45c32016-10-28 11:09:23 -07001764 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001765 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001766 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001767 return QDF_STATUS_E_FAULT;
1768 }
1769
Leo Changfdb45c32016-10-28 11:09:23 -07001770 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301771 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001772 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301773 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 }
1775#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1776 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301777 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778#endif
1779
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001780 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1782 /* make sure event is reset */
1783 INIT_COMPLETION(pAdapter->sta_authorized_event);
1784#endif
1785
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001786 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 hdd_set_peer_authorized_event,
1788 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301789 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001790 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301791 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 }
1793
Krunal Sonibe766b02016-03-10 13:00:44 -08001794 if (pAdapter->device_mode == QDF_STA_MODE ||
1795 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001797 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 unsigned long rc;
1799
1800 /* wait for event from firmware to set the event */
1801 rc = wait_for_completion_timeout(
1802 &pAdapter->sta_authorized_event,
1803 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
1804 if (!rc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001805 hdd_notice("timeout waiting for sta_authorized_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 }
Leo Changfdb45c32016-10-28 11:09:23 -07001807 vdev = cdp_peer_get_vdev(soc, peer);
1808 cdp_fc_vdev_unpause(soc, vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001809 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810#endif
1811 }
1812 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301813 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814}
1815
1816/**
1817 * hdd_roam_register_sta() - register station
1818 * @pAdapter: pointer to adapter
1819 * @pRoamInfo: pointer to roam info
1820 * @staId: station identifier
1821 * @pPeerMacAddress: peer MAC address
1822 * @pBssDesc: pointer to BSS description
1823 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301824 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001826QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 tCsrRoamInfo *pRoamInfo,
1828 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301829 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 tSirBssDescription *pBssDesc)
1831{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301832 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 struct ol_txrx_desc_type staDesc = { 0 };
1834 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001835 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001836 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1837 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838
1839 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301840 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841
1842 /* Get the Station ID from the one saved during the association */
1843 staDesc.sta_id = staId;
1844
1845 /* set the QoS field appropriately */
1846 if (hdd_wmm_is_active(pAdapter))
1847 staDesc.is_qos_enabled = 1;
1848 else
1849 staDesc.is_qos_enabled = 0;
1850
1851#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001852 hdd_notice("WAPI STA Registered: %d",
1853 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 if (pAdapter->wapi_info.fIsWapiSta)
1855 staDesc.is_wapi_supported = 1;
1856 else
1857 staDesc.is_wapi_supported = 0;
1858#endif /* FEATURE_WLAN_WAPI */
1859
Dhanashri Atre50141c52016-04-07 13:15:29 -07001860 /* Register the vdev transmit and receive functions */
1861 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1862 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001863
1864 pAdapter->txrx_vdev = cdp_get_vdev_from_vdev_id(soc, pdev,
1865 pAdapter->sessionId);
1866 if (!pAdapter->txrx_vdev) {
1867 hdd_err("%s find vdev fail", __func__);
1868 return QDF_STATUS_E_FAILURE;
1869 }
1870
1871 txrx_ops.tx.tx = NULL;
1872 cdp_vdev_register(soc, pAdapter->txrx_vdev, pAdapter, &txrx_ops);
1873 if (!txrx_ops.tx.tx) {
1874 hdd_err("%s vdev register fail", __func__);
1875 return QDF_STATUS_E_FAILURE;
1876 }
1877
Dhanashri Atre50141c52016-04-07 13:15:29 -07001878 pAdapter->tx_fn = txrx_ops.tx.tx;
Leo Changfdb45c32016-10-28 11:09:23 -07001879 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301880 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001881 hdd_warn("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001882 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301883 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 }
1885
1886 if (!pRoamInfo->fAuthRequired) {
1887 /*
1888 * Connections that do not need Upper layer auth, transition
1889 * TLSHIM directly to 'Authenticated' state
1890 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301891 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001893 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1895 pRoamInfo->roamSynchInProgress
1896#else
1897 false
1898#endif
1899 );
1900
1901 hdd_conn_set_authenticated(pAdapter, true);
1902 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001903 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301905 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001907 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1909 pRoamInfo->roamSynchInProgress
1910#else
1911 false
1912#endif
1913 );
1914 hdd_conn_set_authenticated(pAdapter, false);
1915 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301916 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917}
1918
1919/**
1920 * hdd_send_re_assoc_event() - send reassoc event
1921 * @dev: pointer to net device
1922 * @pAdapter: pointer to adapter
1923 * @pCsrRoamInfo: pointer to roam info
1924 * @reqRsnIe: pointer to RSN Information element
1925 * @reqRsnLength: length of RSN IE
1926 *
1927 * Return: none
1928 */
1929static void hdd_send_re_assoc_event(struct net_device *dev,
1930 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
1931 uint8_t *reqRsnIe, uint32_t reqRsnLength)
1932{
1933 unsigned int len = 0;
1934 u8 *pFTAssocRsp = NULL;
1935 uint8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Naveen Rawat14298b92015-11-25 16:27:41 -08001936 uint8_t *assoc_req_ies = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 uint32_t rspRsnLength = 0;
1938 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1940 uint8_t *buf_ptr, ssid_ie_len;
1941 struct cfg80211_bss *bss = NULL;
1942 uint8_t *final_req_ie = NULL;
1943 tCsrRoamConnectedProfile roam_profile;
1944 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1945
Jeff Johnsonfdb73432016-10-11 08:07:27 -07001946 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
1947
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001949 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001950 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 }
1952
Naveen Rawat14298b92015-11-25 16:27:41 -08001953 if (!assoc_req_ies) {
1954 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001955 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001956 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001958 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 goto done;
1960 }
1961
1962 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001963 hdd_err("Invalid assoc response length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 goto done;
1965 }
1966
1967 pFTAssocRsp =
1968 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1969 pCsrRoamInfo->nAssocReqLength);
1970 if (pFTAssocRsp == NULL)
1971 goto done;
1972
1973 /* pFTAssocRsp needs to point to the IEs */
1974 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001975 hdd_info("AssocRsp is now at %02x%02x",
1976 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977
1978 /*
1979 * Active session count is decremented upon disconnection, but during
1980 * roaming, there is no disconnect indication and hence active session
1981 * count is not decremented.
1982 * After roaming is completed, active session count is incremented
1983 * as a part of connect indication but effectively after roaming the
1984 * active session count should still be the same and hence upon
1985 * successful reassoc decrement the active session count here.
1986 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001987 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301988 cds_decr_session_set_pcl(pAdapter->device_mode,
1989 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990
1991 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
1992 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1993 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301994 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
1995 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996
1997 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1998 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2000 &roam_profile);
2001 bss = cfg80211_get_bss(pAdapter->wdev.wiphy, chan,
2002 pCsrRoamInfo->bssid.bytes,
2003 &roam_profile.SSID.ssId[0], roam_profile.SSID.length,
Ryan Hsu535d16a2016-01-18 16:45:12 -08002004#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
Ryan Hsu535d16a2016-01-18 16:45:12 -08002006#else
2007 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
2008#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009
2010 if (bss == NULL)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002011 hdd_err("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 buf_ptr = buf_ssid_ie;
2013 *buf_ptr = SIR_MAC_SSID_EID;
2014 buf_ptr++;
2015 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2016 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302017 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 roam_profile.SSID.length);
2019 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08002020 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302021 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002022 buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 final_req_ie = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
2024 if (final_req_ie == NULL)
2025 goto done;
2026 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302027 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302029 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2030 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2031 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08002033 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302034 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002035 final_req_ie, (ssid_ie_len + reqRsnLength));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036 cfg80211_roamed_bss(dev, bss,
2037 final_req_ie, (ssid_ie_len + reqRsnLength),
2038 rspRsnIe, rspRsnLength, GFP_KERNEL);
2039
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302040 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002041 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2042 pCsrRoamInfo->nAssocReqLength);
2043
2044 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302045 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002046 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2047
Prakash Dhavali989127d2016-11-29 14:56:44 +05302048 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002049 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2050 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002051 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002053 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 if (final_req_ie)
2055 kfree(final_req_ie);
2056 kfree(rspRsnIe);
Naveen Rawat14298b92015-11-25 16:27:41 -08002057 kfree(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058}
2059
2060/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302061 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002062 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302063 *
2064 * Return: roam sync status if roaming offloaded else false
2065 */
2066#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002067bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302068{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002069 if (roaminfo)
2070 return roaminfo->roamSynchInProgress;
2071 else
2072 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302073}
2074#endif
2075
2076
2077/**
2078 * hdd_change_sta_state_authenticated()-
2079 * This function changes STA state to authenticated
2080 * @adapter: pointer to the adapter structure.
2081 * @roaminfo: pointer to the RoamInfo structure.
2082 *
2083 * This is called from hdd_RoamSetKeyCompleteHandler
2084 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2085 *
2086 * Return: 0 on success and errno on failure
2087 */
2088static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2089 tCsrRoamInfo *roaminfo)
2090{
2091 int ret;
Dustin Brownf660fb42016-09-09 12:04:00 -07002092 uint32_t timeout;
Govind Singhedc5cda2015-10-23 17:11:35 +05302093 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002094 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302095
Dustin Brownf660fb42016-09-09 12:04:00 -07002096 timeout = hddstactx->hdd_ReassocScenario ?
2097 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002098 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002099
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002100 hdd_info("Changing TL state to AUTHENTICATED for StaId= %d",
2101 hddstactx->conn_info.staId[0]);
Govind Singhedc5cda2015-10-23 17:11:35 +05302102
2103 /* Connections that do not need Upper layer authentication,
2104 * transition TL to 'Authenticated' state after the keys are set
2105 */
2106 ret = hdd_change_peer_state(adapter,
2107 hddstactx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002108 OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302109 hdd_is_roam_sync_in_progress(roaminfo));
2110 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08002111 if ((QDF_STA_MODE == adapter->device_mode) ||
2112 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302113 sme_ps_enable_auto_ps_timer(
2114 WLAN_HDD_GET_HAL_CTX(adapter),
2115 adapter->sessionId,
Dustin Brownf660fb42016-09-09 12:04:00 -07002116 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302117 }
2118
2119 return ret;
2120}
2121
2122/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 * hdd_roam_set_key_complete_handler() - Update the security parameters
2124 * @pAdapter: pointer to adapter
2125 * @pRoamInfo: pointer to roam info
2126 * @roamId: roam id
2127 * @roamStatus: roam status
2128 * @roamResult: roam result
2129 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302130 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302132static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 tCsrRoamInfo *pRoamInfo,
2134 uint32_t roamId,
2135 eRoamCmdStatus roamStatus,
2136 eCsrRoamResult roamResult)
2137{
2138 eCsrEncryptionType connectedCipherAlgo;
2139 bool fConnected = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302140 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302142 tHalHandle hal_ctx = WLAN_HDD_GET_HAL_CTX(pAdapter);
2143 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
2144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 ENTER();
2146
2147 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002148 hdd_info("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302149 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150 }
2151 /*
2152 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2153 * then go to 'authenticated'. For all other authentication types
2154 * (those that do not require upper layer authentication) we can put TL
2155 * directly into 'authenticated' state.
2156 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002157 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002158 MAC_ADDRESS_STR, roamStatus, roamResult,
2159 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2160
2161 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2162 &connectedCipherAlgo);
2163 if (fConnected) {
Krunal Sonibe766b02016-03-10 13:00:44 -08002164 if (QDF_IBSS_MODE == pAdapter->device_mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 uint8_t staId;
2166
Anurag Chouhanc5548422016-02-24 18:33:27 +05302167 if (qdf_is_macaddr_broadcast(&pRoamInfo->peerMac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 pHddStaCtx->roam_info.roamingState =
2169 HDD_ROAM_STATE_NONE;
2170 } else {
Deepak Dhamdhere5872c8c2016-06-02 15:51:47 -07002171 qdf_status = hdd_get_peer_sta_id(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 pHddStaCtx,
2173 &pRoamInfo->peerMac,
2174 &staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302175 if (QDF_STATUS_SUCCESS == qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002176 hdd_info("WLAN TL STA Ptk Installed for STAID=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 staId);
2178 pHddStaCtx->roam_info.roamingState =
2179 HDD_ROAM_STATE_NONE;
2180 }
2181 }
2182 } else {
2183 /*
2184 * TODO: Considering getting a state machine in
Govind Singhedc5cda2015-10-23 17:11:35 +05302185 * HDD later.This routine is invoked twice.
2186 * 1)set PTK 2)set GTK.The following if
2187 * statement will be TRUE when setting GTK.
2188 * At this time we don't handle the state in detail.
2189 * Related CR: 174048 - TL not in authenticated state
Jeff Johnson5a062372017-01-12 09:51:25 -08002190 */
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302191 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302192 pHddStaCtx->conn_info.gtk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302193 /*
2194 * PTK exchange happens in preauthentication
2195 * itself if key_mgmt is FT-PSK, ptk_installed
2196 * was false as there is no set PTK after
2197 * roaming. STA TL state moves to authenticated
2198 * only if ptk_installed is true. So, make
2199 * ptk_installed to true in case of 11R roaming.
2200 */
2201 if (csr_neighbor_roam_is11r_assoc(mac_ctx,
2202 pAdapter->sessionId))
2203 pHddStaCtx->conn_info.ptk_installed =
2204 true;
2205 } else {
Govind Singhedc5cda2015-10-23 17:11:35 +05302206 pHddStaCtx->conn_info.ptk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302207 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302208
2209 /* In WPA case move STA to authenticated when
2210 * ptk is installed.Earlier in WEP case STA
2211 * was moved to AUTHENTICATED prior to setting
2212 * the unicast key and it was resulting in sending
2213 * few un-encrypted packet. Now in WEP case
2214 * STA state will be moved to AUTHENTICATED
2215 * after we set the unicast and broadcast key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 */
Govind Singhedc5cda2015-10-23 17:11:35 +05302217 if ((pHddStaCtx->conn_info.ucEncryptionType ==
2218 eCSR_ENCRYPT_TYPE_WEP40) ||
2219 (pHddStaCtx->conn_info.ucEncryptionType ==
2220 eCSR_ENCRYPT_TYPE_WEP104) ||
2221 (pHddStaCtx->conn_info.ucEncryptionType ==
2222 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2223 (pHddStaCtx->conn_info.ucEncryptionType ==
2224 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2225 if (pHddStaCtx->conn_info.gtk_installed &&
2226 pHddStaCtx->conn_info.ptk_installed)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302227 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302228 hdd_change_sta_state_authenticated(pAdapter,
2229 pRoamInfo);
2230 } else if (pHddStaCtx->conn_info.ptk_installed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302231 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302232 hdd_change_sta_state_authenticated(pAdapter,
2233 pRoamInfo);
2234 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235
Govind Singhedc5cda2015-10-23 17:11:35 +05302236 if (pHddStaCtx->conn_info.gtk_installed &&
2237 pHddStaCtx->conn_info.ptk_installed) {
2238 pHddStaCtx->conn_info.gtk_installed = false;
2239 pHddStaCtx->conn_info.ptk_installed = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 }
2241
2242 pHddStaCtx->roam_info.roamingState =
Govind Singhedc5cda2015-10-23 17:11:35 +05302243 HDD_ROAM_STATE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 }
2245 } else {
2246 /*
2247 * possible disassoc after issuing set key and waiting
2248 * set key complete.
2249 */
2250 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2251 }
2252
2253 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302254 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255}
2256
2257/**
2258 * hdd_perform_roam_set_key_complete() - perform set key complete
2259 * @pAdapter: pointer to adapter
2260 *
2261 * Return: none
2262 */
2263void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2264{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302265 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2267 tCsrRoamInfo roamInfo;
2268 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302269 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302270 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302271 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302272 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302274 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 hdd_roam_set_key_complete_handler(pAdapter,
2276 &roamInfo,
2277 pHddStaCtx->roam_info.roamId,
2278 pHddStaCtx->roam_info.roamStatus,
2279 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302280 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002281 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282
2283 pHddStaCtx->roam_info.deferKeyComplete = false;
2284}
2285
2286/**
2287 * hdd_association_completion_handler() - association completion handler
2288 * @pAdapter: pointer to adapter
2289 * @pRoamInfo: pointer to roam info
2290 * @roamId: roam id
2291 * @roamStatus: roam status
2292 * @roamResult: roam result
2293 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302294 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302296static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 tCsrRoamInfo *pRoamInfo,
2298 uint32_t roamId,
2299 eRoamCmdStatus roamStatus,
2300 eCsrRoamResult roamResult)
2301{
2302 struct net_device *dev = pAdapter->dev;
2303 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2304 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302305 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2307 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 bool hddDisconInProgress = false;
2310 unsigned long rc;
2311
2312 if (!pHddCtx) {
2313 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302314 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 }
2316
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302317 /* validate config */
2318 if (!pHddCtx->config) {
2319 hdd_err("config is NULL");
2320 return QDF_STATUS_E_NULL_VALUE;
2321 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 /* HDD has initiated disconnect, do not send connect result indication
2323 * to kernel as it will be handled by __cfg80211_disconnect.
2324 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302325 if (((eConnectionState_Disconnecting ==
2326 pHddStaCtx->conn_info.connState) ||
2327 (eConnectionState_NotConnected ==
2328 pHddStaCtx->conn_info.connState)) &&
2329 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2330 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002331 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 hddDisconInProgress = true;
2333 }
2334
2335 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2336 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002337 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302338 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 }
2340 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 hdd_conn_set_connection_state(pAdapter,
2342 eConnectionState_Associated);
2343 }
2344 /* Save the connection info from CSR... */
2345 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2346 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002347
2348 if (hdd_add_beacon_filter(pAdapter) != 0)
2349 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350#ifdef FEATURE_WLAN_WAPI
2351 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2352 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2353 || pRoamInfo->u.pConnectedProfile->AuthType ==
2354 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2355 pAdapter->wapi_info.fIsWapiSta = 1;
2356 } else {
2357 pAdapter->wapi_info.fIsWapiSta = 0;
2358 }
2359#endif /* FEATURE_WLAN_WAPI */
2360
2361 /* Indicate 'connect' status to user space */
2362 hdd_send_association_event(dev, pRoamInfo);
2363
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002364 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 if (pHddCtx->miracast_value)
2366 cds_set_mas(pAdapter, pHddCtx->miracast_value);
2367 }
2368
2369 /* Initialize the Linkup event completion variable */
2370 INIT_COMPLETION(pAdapter->linkup_event_var);
2371
2372 /*
2373 * Sometimes Switching ON the Carrier is taking time to activate
2374 * the device properly. Before allowing any packet to go up to
2375 * the application, device activation has to be ensured for
2376 * proper queue mapping by the kernel. we have registered net
2377 * device notifier for device change notification. With this we
2378 * will come to know that the device is getting
2379 * activated properly.
2380 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002382 /*
2383 * Enable Linkup Event Servicing which allows the net
2384 * device notifier to set the linkup event variable.
2385 */
2386 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002388 /* Switch on the Carrier to activate the device */
2389 wlan_hdd_netif_queue_control(pAdapter,
2390 WLAN_NETIF_CARRIER_ON,
2391 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002393 /*
2394 * Wait for the Link to up to ensure all the queues
2395 * are set properly by the kernel.
2396 */
2397 rc = wait_for_completion_timeout(
2398 &pAdapter->linkup_event_var,
2399 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2400 );
2401 if (!rc)
2402 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002404 /*
2405 * Disable Linkup Event Servicing - no more service
2406 * required from the net device notifier call.
2407 */
2408 pAdapter->isLinkUpSvcNeeded = false;
2409 } else {
2410 pHddStaCtx->ft_carrier_on = false;
2411 ft_carrier_on = true;
2412 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2414 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2415 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002416 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417
2418 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2419
2420 if (hdd_ipa_is_enabled(pHddCtx))
2421 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002422 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 pRoamInfo->bssid.bytes);
2424
2425#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2426 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2427#endif
2428
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302429 hdd_info("check for SAP restart");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002430 cds_check_concurrent_intf_and_restart_sap(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431
Nirav Shah1da77682016-05-03 20:16:39 +05302432 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2433 pAdapter->sessionId,
2434 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2435
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 /*
2437 * For reassoc, the station is already registered, all we need
2438 * is to change the state of the STA in TL.
2439 * If authentication is required (WPA/WPA2/DWEP), change TL to
2440 * CONNECTED instead of AUTHENTICATED.
2441 */
2442 if (!pRoamInfo->fReassocReq) {
2443 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 u8 *pFTAssocRsp = NULL;
2445 unsigned int assocRsplen = 0;
2446 u8 *pFTAssocReq = NULL;
2447 unsigned int assocReqlen = 0;
2448 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2450 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2451
2452 /* add bss_id to cfg80211 data base */
2453 bss =
2454 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2455 pRoamInfo);
2456 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302457 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 wlan_hdd_netif_queue_control(pAdapter,
2459 WLAN_NETIF_CARRIER_OFF,
2460 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302461 if (!hddDisconInProgress) {
2462 /*
2463 * Here driver was not able to add bss
2464 * in cfg80211 database this can happen
2465 * if connected channel is not valid,
2466 * i.e reg domain was changed during
2467 * connection. Queue disconnect for the
2468 * session if disconnect is not in
2469 * progress.
2470 */
2471 hdd_err("Disconnecting...");
2472 sme_roam_disconnect(
2473 WLAN_HDD_GET_HAL_CTX(pAdapter),
2474 pAdapter->sessionId,
2475 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2476 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302477 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2480 eCSR_AUTH_TYPE_FT_RSN
2481 || pRoamInfo->u.pConnectedProfile->AuthType ==
2482 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2483
2484 /* Association Response */
2485 pFTAssocRsp =
2486 (u8 *) (pRoamInfo->pbFrames +
2487 pRoamInfo->nBeaconLength +
2488 pRoamInfo->nAssocReqLength);
2489 if (pFTAssocRsp != NULL) {
2490 /*
2491 * pFTAssocRsp needs to point to the IEs
2492 */
2493 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002494 hdd_info("AssocRsp is now at %02x%02x",
2495 (unsigned int)pFTAssocRsp[0],
2496 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 assocRsplen =
2498 pRoamInfo->nAssocRspLength -
2499 FT_ASSOC_RSP_IES_OFFSET;
2500 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002501 hdd_err("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 assocRsplen = 0;
2503 }
2504
2505 /* Association Request */
2506 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2507 pRoamInfo->nBeaconLength);
2508 if (pFTAssocReq != NULL) {
2509 if (!ft_carrier_on) {
2510 /*
2511 * pFTAssocReq needs to point to
2512 * the IEs
2513 */
2514 pFTAssocReq +=
2515 FT_ASSOC_REQ_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002516 hdd_info("pFTAssocReq is now at %02x%02x",
2517 (unsigned int)
2518 pFTAssocReq[0],
2519 (unsigned int)
2520 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 assocReqlen =
2522 pRoamInfo->nAssocReqLength -
2523 FT_ASSOC_REQ_IES_OFFSET;
2524 } else {
2525 /*
2526 * This should contain only the
2527 * FTIEs
2528 */
2529 assocReqlen =
2530 pRoamInfo->nAssocReqLength;
2531 }
2532 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002533 hdd_err("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 assocReqlen = 0;
2535 }
2536
2537 if (ft_carrier_on) {
2538 if (!hddDisconInProgress) {
2539 /*
2540 * After roaming is completed,
2541 * active session count is
2542 * incremented as a part of
2543 * connect indication but
2544 * effectively the active
2545 * session count should still
2546 * be the same and hence upon
2547 * successful reassoc
2548 * decrement the active session
2549 * count here.
2550 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002551 if (!hdd_is_roam_sync_in_progress
2552 (pRoamInfo))
2553 cds_decr_session_set_pcl
2554 (pAdapter->device_mode,
2555 pAdapter->sessionId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002556 hdd_info("ft_carrier_on is %d, sending roamed indication",
2557 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 chan =
2559 ieee80211_get_channel
2560 (pAdapter->wdev.wiphy,
2561 (int)pRoamInfo->pBssDesc->
2562 channelId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002563 hdd_info(
2564 "assocReqlen %d assocRsplen %d",
2565 assocReqlen,
2566 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002567
2568 hdd_notice(
2569 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302570 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302571 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302572 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002573 pFTAssocReq,
2574 assocReqlen);
2575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 cfg80211_roamed(dev, chan,
2577 pRoamInfo->
2578 bssid.bytes,
2579 pFTAssocReq,
2580 assocReqlen,
2581 pFTAssocRsp,
2582 assocRsplen,
2583 GFP_KERNEL);
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002584 wlan_hdd_send_roam_auth_event(
Prakash Dhavali989127d2016-11-29 14:56:44 +05302585 pAdapter,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002586 pRoamInfo->bssid.bytes,
2587 pFTAssocReq,
2588 assocReqlen,
2589 pFTAssocRsp,
2590 assocRsplen,
2591 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592 }
2593 if (sme_get_ftptk_state
2594 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2595 pAdapter->sessionId)) {
2596 sme_set_ftptk_state
2597 (WLAN_HDD_GET_HAL_CTX
2598 (pAdapter),
2599 pAdapter->sessionId,
2600 false);
2601 pRoamInfo->fAuthRequired =
2602 false;
2603
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302604 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 roam_info.bssid,
2606 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302607 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302608 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 roam_info.peerMac,
2610 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302611 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 pHddStaCtx->roam_info.roamId =
2613 roamId;
2614 pHddStaCtx->roam_info.
2615 roamStatus = roamStatus;
2616 pHddStaCtx->roam_info.
2617 deferKeyComplete = true;
2618 }
2619 } else if (!hddDisconInProgress) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002620 hdd_info("ft_carrier_on is %d, sending connect indication",
2621 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302622 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 pRoamInfo->
2624 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302625 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626 pFTAssocReq,
2627 assocReqlen,
2628 pFTAssocRsp,
2629 assocRsplen,
2630 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302631 GFP_KERNEL,
2632 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002634 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 /*
2636 * wpa supplicant expecting WPA/RSN IE in
2637 * connect result.
2638 */
2639 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2640 (pAdapter),
2641 pAdapter->sessionId,
2642 &reqRsnLength,
2643 reqRsnIe);
2644
2645 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2646 (pAdapter),
2647 pAdapter->sessionId,
2648 &rspRsnLength,
2649 rspRsnIe);
2650 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 if (ft_carrier_on)
2652 hdd_send_re_assoc_event(dev,
2653 pAdapter,
2654 pRoamInfo,
2655 reqRsnIe,
2656 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002657 else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002658 hdd_info("sending connect indication to nl80211:for bssid "
2659 MAC_ADDRESS_STR
2660 " result:%d and Status:%d",
2661 MAC_ADDR_ARRAY
2662 (pRoamInfo->bssid.bytes),
2663 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664
2665 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302666 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 pRoamInfo->
2668 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302669 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 reqRsnIe,
2671 reqRsnLength,
2672 rspRsnIe,
2673 rspRsnLength,
2674 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302675 GFP_KERNEL,
2676 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 }
2678 }
2679 }
2680 if (!hddDisconInProgress) {
2681 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 bss);
2684
2685 /*
2686 * Perform any WMM-related association
2687 * processing.
2688 */
2689 hdd_wmm_assoc(pAdapter, pRoamInfo,
2690 eCSR_BSS_TYPE_INFRASTRUCTURE);
2691
2692 /*
2693 * Start the Queue - Start tx queues before
2694 * hdd_roam_register_sta, since
2695 * hdd_roam_register_sta will flush any cached
2696 * data frames immediately.
2697 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002698 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 wlan_hdd_netif_queue_control(pAdapter,
2700 WLAN_WAKE_ALL_NETIF_QUEUE,
2701 WLAN_CONTROL_PATH);
2702
2703 /*
2704 * Register the Station with TL after associated
2705 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302706 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707 pRoamInfo,
2708 pHddStaCtx->
2709 conn_info.
2710 staId[0],
2711 NULL,
2712 pRoamInfo->
2713 pBssDesc);
2714 }
2715 } else {
2716 /*
2717 * wpa supplicant expecting WPA/RSN IE in connect result
2718 * in case of reassociation also need to indicate it to
2719 * supplicant.
2720 */
2721 csr_roam_get_wpa_rsn_req_ie(
2722 WLAN_HDD_GET_HAL_CTX(pAdapter),
2723 pAdapter->sessionId,
2724 &reqRsnLength, reqRsnIe);
2725
2726 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2727 reqRsnIe, reqRsnLength);
2728 /* Reassoc successfully */
2729 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302730 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 hdd_change_peer_state(pAdapter,
2732 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002733 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2735 pRoamInfo->roamSynchInProgress
2736#else
2737 false
2738#endif
2739 );
2740 hdd_conn_set_authenticated(pAdapter, false);
2741 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002742 hdd_info("staId: %d Changing TL state to AUTHENTICATED",
2743 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302744 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 hdd_change_peer_state(pAdapter,
2746 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002747 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2749 pRoamInfo->roamSynchInProgress
2750#else
2751 false
2752#endif
2753 );
2754 hdd_conn_set_authenticated(pAdapter, true);
2755 }
2756
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302757 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 /*
2759 * Perform any WMM-related association
2760 * processing
2761 */
2762 hdd_wmm_assoc(pAdapter, pRoamInfo,
2763 eCSR_BSS_TYPE_INFRASTRUCTURE);
2764 }
2765
2766 /* Start the tx queues */
2767#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2768 if (pRoamInfo->roamSynchInProgress)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002769 hdd_info("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002771 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002772 wlan_hdd_netif_queue_control(pAdapter,
2773 WLAN_WAKE_ALL_NETIF_QUEUE,
2774 WLAN_CONTROL_PATH);
2775 }
2776
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302777#ifdef FEATURE_WLAN_TDLS
2778 wlan_hdd_tdls_connection_callback(pAdapter);
2779#endif
2780
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302781 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002782 hdd_err("STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302783 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 }
2785#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302786 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 sizeof(pAdapter->hdd_stats.hddPmfStats));
2788#endif
2789 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302790 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 hdd_wext_state_t *pWextState =
2792 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2793 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302794 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2795 " result:%d and Status:%d",
2796 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2797 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302799 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2800 " result:%d and Status:%d",
2801 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2802 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302803
2804 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2805 (pRoamInfo &&
2806 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2807 pRoamInfo->statusCode) ||
2808 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2809 pRoamInfo->statusCode) ||
2810 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2811 pRoamInfo->statusCode)))) {
2812 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2813 pRoamInfo ?
2814 pRoamInfo->bssid.bytes :
2815 pWextState->req_bssId.bytes);
2816 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2817 pRoamInfo ?
2818 pRoamInfo->bssid.bytes :
2819 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05302820 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05302821 }
2822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 /*
2824 * CR465478: Only send up a connection failure result when CSR
2825 * has completed operation - with a ASSOCIATION_FAILURE status.
2826 */
2827 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2828 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302829 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002830 hdd_err("send connect failure to nl80211: for bssid "
2831 MAC_ADDRESS_STR
2832 " result:%d and Status:%d reasoncode %d",
2833 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2834 roamResult, roamStatus,
2835 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302836 pHddStaCtx->conn_info.assoc_status_code =
2837 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08002838 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002839 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 MAC_ADDRESS_STR
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002841 " result:%d and Status:%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2843 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08002844 }
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05302845 hdd_err("Invoking packetdump deregistration API");
2846 wlan_deregister_txrx_packetdump();
2847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 /* inform association failure event to nl80211 */
2849 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
2850 roamResult) {
2851 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302852 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302854 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302856 GFP_KERNEL,
2857 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302859 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302861 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302863 GFP_KERNEL,
2864 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 } else {
Wu Gao77d28352016-11-23 17:50:56 +08002866 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302867 hdd_connect_result(dev,
2868 pRoamInfo->bssid.bytes,
2869 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08002870 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05302871 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302873 GFP_KERNEL,
2874 connect_timeout);
Wu Gao77d28352016-11-23 17:50:56 +08002875 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302876 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302878 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302880 GFP_KERNEL,
2881 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882 }
Abhishek Singhac2be142015-12-03 16:16:25 +05302883 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002884 } else if ((eCSR_ROAM_CANCELLED == roamStatus
2885 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05302886 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002887 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05302888 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002889 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302890 GFP_KERNEL,
2891 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 }
2893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 /*
2895 * Set connection state to eConnectionState_NotConnected only
2896 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002897 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002899 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
2900 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 hdd_conn_set_connection_state(pAdapter,
2903 eConnectionState_NotConnected);
2904 }
2905 hdd_wmm_init(pAdapter);
2906
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002907 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 wlan_hdd_netif_queue_control(pAdapter,
2909 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2910 WLAN_CONTROL_PATH);
2911 }
2912
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302913 if (QDF_STATUS_SUCCESS != cds_check_and_restart_sap(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 roamResult, pHddStaCtx))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302915 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916
Govind Singh24db1ed2015-12-18 15:54:59 +05302917 if (NULL != pRoamInfo && NULL != pRoamInfo->pBssDesc) {
2918 cds_force_sap_on_scc(roamResult,
2919 pRoamInfo->pBssDesc->channelId);
2920 } else {
2921 hdd_err("pRoamInfo profile is not set properly");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302922 return QDF_STATUS_E_FAILURE;
Govind Singh24db1ed2015-12-18 15:54:59 +05302923 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302925 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926}
2927
2928/**
2929 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
2930 * @pAdapter: pointer to adapter
2931 * @pRoamInfo: pointer to roam info
2932 * @roamId: roam id
2933 * @roamStatus: roam status
2934 * @roamResult: roam result
2935 *
2936 * Here we update the status of the Ibss when we receive information that we
2937 * have started/joined an ibss session.
2938 *
2939 * Return: none
2940 */
2941static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
2942 tCsrRoamInfo *pRoamInfo,
2943 uint32_t roamId,
2944 eRoamCmdStatus roamStatus,
2945 eCsrRoamResult roamResult)
2946{
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002947 hdd_info("%s: id %d, status %d, result %d",
2948 pAdapter->dev->name, roamId,
2949 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950
2951 switch (roamResult) {
2952 /* both IBSS Started and IBSS Join should come in here. */
2953 case eCSR_ROAM_RESULT_IBSS_STARTED:
2954 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
2955 case eCSR_ROAM_RESULT_IBSS_COALESCED:
2956 {
2957 hdd_context_t *pHddCtx =
2958 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302959 hdd_station_ctx_t *hdd_sta_ctx =
2960 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302961 struct qdf_mac_addr broadcastMacAddr =
2962 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963
2964 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302965 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 return;
2967 }
2968
2969 /* When IBSS Started comes from CSR, we need to move
2970 * connection state to IBSS Disconnected (meaning no peers
2971 * are in the IBSS).
2972 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 hdd_conn_set_connection_state(pAdapter,
2974 eConnectionState_IbssDisconnected);
2975 /* notify wmm */
2976 hdd_wmm_connect(pAdapter, pRoamInfo,
2977 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302978
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07002979 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302980
2981 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 pAdapter;
2983 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302984 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 &broadcastMacAddr,
2986 pRoamInfo->pBssDesc);
2987
2988 if (pRoamInfo->pBssDesc) {
2989 struct cfg80211_bss *bss;
2990#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
2991 struct ieee80211_channel *chan;
2992 int chan_no;
2993 unsigned int freq;
2994#endif
2995 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002996 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
2997 pAdapter->dev->name,
2998 MAC_ADDR_ARRAY(
2999 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000
3001 /* we must first give cfg80211 the BSS information */
3002 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3003 pRoamInfo);
3004 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003005 hdd_err("%s: unable to create IBSS entry",
3006 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 return;
3008 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003009 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 wlan_hdd_netif_queue_control(pAdapter,
3011 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3012 WLAN_CONTROL_PATH);
3013
3014#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3015 chan_no = pRoamInfo->pBssDesc->channelId;
3016
3017 if (chan_no <= 14)
3018 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003019 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020 else
3021 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003022 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023
3024 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3025
3026 if (chan)
3027 cfg80211_ibss_joined(pAdapter->dev,
3028 bss->bssid, chan,
3029 GFP_KERNEL);
3030 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003031 hdd_err("%s: chanId: %d, can't find channel",
3032 pAdapter->dev->name,
3033 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034#else
3035 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3036 GFP_KERNEL);
3037#endif
3038 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 bss);
3041 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003042 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003043 cds_incr_active_session(pAdapter->device_mode,
Krunal Soni2c68f232015-10-26 20:52:51 -07003044 pAdapter->sessionId);
3045 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3046 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003047 cds_update_connection_info(pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003048 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 break;
3050 }
3051
3052 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3053 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003054 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 break;
3056 }
3057
3058 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003059 hdd_err("%s: unexpected result %d",
3060 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 break;
3062 }
3063
3064 return;
3065}
3066
3067/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003068 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3069 * @sta_ctx: pointer to hdd station context
3070 * @sta_id: station ID
3071 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 *
3073 * This information is passed to iwconfig later. The peer that joined
3074 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003075
3076 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003078bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3079 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003081 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003083 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3084 if (0 == sta_ctx->conn_info.staId[idx]) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003085 hdd_info("adding peer: %pM, sta_id: %d, at idx: %d",
3086 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003087 sta_ctx->conn_info.staId[idx] = sta_id;
3088 qdf_copy_macaddr(
3089 &sta_ctx->conn_info.peerMacAddress[idx],
3090 peer_mac_addr);
3091 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 }
3093 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003094 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095}
3096
3097/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003098 * hdd_delete_peer() - removes peer from hdd station context peer table
3099 * @sta_ctx: pointer to hdd station context
3100 * @sta_id: station ID
3101 *
3102 * Return: None
3103 */
3104void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3105{
3106 int i;
3107
3108 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3109 if (sta_id == sta_ctx->conn_info.staId[i]) {
3110 sta_ctx->conn_info.staId[i] = 0;
3111 return;
3112 }
3113 }
3114
3115 hdd_err(FL("sta_id %d is not present in peer table"), sta_id);
3116}
3117
3118/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3120 * @pAdapter: pointer to adapter
3121 * @staId: station id
3122 *
3123 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003124 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003125 * false otherwise.
3126 */
3127static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3128{
3129 bool fSuccess = false;
3130 int idx = 0;
3131 uint8_t valid_idx = 0;
3132 uint8_t del_idx = 0;
3133 uint8_t empty_slots = 0;
3134 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3135
Naveen Rawatc45d1622016-07-05 12:20:09 -07003136 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3138 pHddStaCtx->conn_info.staId[idx] = 0;
3139
Anurag Chouhanc5548422016-02-24 18:33:27 +05303140 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 peerMacAddress[idx]);
3142
3143 fSuccess = true;
3144
3145 /*
3146 * Note the deleted Index, if its 0 we need special
3147 * handling.
3148 */
3149 del_idx = idx;
3150
3151 empty_slots++;
3152 } else {
3153 if (pHddStaCtx->conn_info.staId[idx] != 0) {
3154 valid_idx = idx;
3155 } else {
3156 /* Found an empty slot */
3157 empty_slots++;
3158 }
3159 }
3160 }
3161
Naveen Rawatc45d1622016-07-05 12:20:09 -07003162 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 /* Last peer departed, set the IBSS state appropriately */
3164 pHddStaCtx->conn_info.connState =
3165 eConnectionState_IbssDisconnected;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003166 hdd_err("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 }
3168 /* Find next active staId, to have a valid sta trigger for TL. */
3169 if (fSuccess == true) {
3170 if (del_idx == 0) {
3171 if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
3172 pHddStaCtx->conn_info.staId[0] =
3173 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303174 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003175 peerMacAddress[0],
3176 &pHddStaCtx->conn_info.
3177 peerMacAddress[valid_idx]);
3178
3179 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303180 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 peerMacAddress[valid_idx]);
3182 }
3183 }
3184 }
3185 return fSuccess;
3186}
3187
3188/**
3189 * roam_ibss_connect_handler() - IBSS connection handler
3190 * @pAdapter: pointer to adapter
3191 * @pRoamInfo: pointer to roam info
3192 *
3193 * We update the status of the IBSS to connected in this function.
3194 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303195 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303197static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 tCsrRoamInfo *pRoamInfo)
3199{
3200 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 /*
3202 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3203 * a partner stations).
3204 */
3205 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3206
3207 /* Save the connection info from CSR... */
3208 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3209
3210 /* Send the bssid address to the wext. */
3211 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3212 /* add bss_id to cfg80211 data base */
3213 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3214 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003215 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303217 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 }
3219 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 bss);
3222
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303223 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224}
3225
3226/**
3227 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3228 * @pAdapter: pointer to adapter
3229 * @pRoamInfo: pointer to roam info
3230 * @roamId: roam id
3231 * @roamStatus: roam status
3232 * @roamResult: roam result
3233 *
3234 * This function indicates the Mic failure to the supplicant
3235 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303236 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303238static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3240 tCsrRoamInfo *pRoamInfo,
3241 uint32_t roamId,
3242 eRoamCmdStatus roamStatus,
3243 eCsrRoamResult roamResult)
3244{
3245 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3246
3247 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3248 TKIP_COUNTER_MEASURE_STOPED ==
3249 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3250 struct iw_michaelmicfailure msg;
3251 union iwreq_data wreq;
3252 memset(&msg, '\0', sizeof(msg));
3253 msg.src_addr.sa_family = ARPHRD_ETHER;
3254 memcpy(msg.src_addr.sa_data,
3255 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3256 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003257 hdd_info("MIC MAC " MAC_ADDRESS_STR,
3258 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259
3260 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3261 msg.flags = IW_MICFAILURE_GROUP;
3262 else
3263 msg.flags = IW_MICFAILURE_PAIRWISE;
3264 memset(&wreq, 0, sizeof(wreq));
3265 wreq.data.length = sizeof(msg);
3266 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3267 (char *)&msg);
3268 /* inform mic failure to nl80211 */
3269 cfg80211_michael_mic_failure(pAdapter->dev,
3270 pRoamInfo->u.pMICFailureInfo->
3271 taMacAddr,
3272 ((pRoamInfo->u.pMICFailureInfo->
3273 multicast ==
3274 eSIR_TRUE) ?
3275 NL80211_KEYTYPE_GROUP :
3276 NL80211_KEYTYPE_PAIRWISE),
3277 pRoamInfo->u.pMICFailureInfo->
3278 keyId,
3279 pRoamInfo->u.pMICFailureInfo->TSC,
3280 GFP_KERNEL);
3281
3282 }
3283
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303284 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285}
3286
3287/**
3288 * roam_roam_connect_status_update_handler() - IBSS connect status update
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 * The Ibss connection status is updated regularly here in this function.
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 -08003300roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3301 tCsrRoamInfo *pRoamInfo,
3302 uint32_t roamId,
3303 eRoamCmdStatus roamStatus,
3304 eCsrRoamResult roamResult)
3305{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303306 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303308
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 switch (roamResult) {
3310 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3311 {
3312 hdd_station_ctx_t *pHddStaCtx =
3313 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003314 struct station_info *stainfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303316 hdd_err("IBSS New Peer indication from SME "
3317 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3318 MAC_ADDRESS_STR " and stationID= %d",
3319 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3320 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3321 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003323 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3325 pRoamInfo->staId,
3326 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003327 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 break;
3329 }
3330
3331 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303334 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 pRoamInfo,
3336 pRoamInfo->staId,
3337 &pRoamInfo->peerMac,
3338 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303339 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003340 hdd_err("Cannot register STA with TL for IBSS. Failed with qdf_status = %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303341 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 }
3343 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003344 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3345 if (stainfo == NULL) {
3346 hdd_err("memory allocation for station_info failed");
3347 return QDF_STATUS_E_NOMEM;
3348 }
3349 stainfo->filled = 0;
3350 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351
3352 cfg80211_new_sta(pAdapter->dev,
3353 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003354 stainfo, GFP_KERNEL);
3355 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356
3357 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
3358 pHddStaCtx->ibss_enc_key.encType
3359 || eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
3360 pHddStaCtx->ibss_enc_key.encType
3361 || eCSR_ENCRYPT_TYPE_TKIP ==
3362 pHddStaCtx->ibss_enc_key.encType
3363 || eCSR_ENCRYPT_TYPE_AES ==
3364 pHddStaCtx->ibss_enc_key.encType) {
3365 pHddStaCtx->ibss_enc_key.keyDirection =
3366 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303367 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368 &pRoamInfo->peerMac);
3369
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003370 hdd_info("New peer joined set PTK encType=%d",
3371 pHddStaCtx->ibss_enc_key.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303373 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3375 (pAdapter),
3376 pAdapter->sessionId,
3377 &pHddStaCtx->ibss_enc_key,
3378 &roamId);
3379
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303380 if (QDF_STATUS_SUCCESS != qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003381 hdd_err("sme_roam_set_key failed, status=%d",
3382 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303383 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 }
3385 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003386 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 wlan_hdd_netif_queue_control(pAdapter,
3388 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3389 WLAN_CONTROL_PATH);
3390 break;
3391 }
3392
3393 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3394 {
3395
3396 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3397
3398 break;
3399 }
3400 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3401 {
3402 hdd_station_ctx_t *pHddStaCtx =
3403 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3404
3405 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003406 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303408 hdd_err("IBSS Peer Departed from SME "
3409 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3410 MAC_ADDRESS_STR " and stationID= %d",
3411 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3412 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3413 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414
3415 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3416
3417 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3418 pHddStaCtx->ibss_sta_generation++;
3419
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303420 qdf_status = hdd_remove_peer_object(pAdapter->hdd_vdev,
3421 pRoamInfo->peerMac.bytes);
3422 if (QDF_IS_STATUS_ERROR(qdf_status))
3423 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
3424 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 cfg80211_del_sta(pAdapter->dev,
3427 (const u8 *)&pRoamInfo->peerMac.bytes,
3428 GFP_KERNEL);
3429 break;
3430 }
3431 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3432 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003433 hdd_info("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003435 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 wlan_hdd_netif_queue_control(pAdapter,
3437 WLAN_NETIF_TX_DISABLE_N_CARRIER,
3438 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 hdd_conn_set_connection_state(pAdapter,
3440 eConnectionState_NotConnected);
3441
3442 /* Send the bssid address to the wext. */
3443 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3444 break;
3445 }
3446 default:
3447 break;
3448
3449 }
3450
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303451 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452}
3453
3454#ifdef FEATURE_WLAN_TDLS
3455/**
3456 * hdd_roam_register_tdlssta() - register new TDLS station
3457 * @pAdapter: pointer to adapter
3458 * @peerMac: pointer to peer MAC address
3459 * @staId: station identifier
3460 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303461 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 *
3463 * Construct the staDesc and register with TL the new STA.
3464 * This is called as part of ADD_STA in the TDLS setup.
3465 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303466 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303468QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303470 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303472 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003474 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003475 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3476 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477
3478 /*
3479 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3480 * be peer MAC, here we are working on direct Link
3481 */
3482 staDesc.sta_id = staId;
3483
3484 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303485 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486
Dhanashri Atre50141c52016-04-07 13:15:29 -07003487 /* Register the vdev transmit and receive functions */
3488 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3489 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003490 cdp_vdev_register(soc,
3491 cdp_get_vdev_from_vdev_id(soc, pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003492 pAdapter, &txrx_ops);
3493 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494
3495 /* Register the Station with TL... */
Leo Changfdb45c32016-10-28 11:09:23 -07003496 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303497 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003498 hdd_err("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303499 qdf_status, qdf_status);
3500 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 }
3502
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303503 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504}
3505
3506/**
3507 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3508 * @pAdapter: pointer to adapter
3509 * @staId: station identifier
3510 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303511 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513static QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 uint8_t staId)
3515{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303516 QDF_STATUS qdf_status;
Leo Changfdb45c32016-10-28 11:09:23 -07003517 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
3518 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303519 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003520 hdd_warn("cdp_peer_clear() failed for staID %d. Status=%d [0x%08X]",
3521 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303523 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524}
3525
3526/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003527 * hdd_tdls_connection_tracker_update() - update connection tracker state
3528 * @adapter: pointer to adapter
3529 * @roam_info: pointer to roam info
3530 * @hdd_tdls_ctx: tdls context
3531 *
3532 * Return: QDF_STATUS enumeration
3533 */
3534static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3535 tCsrRoamInfo *roam_info,
3536 tdlsCtx_t *hdd_tdls_ctx)
3537{
3538 hddTdlsPeer_t *curr_peer;
3539 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3540
3541 curr_peer = wlan_hdd_tdls_find_peer(adapter,
3542 roam_info->peerMac.bytes, true);
3543
3544 if (!curr_peer) {
3545 hdd_err("curr_peer is null");
3546 return QDF_STATUS_E_FAILURE;
3547 }
3548
3549 mutex_lock(&hdd_ctx->tdls_lock);
3550
3551 if (eTDLS_LINK_CONNECTED ==
3552 curr_peer->link_status) {
3553 hdd_err("Received CONNECTION_TRACKER_NOTIFICATION "
3554 MAC_ADDRESS_STR
3555 " staId: %d, reason: %d",
3556 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3557 roam_info->staId,
3558 roam_info->reasonCode);
3559
3560 if (roam_info->reasonCode ==
3561 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3562 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003563 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3564 roam_info->reasonCode ==
3565 eWMI_TDLS_SCAN_STARTED_EVENT)
3566 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003567 else if (roam_info->reasonCode ==
3568 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3569 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003570 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3571 roam_info->reasonCode ==
3572 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3573 hdd_ctx->enable_tdls_connection_tracker = true;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003574
3575 } else {
3576 hdd_err("TDLS not connected, ignore notification, reason: %d",
3577 roam_info->reasonCode);
3578 }
3579
3580 mutex_unlock(&hdd_ctx->tdls_lock);
3581
3582 return QDF_STATUS_SUCCESS;
3583}
3584
3585
3586
3587
3588/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3590 * @pAdapter: pointer to adapter
3591 * @pRoamInfo: pointer to roam info
3592 * @roamId: roam id
3593 * @roamStatus: roam status
3594 * @roamResult: roam result
3595 *
3596 * HDD interface between SME and TL to ensure TDLS client registration with
3597 * TL in case of new TDLS client is added and deregistration at the time
3598 * TDLS client is deleted.
3599 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303600 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303602static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3604 tCsrRoamInfo *pRoamInfo,
3605 uint32_t roamId,
3606 eRoamCmdStatus roamStatus,
3607 eCsrRoamResult roamResult)
3608{
3609 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3610 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
3611 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303612 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 uint8_t staIdx;
3614 hddTdlsPeer_t *curr_peer;
3615 uint32_t reason;
3616
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003617 hdd_info("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 roamResult ==
3619 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3620 ==
3621 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3622 roamResult ==
3623 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3624 : roamResult ==
3625 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3626 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3627 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3628 roamResult ==
3629 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3630 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3631 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3632 : roamResult ==
3633 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3634 : roamResult ==
3635 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3636 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3637 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3638
3639 if (!pHddTdlsCtx) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003640 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
3641 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 return status;
3643 }
3644
3645 switch (roamResult) {
3646 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3647 {
3648 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003649 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303651 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3652
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 } else {
3654 /*
3655 * Check if there is available index for this new TDLS
3656 * STA.
3657 */
3658 for (staIdx = 0;
3659 staIdx < pHddCtx->max_num_tdls_sta;
3660 staIdx++) {
3661 if (0 ==
3662 pHddCtx->tdlsConnInfo[staIdx].
3663 staId) {
3664 pHddCtx->tdlsConnInfo[staIdx].
3665 sessionId =
3666 pRoamInfo->sessionId;
3667 pHddCtx->tdlsConnInfo[staIdx].
3668 staId = pRoamInfo->staId;
3669
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003670 hdd_warn("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003672 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 staIdx,
3674 pHddCtx->
3675 tdlsConnInfo[staIdx].
3676 staId,
3677 MAC_ADDR_ARRAY
3678 (pRoamInfo->peerMac.bytes));
3679
Anurag Chouhanc5548422016-02-24 18:33:27 +05303680 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 tdlsConnInfo
3682 [staIdx].
3683 peerMac,
3684 &pRoamInfo->
3685 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303686 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 break;
3688 }
3689 }
3690 if (staIdx < pHddCtx->max_num_tdls_sta) {
3691 if (-1 ==
3692 wlan_hdd_tdls_set_sta_id(pAdapter,
3693 pRoamInfo->
3694 peerMac.bytes,
3695 pRoamInfo->
3696 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003697 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303698 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 }
3700
3701 (WLAN_HDD_GET_CTX(pAdapter))->
3702 sta_to_adapter[pRoamInfo->staId] =
3703 pAdapter;
3704 /*
3705 * store the ucast signature,
3706 * if required for further reference.
3707 */
3708
3709 wlan_hdd_tdls_set_signature(pAdapter,
3710 pRoamInfo->
3711 peerMac.bytes,
3712 pRoamInfo->
3713 ucastSig);
3714 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303715 status = QDF_STATUS_E_FAILURE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003716 hdd_err("no available slot in conn_info. staId %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 pRoamInfo->staId);
3718 }
3719 pAdapter->tdlsAddStaStatus = status;
3720 }
3721 complete(&pAdapter->tdls_add_station_comp);
3722 break;
3723 }
3724 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3725 {
3726 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003727 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 pRoamInfo->statusCode);
3729 }
3730 /* store the ucast signature which will be used later when
3731 * registering to TL
3732 */
3733 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3734 complete(&pAdapter->tdls_add_station_comp);
3735 break;
3736 }
3737 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3738 {
3739 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003740 hdd_err("Link Establish Request failed. status(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741 pRoamInfo->statusCode);
3742 }
3743 complete(&pAdapter->tdls_link_establish_req_comp);
3744 break;
3745 }
3746 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3747 {
3748 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3749 staIdx++) {
3750 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3751 pRoamInfo->sessionId)
3752 && pRoamInfo->staId ==
3753 pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003754 hdd_warn("HDD: del STA IDX = %x",
3755 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003756
3757 curr_peer =
3758 wlan_hdd_tdls_find_peer(pAdapter,
3759 pRoamInfo->
3760 peerMac.bytes,
3761 true);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303762 if (NULL != curr_peer) {
3763 hdd_info("Current status for peer " MAC_ADDRESS_STR " is %d",
3764 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3765 curr_peer->link_status);
3766 if (TDLS_IS_CONNECTED(curr_peer)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767 hdd_roam_deregister_tdlssta
3768 (pAdapter,
3769 pRoamInfo->staId);
3770 wlan_hdd_tdls_decrement_peer_count
3771 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303772 } else if (eTDLS_LINK_CONNECTING ==
3773 curr_peer->link_status) {
3774 hdd_roam_deregister_tdlssta
3775 (pAdapter,
3776 pRoamInfo->staId);
3777 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 }
3779 wlan_hdd_tdls_reset_peer(pAdapter,
3780 pRoamInfo->
3781 peerMac.bytes);
3782
3783 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3784 pHddCtx->tdlsConnInfo[staIdx].
3785 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303786 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787 tdlsConnInfo[staIdx].
3788 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303789 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303790 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 break;
3792 }
3793 }
3794 complete(&pAdapter->tdls_del_station_comp);
3795 }
3796 break;
3797 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3798 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003799 hdd_err("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 pRoamInfo->reasonCode);
3801
3802 curr_peer =
3803 wlan_hdd_tdls_find_peer(pAdapter,
3804 pRoamInfo->peerMac.bytes, true);
3805 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
3806 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303807 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3808 curr_peer->peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303809 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 break;
3811 }
3812 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3813 {
3814 /* 0 staIdx is assigned to AP we dont want to touch that */
3815 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3816 staIdx++) {
3817 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3818 pRoamInfo->sessionId)
3819 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003820 hdd_warn("hdd_tdlsStatusUpdate: staIdx %d "
3821 MAC_ADDRESS_STR,
3822 pHddCtx->tdlsConnInfo[staIdx].
3823 staId,
3824 MAC_ADDR_ARRAY(pHddCtx->
3825 tdlsConnInfo
3826 [staIdx].
3827 peerMac.
3828 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829 wlan_hdd_tdls_reset_peer(pAdapter,
3830 pHddCtx->
3831 tdlsConnInfo
3832 [staIdx].
3833 peerMac.bytes);
3834 hdd_roam_deregister_tdlssta(pAdapter,
3835 pHddCtx->
3836 tdlsConnInfo
3837 [staIdx].
3838 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303839 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 sizeof
3841 (smeTdlsPeerStateParams));
3842 smeTdlsPeerStateParams.vdevId =
3843 pHddCtx->tdlsConnInfo[staIdx].
3844 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303845 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846 peerMacAddr,
3847 &pHddCtx->
3848 tdlsConnInfo[staIdx].
3849 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303850 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 smeTdlsPeerStateParams.peerState =
3852 eSME_TDLS_PEER_STATE_TEARDOWN;
3853
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003854 hdd_info("calling sme_update_tdls_peer_state for staIdx %d "
3855 MAC_ADDRESS_STR,
3856 pHddCtx->tdlsConnInfo[staIdx].
3857 staId,
3858 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 tdlsConnInfo
3860 [staIdx].
3861 peerMac.
3862 bytes));
3863 status =
3864 sme_update_tdls_peer_state(
3865 pHddCtx->hHal,
3866 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303867 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003868 hdd_err("sme_update_tdls_peer_state failed for "
3869 MAC_ADDRESS_STR,
3870 MAC_ADDR_ARRAY
3871 (pHddCtx->
3872 tdlsConnInfo[staIdx].
3873 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 }
3875 wlan_hdd_tdls_decrement_peer_count
3876 (pAdapter);
3877
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303878 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879 tdlsConnInfo[staIdx].
3880 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303881 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3883 pHddCtx->tdlsConnInfo[staIdx].
3884 sessionId = 255;
3885
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303886 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 }
3888 }
3889 break;
3890 }
3891 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
3892 {
3893 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07003894 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
3895 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303896 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 break;
3898 }
3899
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07003900 if (pHddCtx->tdls_nss_switch_in_progress) {
3901 hdd_err("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
3902 status = QDF_STATUS_SUCCESS;
3903 break;
3904 }
3905
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906 curr_peer =
3907 wlan_hdd_tdls_get_peer(pAdapter,
Kabilan Kannan36090ce2016-05-03 19:28:44 -07003908 pRoamInfo->peerMac.bytes,
3909 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303911 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303912 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 } else {
3914 if (eTDLS_LINK_CONNECTED ==
3915 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003916 hdd_err("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 } else {
3918 /*
3919 * If external control is enabled then initiate
3920 * TDLS only if forced peer is set otherwise
3921 * ignore should Discover trigger from fw.
3922 */
3923 if (pHddCtx->config->
3924 fTDLSExternalControl
3925 && (false ==
3926 curr_peer->isForcedPeer)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003927 hdd_info("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303928 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 break;
3930 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003931 hdd_info("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003932 pHddCtx->config->
3933 fTDLSExternalControl,
3934 curr_peer->isForcedPeer,
3935 pRoamInfo->reasonCode);
3936 }
Nitesh Shah983e8f52016-11-25 12:36:29 +05303937 pHddTdlsCtx->curr_candidate = curr_peer;
3938 wlan_hdd_tdls_implicit_send_discovery_request(
3939 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303941 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942 }
3943 break;
3944 }
3945
3946 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
3947 {
3948 curr_peer =
3949 wlan_hdd_tdls_find_peer(pAdapter,
3950 pRoamInfo->peerMac.bytes, true);
3951 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303952 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303953 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954 } else {
3955 if (eTDLS_LINK_CONNECTED ==
3956 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003957 hdd_err("Received SHOULD_TEARDOWN for peer "
3958 MAC_ADDRESS_STR
3959 " staId: %d, reason: %d",
3960 MAC_ADDR_ARRAY(pRoamInfo->
3961 peerMac.bytes),
3962 pRoamInfo->staId,
3963 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964
3965 if (pRoamInfo->reasonCode ==
3966 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
3967 pRoamInfo->reasonCode ==
3968 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
3969 pRoamInfo->reasonCode ==
3970 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
3971 pRoamInfo->reasonCode ==
3972 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
3973 reason =
3974 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
3975 } else
3976 reason =
3977 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
3978
3979 wlan_hdd_tdls_indicate_teardown
3980 (pHddTdlsCtx->pAdapter, curr_peer,
3981 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303982 hdd_send_wlan_tdls_teardown_event(
3983 eTDLS_TEARDOWN_BSS_DISCONNECT,
3984 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003986 hdd_err("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
3987 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003988 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303989 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 }
3991 break;
3992 }
3993
3994 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
3995 {
3996 curr_peer =
3997 wlan_hdd_tdls_find_peer(pAdapter,
3998 pRoamInfo->peerMac.bytes, true);
3999 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05304000 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304001 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 } else {
4003 if (eTDLS_LINK_CONNECTED ==
4004 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004005 hdd_err("Received SHOULD_PEER_DISCONNECTED for peer "
4006 MAC_ADDRESS_STR
4007 " staId: %d, reason: %d",
4008 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4009 pRoamInfo->staId,
4010 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004011
4012 if (pRoamInfo->reasonCode ==
4013 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4014 pRoamInfo->reasonCode ==
4015 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4016 pRoamInfo->reasonCode ==
4017 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4018 pRoamInfo->reasonCode ==
4019 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4020 reason =
4021 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4022 } else
4023 reason =
4024 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4025
4026 wlan_hdd_tdls_indicate_teardown
4027 (pHddTdlsCtx->pAdapter, curr_peer,
4028 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304029 hdd_send_wlan_tdls_teardown_event(
4030 eTDLS_TEARDOWN_BSS_DISCONNECT,
4031 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004033 hdd_err("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
4034 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304036 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 }
4038 break;
4039 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004040
4041 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
4042 status = hdd_tdls_connection_tracker_update(pAdapter,
4043 pRoamInfo,
4044 pHddTdlsCtx);
4045 break;
4046
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 default:
4048 {
4049 break;
4050 }
4051 }
4052
4053 return status;
4054}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004055#else
4056
4057static inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
4058 uint8_t staId)
4059{
4060 return QDF_STATUS_SUCCESS;
4061}
4062
4063static inline QDF_STATUS
4064hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4065 tCsrRoamInfo *pRoamInfo,
4066 uint32_t roamId,
4067 eRoamCmdStatus roamStatus,
4068 eCsrRoamResult roamResult)
4069{
4070 return QDF_STATUS_SUCCESS;
4071}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072#endif
4073
4074#ifdef WLAN_FEATURE_11W
4075/**
4076 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4077 * @pAdapter: pointer to the adapter
4078 * @nFrameLength: Length of the unprotected frame being passed
4079 * @pbFrames: Pointer to the frame buffer
4080 * @frameType: 802.11 frame type
4081 *
4082 * This function forwards the unprotected management frame to the supplicant.
4083 *
4084 * Return: nothing
4085 */
4086static void
4087hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4088 uint8_t *pbFrames, uint8_t frameType)
4089{
4090 uint8_t type = 0;
4091 uint8_t subType = 0;
4092
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004093 hdd_info("Frame Type = %d Frame Length = %d",
4094 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095
4096 /* Sanity Checks */
4097 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004098 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 return;
4100 }
4101
4102 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004103 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 return;
4105 }
4106
4107 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004108 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 return;
4110 }
4111
4112 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004113 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 return;
4115 }
4116
4117 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004118 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 return;
4120 }
4121
4122 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4123 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4124
4125 /* Get pAdapter from Destination mac address of the frame */
4126 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4127#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4128 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4129 nFrameLength);
4130#else
4131 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4132 nFrameLength);
4133#endif
4134 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4135 } else if (type == SIR_MAC_MGMT_FRAME &&
4136 subType == SIR_MAC_MGMT_DEAUTH) {
4137#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4138 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4139 nFrameLength);
4140#else
4141 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4142 nFrameLength);
4143#endif
4144 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4145 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004146 hdd_err("Frame type %d and subtype %d are not valid",
4147 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 return;
4149 }
4150}
4151#endif
4152
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004153#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154/**
4155 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4156 * @pAdapter: pointer to adapter
4157 * @tid: traffic identifier
4158 * @state: state
4159 * @measInterval: measurement interval
4160 *
4161 * This function sends traffic stream metrics IE information to
4162 * the supplicant via wireless event.
4163 *
4164 * Return: none
4165 */
4166static void
4167hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4168 uint8_t state, uint16_t measInterval)
4169{
4170 union iwreq_data wrqu;
4171 char buf[IW_CUSTOM_MAX + 1];
4172 int nBytes = 0;
4173
4174 if (NULL == pAdapter)
4175 return;
4176
4177 /* create the event */
4178 memset(&wrqu, '\0', sizeof(wrqu));
4179 memset(buf, '\0', sizeof(buf));
4180
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004181 hdd_info("TSM Ind tid(%d) state(%d) MeasInt(%d)",
4182 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183
4184 nBytes =
4185 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4186 measInterval);
4187
4188 wrqu.data.pointer = buf;
4189 wrqu.data.length = nBytes;
4190 /* send the event */
4191 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4192}
4193
4194/**
4195 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4196 * @pAdapter: pointer to adapter
4197 * @pRoamInfo: pointer to roam info
4198 *
4199 * This function sends cckm preauth indication to the supplicant
4200 * via wireless custom event.
4201 *
4202 * Return: none
4203 */
4204static void
4205hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4206{
4207 union iwreq_data wrqu;
4208 char buf[IW_CUSTOM_MAX + 1];
4209 char *pos = buf;
4210 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4211
4212 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4213 return;
4214
4215 /* create the event */
4216 memset(&wrqu, '\0', sizeof(wrqu));
4217 memset(buf, '\0', sizeof(buf));
4218
4219 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004220 hdd_info("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
4221 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4222 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223
4224 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4225 pos += nBytes;
4226 freeBytes -= nBytes;
4227
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304228 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304229 pos += QDF_MAC_ADDR_SIZE;
4230 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231
4232 nBytes = snprintf(pos, freeBytes, " %u:%u",
4233 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4234 freeBytes -= nBytes;
4235
4236 wrqu.data.pointer = buf;
4237 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4238
4239 /* send the event */
4240 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4241}
4242
4243/**
4244 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4245 * @pAdapter: pointer to adapter
4246 * @pRoamInfo: pointer to roam info
4247 *
4248 * Return: none
4249 */
4250static void
4251hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4252 tCsrRoamInfo *pRoamInfo)
4253{
4254 union iwreq_data wrqu;
4255 char buf[IW_CUSTOM_MAX + 1];
4256 int nBytes = 0;
4257
4258 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4259 return;
4260
4261 /* create the event */
4262 memset(&wrqu, '\0', sizeof(wrqu));
4263 memset(buf, '\0', sizeof(buf));
4264
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004265 hdd_info("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266
4267 nBytes =
4268 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4269 pRoamInfo->tsmRoamDelay);
4270
4271 wrqu.data.pointer = buf;
4272 wrqu.data.length = nBytes;
4273
4274 /* send the event */
4275 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4276}
4277
4278/**
4279 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4280 * @pAdapter: pointer to adapter
4281 * @measurementToken: measurement token
4282 * @flag: flag
4283 * @numBss: number of bss
4284 *
4285 * If the measurement is none and no scan results found,
4286 * indicate the supplicant about measurement done.
4287 *
4288 * Return: none
4289 */
4290void
4291hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4292 const uint16_t measurementToken,
4293 const bool flag, const uint8_t numBss)
4294{
4295 union iwreq_data wrqu;
4296 char buf[IW_CUSTOM_MAX];
4297 char *pos = buf;
4298 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4299
4300 memset(&wrqu, '\0', sizeof(wrqu));
4301 memset(buf, '\0', sizeof(buf));
4302
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004303 hdd_info("CCXBCNREP=%d %d %d", measurementToken,
4304 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305
4306 nBytes =
4307 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4308 flag, numBss);
4309
4310 wrqu.data.pointer = buf;
4311 wrqu.data.length = nBytes;
4312 /* send the event */
4313 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4314}
4315
4316/**
4317 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4318 * @pAdapter: pointer to adapter
4319 * @pRoamInfo: pointer to roam info
4320 *
4321 * If the measurement is none and no scan results found,
4322 * indicate the supplicant about measurement done.
4323 *
4324 * Return: none
4325 */
4326static void
4327hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4328 const tCsrRoamInfo *pRoamInfo)
4329{
4330 union iwreq_data wrqu;
4331 char buf[IW_CUSTOM_MAX];
4332 char *pos = buf;
4333 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4334 uint8_t i = 0, len = 0;
4335 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4336 uint8_t lastSent = 0, sendBss = 0;
4337 int bcnRepFieldSize =
4338 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4339 bcnReportFields);
4340 uint8_t ieLenByte = 1;
4341 /*
4342 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4343 */
4344#define ESEBCNREPHEADER_LEN (18)
4345
4346 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4347 return;
4348
4349 /*
4350 * Custom event can pass maximum of 256 bytes of data,
4351 * based on the IE len we need to identify how many BSS info can
4352 * be filled in to custom event data.
4353 */
4354 /*
4355 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4356 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4357 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4358 */
4359
4360 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4361 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004362 hdd_info("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004364 * indicate the supplicant about measurement done
4365 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 hdd_indicate_ese_bcn_report_no_results(
4367 pAdapter,
4368 pRoamInfo->pEseBcnReportRsp->
4369 measurementToken,
4370 pRoamInfo->pEseBcnReportRsp->flag,
4371 pRoamInfo->pEseBcnReportRsp->numBss);
4372 } else {
4373 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4374 memset(&wrqu, '\0', sizeof(wrqu));
4375 memset(buf, '\0', sizeof(buf));
4376 tot_bcn_ieLen = 0;
4377 sendBss = 0;
4378 pos = buf;
4379 freeBytes = IW_CUSTOM_MAX;
4380
4381 for (i = lastSent;
4382 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4383 len =
4384 bcnRepFieldSize + ieLenByte +
4385 pRoamInfo->pEseBcnReportRsp->
4386 bcnRepBssInfo[i].ieLen;
4387 if ((len + tot_bcn_ieLen) >
4388 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4389 break;
4390 }
4391 tot_bcn_ieLen += len;
4392 sendBss++;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004393 hdd_info("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
4394 i, bcnRepFieldSize, 1,
4395 pRoamInfo->pEseBcnReportRsp->
4396 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 }
4398
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004399 hdd_info("Sending %d BSS Info", sendBss);
4400 hdd_info("CCXBCNREP=%d %d %d %d",
4401 pRoamInfo->pEseBcnReportRsp->measurementToken,
4402 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4403 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404
4405 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4406 pRoamInfo->pEseBcnReportRsp->
4407 measurementToken,
4408 pRoamInfo->pEseBcnReportRsp->flag,
4409 sendBss);
4410 pos += nBytes;
4411 freeBytes -= nBytes;
4412
4413 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304414 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 sizeof(tot_bcn_ieLen));
4416 pos += sizeof(tot_bcn_ieLen);
4417 freeBytes -= sizeof(tot_bcn_ieLen);
4418
4419 for (i = 0; i < sendBss; i++) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004420 hdd_info("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4422 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4423 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4424 pRoamInfo->pEseBcnReportRsp->
4425 bcnRepBssInfo[i +
4426 lastSent].bcnReportFields.
4427 ChanNum,
4428 pRoamInfo->pEseBcnReportRsp->
4429 bcnRepBssInfo[i +
4430 lastSent].bcnReportFields.
4431 Spare,
4432 pRoamInfo->pEseBcnReportRsp->
4433 bcnRepBssInfo[i +
4434 lastSent].bcnReportFields.
4435 MeasDuration,
4436 pRoamInfo->pEseBcnReportRsp->
4437 bcnRepBssInfo[i +
4438 lastSent].bcnReportFields.
4439 PhyType,
4440 pRoamInfo->pEseBcnReportRsp->
4441 bcnRepBssInfo[i +
4442 lastSent].bcnReportFields.
4443 RecvSigPower,
4444 pRoamInfo->pEseBcnReportRsp->
4445 bcnRepBssInfo[i +
4446 lastSent].bcnReportFields.
4447 ParentTsf,
4448 pRoamInfo->pEseBcnReportRsp->
4449 bcnRepBssInfo[i +
4450 lastSent].bcnReportFields.
4451 TargetTsf[0],
4452 pRoamInfo->pEseBcnReportRsp->
4453 bcnRepBssInfo[i +
4454 lastSent].bcnReportFields.
4455 TargetTsf[1],
4456 pRoamInfo->pEseBcnReportRsp->
4457 bcnRepBssInfo[i +
4458 lastSent].bcnReportFields.
4459 BcnInterval,
4460 pRoamInfo->pEseBcnReportRsp->
4461 bcnRepBssInfo[i +
4462 lastSent].bcnReportFields.
4463 CapabilityInfo,
4464 pRoamInfo->pEseBcnReportRsp->
4465 bcnRepBssInfo[i +
4466 lastSent].bcnReportFields.
4467 Bssid[0],
4468 pRoamInfo->pEseBcnReportRsp->
4469 bcnRepBssInfo[i +
4470 lastSent].bcnReportFields.
4471 Bssid[1],
4472 pRoamInfo->pEseBcnReportRsp->
4473 bcnRepBssInfo[i +
4474 lastSent].bcnReportFields.
4475 Bssid[2],
4476 pRoamInfo->pEseBcnReportRsp->
4477 bcnRepBssInfo[i +
4478 lastSent].bcnReportFields.
4479 Bssid[3],
4480 pRoamInfo->pEseBcnReportRsp->
4481 bcnRepBssInfo[i +
4482 lastSent].bcnReportFields.
4483 Bssid[4],
4484 pRoamInfo->pEseBcnReportRsp->
4485 bcnRepBssInfo[i +
4486 lastSent].bcnReportFields.
4487 Bssid[5]);
4488
4489 /* bcn report fields are copied */
4490 len =
4491 sizeof(pRoamInfo->pEseBcnReportRsp->
4492 bcnRepBssInfo[i +
4493 lastSent].
4494 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304495 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 (char *)&pRoamInfo->
4497 pEseBcnReportRsp->bcnRepBssInfo[i +
4498 lastSent].
4499 bcnReportFields, len);
4500 pos += len;
4501 freeBytes -= len;
4502
4503 /* Add 1 byte of ie len */
4504 len =
4505 pRoamInfo->pEseBcnReportRsp->
4506 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304507 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 pos += sizeof(len);
4509 freeBytes -= sizeof(len);
4510
4511 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304512 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 (char *)pRoamInfo->
4514 pEseBcnReportRsp->bcnRepBssInfo[i +
4515 lastSent].
4516 pBuf, len);
4517 pos += len;
4518 freeBytes -= len;
4519 }
4520
4521 wrqu.data.pointer = buf;
4522 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4523
4524 /* send the event */
4525 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4526 buf);
4527 lastSent += sendBss;
4528 }
4529 }
4530}
4531
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004532#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533
4534/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304535 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4536 * @pHddStaCtx: Station Context
4537 *
4538 * API to check if the connection authentication type is 8021x_sha256.
4539 *
4540 * Return: bool
4541 */
4542#ifdef WLAN_FEATURE_11W
4543static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4544{
4545 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4546 pHddStaCtx->conn_info.authType;
4547}
4548#else
4549static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4550{
4551 return false;
4552}
4553#endif
4554
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304555/*
4556 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4557 * @adapter: Pointer to adapter context
4558 * @roam_info: Pointer to roam info
4559 *
4560 * Return: None
4561 */
4562static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4563 tCsrRoamInfo *roam_info)
4564{
4565 struct hdd_chan_change_params chan_change;
4566 struct cfg80211_bss *bss;
4567 struct net_device *dev = adapter->dev;
4568 struct wireless_dev *wdev = dev->ieee80211_ptr;
4569 struct wiphy *wiphy = wdev->wiphy;
4570 QDF_STATUS status;
4571
4572 hdd_info("channel switch for session:%d to channel:%d",
4573 adapter->sessionId, roam_info->chan_info.chan_id);
4574
4575 chan_change.chan = roam_info->chan_info.chan_id;
4576 chan_change.chan_params.ch_width =
4577 roam_info->chan_info.ch_width;
4578 chan_change.chan_params.sec_ch_offset =
4579 roam_info->chan_info.sec_ch_offset;
4580 chan_change.chan_params.center_freq_seg0 =
4581 roam_info->chan_info.band_center_freq1;
4582 chan_change.chan_params.center_freq_seg1 =
4583 roam_info->chan_info.band_center_freq2;
4584
4585 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4586 if (NULL == bss)
4587 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4588 else
4589 cfg80211_put_bss(wiphy, bss);
4590
4591 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4592 if (QDF_IS_STATUS_ERROR(status))
4593 hdd_err("channel change notification failed");
4594
4595 status = cds_set_hw_mode_on_channel_switch(adapter->sessionId);
4596 if (QDF_IS_STATUS_ERROR(status))
4597 hdd_info("set hw mode change not done");
4598}
4599
Komal Seelam98760ba2015-12-15 11:05:18 +05304600/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 * hdd_sme_roam_callback() - hdd sme roam callback
4602 * @pContext: pointer to adapter context
4603 * @pRoamInfo: pointer to roam info
4604 * @roamId: roam id
4605 * @roamStatus: roam status
4606 * @roamResult: roam result
4607 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304608 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304610QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4612 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4613{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304614 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4616 hdd_wext_state_t *pWextState = NULL;
4617 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304618 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 hdd_context_t *pHddCtx = NULL;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304620 struct cfg80211_bss *bss_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004622 hdd_info("CSR Callback: status= %d result= %d roamID=%d",
4623 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624
4625 /* Sanity check */
4626 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004627 hdd_alert("invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304628 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 }
4630
4631 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4632 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4633
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304634 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304635 pAdapter->sessionId, roamStatus));
4636
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 switch (roamStatus) {
4638 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304639 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4640 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004641 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 break;
4643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 /*
4645 * We did pre-auth,then we attempted a 11r or ese reassoc.
4646 * reassoc failed due to failure, timeout, reject from ap
4647 * in any case tell the OS, our carrier is off and mark
4648 * interface down.
4649 */
4650 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004651 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4652 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304653 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4655 roamStatus, roamResult);
4656 /*
4657 * Check if Mcast/Bcast Filters are set, if yes
4658 * clear the filters here.
4659 */
4660 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set ==
4661 true) {
4662 (WLAN_HDD_GET_CTX(pAdapter))->
4663 hdd_mcastbcast_filter_set = false;
4664 }
4665 pHddStaCtx->ft_carrier_on = false;
4666 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004667 hdd_info("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
4668 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 break;
4670
4671 case eCSR_ROAM_FT_START:
4672 /*
4673 * When we roam for ESE and 11r, we dont want the OS to be
4674 * informed that the link is down. So mark the link ready for
4675 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4676 * be received. Where in we will not mark the link down
4677 * Also we want to stop tx at this point when we will be
4678 * doing disassoc at this time. This saves 30-60 msec
4679 * after reassoc.
4680 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004681 hdd_info("Disabling queues");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004682 hdd_info("Roam Synch Ind: NAPI Serialize ON");
4683 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004684 wlan_hdd_netif_queue_control(pAdapter,
4685 WLAN_NETIF_TX_DISABLE,
4686 WLAN_CONTROL_PATH);
4687 status = hdd_roam_deregister_sta(pAdapter,
4688 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304689 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304690 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691 pHddStaCtx->ft_carrier_on = true;
4692 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004693 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4694 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004696 case eCSR_ROAM_NAPI_OFF:
4697 hdd_info("After Roam Synch Comp: NAPI Serialize OFF");
4698 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004699 hdd_set_roaming_in_progress(false);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004700 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004703 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 wlan_hdd_netif_queue_control(pAdapter,
4705 WLAN_NETIF_TX_DISABLE,
4706 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 wlan_hdd_netif_queue_control(pAdapter,
4709 WLAN_NETIF_CARRIER_OFF,
4710 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 break;
4713 case eCSR_ROAM_LOSTLINK:
4714 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004715 hdd_info("Roaming started due to connection lost");
4716 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 wlan_hdd_netif_queue_control(pAdapter,
4718 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4719 WLAN_CONTROL_PATH);
4720 break;
4721 }
4722 case eCSR_ROAM_DISASSOCIATED:
4723 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004724 hdd_info("****eCSR_ROAM_DISASSOCIATED****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304725 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4727 roamStatus, roamResult);
4728 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4729 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4730 if (pHddCtx->hdd_mcastbcast_filter_set == true) {
4731 hdd_conf_mcastbcast_filter(pHddCtx, false);
4732
4733 if (true ==
4734 pHddCtx->sus_res_mcastbcast_filter_valid) {
4735 pHddCtx->configuredMcastBcastFilter =
4736 pHddCtx->sus_res_mcastbcast_filter;
4737 pHddCtx->
4738 sus_res_mcastbcast_filter_valid =
4739 false;
4740 }
4741
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004742 hdd_info("offload: disassociation happening, restoring configuredMcastBcastFilter");
4743 hdd_info("McastBcastFilter = %d",
4744 pHddCtx->configuredMcastBcastFilter);
4745 hdd_info("offload: already called mcastbcast filter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746 (WLAN_HDD_GET_CTX(pAdapter))->
4747 hdd_mcastbcast_filter_set = false;
4748 }
4749 /* Call to clear any MC Addr List filter applied after
4750 * successful connection.
4751 */
4752 wlan_hdd_set_mc_addr_list(pAdapter, false);
4753 }
4754 break;
4755 case eCSR_ROAM_IBSS_LEAVE:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004756 hdd_info("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304757 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4759 roamStatus, roamResult);
4760 break;
4761 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004762 hdd_info("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 /*
4764 * To Do - address probable memory leak with WEP encryption upon
4765 * successful association.
4766 */
4767 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4768 /* Clear saved connection information in HDD */
4769 hdd_conn_remove_connect_info(
4770 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4771 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304772 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773 hdd_association_completion_handler(pAdapter, pRoamInfo,
4774 roamId, roamStatus,
4775 roamResult);
4776#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4777 if (pRoamInfo)
4778 pRoamInfo->roamSynchInProgress = false;
4779#endif
4780 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004781 case eCSR_ROAM_CANCELLED:
4782 hdd_info("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304784 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 pRoamInfo,
4786 roamId,
4787 roamStatus,
4788 roamResult);
4789 break;
4790 case eCSR_ROAM_IBSS_IND:
4791 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4792 roamStatus, roamResult);
4793 break;
4794
4795 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304796 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797 roam_roam_connect_status_update_handler(pAdapter,
4798 pRoamInfo,
4799 roamId,
4800 roamStatus,
4801 roamResult);
4802 break;
4803
4804 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304805 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806 hdd_roam_mic_error_indication_handler(pAdapter,
4807 pRoamInfo,
4808 roamId,
4809 roamStatus,
4810 roamResult);
4811 break;
4812
4813 case eCSR_ROAM_SET_KEY_COMPLETE:
4814 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304815 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004816 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4817 roamId, roamStatus,
4818 roamResult);
4819 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4820 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004821 hdd_info("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 pHddStaCtx->hdd_ReassocScenario,
4823 pAdapter->sessionId);
4824 }
4825 }
4826#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4827 if (pRoamInfo != NULL)
4828 pRoamInfo->roamSynchInProgress = false;
4829#endif
4830 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004831
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 case eCSR_ROAM_FT_RESPONSE:
4833 hdd_send_ft_event(pAdapter);
4834 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004835
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304837 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4838 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304840 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841 wlan_hdd_cfg80211_pmksa_candidate_notify(
4842 pAdapter, pRoamInfo, 1, false);
4843 }
4844 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845
4846#ifdef FEATURE_WLAN_LFR_METRICS
4847 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4848 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304849 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4851 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304852 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 }
4854 break;
4855 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4856 /*
4857 * This event will notify pre-auth completion in case of success
4858 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304859 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4861 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304862 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 }
4864 break;
4865 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4866 /*
4867 * This event will notify pre-auth completion incase of failure.
4868 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304869 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4871 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304872 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 }
4874 break;
4875 case eCSR_ROAM_HANDOVER_SUCCESS:
4876 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004877 * It will be only invoked on success
4878 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304879 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4881 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304882 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 }
4884 break;
4885#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886 case eCSR_ROAM_REMAIN_CHAN_READY:
4887 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4888 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889#ifdef FEATURE_WLAN_TDLS
4890 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304891 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4893 roamId,
4894 roamStatus,
4895 roamResult);
4896 break;
4897 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4898 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4899 pRoamInfo->reasonCode);
4900 break;
4901#endif
4902#ifdef WLAN_FEATURE_11W
4903 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4904 hdd_indicate_unprot_mgmt_frame(pAdapter,
4905 pRoamInfo->nFrameLength,
4906 pRoamInfo->pbFrames,
4907 pRoamInfo->frameType);
4908 break;
4909#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004910#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 case eCSR_ROAM_TSM_IE_IND:
4912 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
4913 pRoamInfo->tsmIe.state,
4914 pRoamInfo->tsmIe.msmt_interval);
4915 break;
4916
4917 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4918 {
4919 if (eCSR_AUTH_TYPE_CCKM_WPA ==
4920 pHddStaCtx->conn_info.authType
4921 || eCSR_AUTH_TYPE_CCKM_RSN ==
4922 pHddStaCtx->conn_info.authType) {
4923 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
4924 }
4925 break;
4926 }
4927
4928 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4929 {
4930 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
4931 break;
4932 }
4933
4934 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4935 {
4936 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
4937 break;
4938 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004939#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304940 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304941 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304942 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304943
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304944 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4945 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
4946 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
4947 pAdapter, pRoamInfo->pBssDesc);
4948 if (NULL == bss_status)
4949 hdd_info("UPDATE_SCAN_RESULT returned NULL");
4950 else
4951 cfg80211_put_bss(
4952#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4953 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4954#endif
4955 bss_status);
4956 }
4957 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004958 case eCSR_ROAM_NDP_STATUS_UPDATE:
4959 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
4960 roamResult);
4961 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004962 case eCSR_ROAM_START:
4963 hdd_info("Process ROAM_START from firmware");
4964 wlan_hdd_netif_queue_control(pAdapter,
4965 WLAN_NETIF_TX_DISABLE,
4966 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004967 hdd_napi_serialize(1);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004968 cds_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004969 hdd_set_roaming_in_progress(true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004970 cds_restart_opportunistic_timer(true);
4971 break;
4972 case eCSR_ROAM_ABORT:
4973 hdd_info("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004974 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004975 wlan_hdd_netif_queue_control(pAdapter,
4976 WLAN_WAKE_ALL_NETIF_QUEUE,
4977 WLAN_CONTROL_PATH);
4978 cds_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004979 hdd_set_roaming_in_progress(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004980 break;
4981
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982 default:
4983 break;
4984 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304985 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986}
4987
4988/**
4989 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4990 * @auth_suite: auth suite
4991 *
4992 * Return: eCsrAuthType enumeration
4993 */
4994eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4995{
4996 eCsrAuthType auth_type;
4997 /* is the auth type supported? */
4998 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4999 auth_type = eCSR_AUTH_TYPE_RSN;
5000 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5001 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005002 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003 /* Check for 11r FT Authentication with PSK */
5004 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5005 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5006 /* Check for 11R FT Authentication with 802.1X */
5007 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5008 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005009#ifdef FEATURE_WLAN_ESE
5010 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5011 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5012 } else
5013#endif /* FEATURE_WLAN_ESE */
5014#ifdef WLAN_FEATURE_11W
5015 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5016 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5017 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5018 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5019 } else
5020#endif
5021 {
5022 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5023 }
5024 return auth_type;
5025}
5026
5027/**
5028 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5029 * @auth_suite: auth suite
5030 *
5031 * Return: eCsrAuthType enumeration
5032 */
5033eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5034{
5035 eCsrAuthType auth_type;
5036 /* is the auth type supported? */
5037 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5038 auth_type = eCSR_AUTH_TYPE_WPA;
5039 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5040 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5041 } else
5042#ifdef FEATURE_WLAN_ESE
5043 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5044 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5045 } else
5046#endif /* FEATURE_WLAN_ESE */
5047 {
5048 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5049 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005050 hdd_info("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005051 return auth_type;
5052}
5053
5054/**
5055 * hdd_translate_rsn_to_csr_encryption_type() -
5056 * Translate RSN to CSR encryption type
5057 * @cipher_suite: cipher suite
5058 *
5059 * Return: eCsrEncryptionType enumeration
5060 */
5061eCsrEncryptionType
5062hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5063{
5064 eCsrEncryptionType cipher_type;
5065
5066 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5067 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5068 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5069 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5070 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5071 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5072 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5073 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5074 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5075 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5076 else
5077 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5078
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005079 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005080 return cipher_type;
5081}
5082
5083/**
5084 * hdd_translate_wpa_to_csr_encryption_type() -
5085 * Translate WPA to CSR encryption type
5086 * @cipher_suite: cipher suite
5087 *
5088 * Return: eCsrEncryptionType enumeration
5089 */
5090eCsrEncryptionType
5091hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5092{
5093 eCsrEncryptionType cipher_type;
5094
5095 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5096 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5097 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5098 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5099 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5100 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5101 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5102 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5103 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5104 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5105 else
5106 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5107
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005108 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 return cipher_type;
5110}
5111
5112/**
5113 * hdd_process_genie() - process gen ie
5114 * @pAdapter: pointer to adapter
5115 * @bssid: pointer to mac address
5116 * @pEncryptType: pointer to encryption type
5117 * @mcEncryptType: pointer to multicast encryption type
5118 * @pAuthType: pointer to auth type
5119 *
5120 * Return: 0 on success, error number otherwise
5121 */
5122static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5123 u8 *bssid,
5124 eCsrEncryptionType *pEncryptType,
5125 eCsrEncryptionType *mcEncryptType,
5126 eCsrAuthType *pAuthType,
5127#ifdef WLAN_FEATURE_11W
5128 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5129#endif
5130 uint16_t gen_ie_len, uint8_t *gen_ie)
5131{
5132 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305133 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 tDot11fIERSN dot11RSNIE;
5135 tDot11fIEWPA dot11WPAIE;
5136 uint32_t i;
5137 uint8_t *pRsnIe;
5138 uint16_t RSNIeLen;
5139 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5140 bool updatePMKCache = false;
5141
5142 /*
5143 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5144 * setting present flag to 0.
5145 */
5146 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5147 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5148
5149 /* Type check */
5150 if (gen_ie[0] == DOT11F_EID_RSN) {
5151 /* Validity checks */
5152 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5153 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005154 hdd_err("Invalid DOT11F RSN IE length :%d",
5155 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 return -EINVAL;
5157 }
5158 /* Skip past the EID byte and length byte */
5159 pRsnIe = gen_ie + 2;
5160 RSNIeLen = gen_ie_len - 2;
5161 /* Unpack the RSN IE */
5162 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
5163 pRsnIe, RSNIeLen, &dot11RSNIE);
5164 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005165 hdd_info("pairwise cipher suite count: %d",
5166 dot11RSNIE.pwise_cipher_suite_count);
5167 hdd_info("authentication suite count: %d",
5168 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169 /* dot11RSNIE.akm_suite_count */
5170 /* Just translate the FIRST one */
5171 *pAuthType =
5172 hdd_translate_rsn_to_csr_auth_type(
5173 dot11RSNIE.akm_suites[0]);
5174 /* dot11RSNIE.pwise_cipher_suite_count */
5175 *pEncryptType =
5176 hdd_translate_rsn_to_csr_encryption_type(
5177 dot11RSNIE.pwise_cipher_suites[0]);
5178 /* dot11RSNIE.gp_cipher_suite_count */
5179 *mcEncryptType =
5180 hdd_translate_rsn_to_csr_encryption_type(
5181 dot11RSNIE.gp_cipher_suite);
5182#ifdef WLAN_FEATURE_11W
5183 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5184 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5185#endif
5186 /* Set the PMKSA ID Cache for this interface */
5187 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5188 if (is_zero_ether_addr(bssid)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005189 hdd_err("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190 break;
5191 }
5192 updatePMKCache = true;
5193 /*
5194 * For right now, I assume setASSOCIATE() has passed
5195 * in the bssid.
5196 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305197 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305198 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305199 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5201 }
5202
5203 if (updatePMKCache) {
5204 /*
5205 * Calling csr_roam_set_pmkid_cache to configure the
5206 * PMKIDs into the cache.
5207 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005208 hdd_info("Calling sme_roam_set_pmkid_cache with cache entry %d.",
5209 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 /* Finally set the PMKSA ID Cache in CSR */
5211 result =
5212 sme_roam_set_pmkid_cache(halHandle,
5213 pAdapter->sessionId,
5214 PMKIDCache,
5215 dot11RSNIE.pmkid_count,
5216 false);
5217 }
5218 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5219 /* Validity checks */
5220 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5221 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005222 hdd_err("Invalid DOT11F WPA IE length :%d",
5223 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 return -EINVAL;
5225 }
5226 /* Skip past the EID and length byte - and four byte WiFi OUI */
5227 pRsnIe = gen_ie + 2 + 4;
5228 RSNIeLen = gen_ie_len - (2 + 4);
5229 /* Unpack the WPA IE */
5230 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
5231 pRsnIe, RSNIeLen, &dot11WPAIE);
5232 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005233 hdd_info("WPA unicast cipher suite count: %d",
5234 dot11WPAIE.unicast_cipher_count);
5235 hdd_info("WPA authentication suite count: %d",
5236 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237 /* dot11WPAIE.auth_suite_count */
5238 /* Just translate the FIRST one */
5239 *pAuthType =
5240 hdd_translate_wpa_to_csr_auth_type(
5241 dot11WPAIE.auth_suites[0]);
5242 /* dot11WPAIE.unicast_cipher_count */
5243 *pEncryptType =
5244 hdd_translate_wpa_to_csr_encryption_type(
5245 dot11WPAIE.unicast_ciphers[0]);
5246 /* dot11WPAIE.unicast_cipher_count */
5247 *mcEncryptType =
5248 hdd_translate_wpa_to_csr_encryption_type(
5249 dot11WPAIE.multicast_cipher);
5250 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005251 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 return -EINVAL;
5253 }
5254 return 0;
5255}
5256
5257/**
5258 * hdd_set_genie_to_csr() - set genie to csr
5259 * @pAdapter: pointer to adapter
5260 * @RSNAuthType: pointer to auth type
5261 *
5262 * Return: 0 on success, error number otherwise
5263 */
5264int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5265{
5266 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5267 uint32_t status = 0;
5268 eCsrEncryptionType RSNEncryptType;
5269 eCsrEncryptionType mcRSNEncryptType;
5270#ifdef WLAN_FEATURE_11W
5271 uint8_t RSNMfpRequired = 0;
5272 uint8_t RSNMfpCapable = 0;
5273#endif
5274 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5275 /* MAC address of assoc peer */
5276 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305277 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 pWextState->roamProfile.BSSIDs.bssid,
5279 sizeof(bssid));
5280 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5281 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5282 /* continue */
5283 } else {
5284 return 0;
5285 }
5286 /* The actual processing may eventually be more extensive than this. */
5287 /* Right now, just consume any PMKIDs that are sent in by the app. */
5288 status = hdd_process_genie(pAdapter, bssid,
5289 &RSNEncryptType,
5290 &mcRSNEncryptType, RSNAuthType,
5291#ifdef WLAN_FEATURE_11W
5292 &RSNMfpRequired, &RSNMfpCapable,
5293#endif
5294 pWextState->WPARSNIE[1] + 2,
5295 pWextState->WPARSNIE);
5296 if (status == 0) {
5297 /*
5298 * Now copy over all the security attributes
5299 * you have parsed out.
5300 */
5301 pWextState->roamProfile.EncryptionType.numEntries = 1;
5302 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5303
5304 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5305 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5306 mcRSNEncryptType;
5307
Krunal Sonibe766b02016-03-10 13:00:44 -08005308 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5310 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5311 /*
5312 * For wpa none supplicant sends the WPA IE with unicast
5313 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5314 * multicast cipher as either AES/TKIP based on group
5315 * cipher configuration mentioned in the
5316 * wpa_supplicant.conf.
5317 */
5318
5319 /* Set the unicast cipher same as multicast cipher */
5320 pWextState->roamProfile.EncryptionType.encryptionType[0]
5321 = mcRSNEncryptType;
5322 }
5323#ifdef WLAN_FEATURE_11W
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005324 hdd_info("RSNMfpRequired = %d, RSNMfpCapable = %d",
5325 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5327 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5328#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005329 hdd_info("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
5330 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331 }
5332 return 0;
5333}
5334
5335/**
5336 * hdd_set_csr_auth_type() - set csr auth type
5337 * @pAdapter: pointer to adapter
5338 * @RSNAuthType: auth type
5339 *
5340 * Return: 0 on success, error number otherwise
5341 */
5342int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5343{
5344 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5345 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5346 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347
5348 pRoamProfile->AuthType.numEntries = 1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005349 hdd_info("pHddStaCtx->conn_info.authType = %d",
5350 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351
5352 switch (pHddStaCtx->conn_info.authType) {
5353 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5354#ifdef FEATURE_WLAN_ESE
5355 case eCSR_AUTH_TYPE_CCKM_WPA:
5356 case eCSR_AUTH_TYPE_CCKM_RSN:
5357#endif
5358 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5359
5360 pRoamProfile->AuthType.authType[0] =
5361 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5362 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5363
5364#ifdef FEATURE_WLAN_ESE
5365 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5366 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5367 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005368 hdd_info("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 pRoamProfile->AuthType.authType[0] =
5370 eCSR_AUTH_TYPE_CCKM_WPA;
5371 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005372 hdd_info("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005373 pRoamProfile->AuthType.authType[0] =
5374 eCSR_AUTH_TYPE_CCKM_WPA;
5375 } else
5376#endif
5377 if ((pWextState->
5378 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5379 == IW_AUTH_KEY_MGMT_802_1X) {
5380 pRoamProfile->AuthType.authType[0] =
5381 eCSR_AUTH_TYPE_WPA;
5382 } else
5383 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5384 == IW_AUTH_KEY_MGMT_PSK) {
5385 pRoamProfile->AuthType.authType[0] =
5386 eCSR_AUTH_TYPE_WPA_PSK;
5387 } else {
5388 pRoamProfile->AuthType.authType[0] =
5389 eCSR_AUTH_TYPE_WPA_NONE;
5390 }
5391 }
5392 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5393#ifdef FEATURE_WLAN_ESE
5394 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5395 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5396 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005397 hdd_info("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398 pRoamProfile->AuthType.authType[0] =
5399 eCSR_AUTH_TYPE_CCKM_RSN;
5400 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005401 hdd_info("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 pRoamProfile->AuthType.authType[0] =
5403 eCSR_AUTH_TYPE_CCKM_RSN;
5404 } else
5405#endif
5406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5408 ((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_FT_RSN;
5413 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5414 &&
5415 ((pWextState->
5416 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5417 == IW_AUTH_KEY_MGMT_PSK)) {
5418 pRoamProfile->AuthType.authType[0] =
5419 eCSR_AUTH_TYPE_FT_RSN_PSK;
5420 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421
5422#ifdef WLAN_FEATURE_11W
5423 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5424 pRoamProfile->AuthType.authType[0] =
5425 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5426 } else if (RSNAuthType ==
5427 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5428 pRoamProfile->AuthType.authType[0] =
5429 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5430 } else
5431#endif
5432
5433 if ((pWextState->
5434 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5435 == IW_AUTH_KEY_MGMT_802_1X) {
5436 pRoamProfile->AuthType.authType[0] =
5437 eCSR_AUTH_TYPE_RSN;
5438 } else
5439 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5440 == IW_AUTH_KEY_MGMT_PSK) {
5441 pRoamProfile->AuthType.authType[0] =
5442 eCSR_AUTH_TYPE_RSN_PSK;
5443 } else {
5444 pRoamProfile->AuthType.authType[0] =
5445 eCSR_AUTH_TYPE_UNKNOWN;
5446 }
5447 }
5448 break;
5449
5450 case eCSR_AUTH_TYPE_SHARED_KEY:
5451
5452 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5453 break;
5454 default:
5455
5456#ifdef FEATURE_WLAN_ESE
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005457 hdd_info("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458#endif /* FEATURE_WLAN_ESE */
5459 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5460 break;
5461 }
5462
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005463 hdd_info("Set roam Authtype to %d",
5464 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 return 0;
5467}
5468
5469/**
5470 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5471 * to the CSR roam profile.
5472 *
5473 * @dev: Pointer to the net device.
5474 * @info: Pointer to the iw_request_info.
5475 * @wrqu: Pointer to the iwreq_data.
5476 * @extra: Pointer to the data.
5477 *
5478 * Return: 0 for success, error number on failure
5479 */
5480static int __iw_set_essid(struct net_device *dev,
5481 struct iw_request_info *info,
5482 union iwreq_data *wrqu, char *extra)
5483{
5484 unsigned long rc;
5485 uint32_t status = 0;
5486 hdd_wext_state_t *pWextState;
5487 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5488 hdd_context_t *hdd_ctx;
5489 uint32_t roamId;
5490 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 eCsrAuthType RSNAuthType;
5492 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5493 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5494 int ret;
5495
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005496 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497
5498 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5499 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305500 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005501 return ret;
5502
Krunal Sonibe766b02016-03-10 13:00:44 -08005503 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005504 pAdapter->device_mode != QDF_IBSS_MODE &&
5505 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005506 hdd_warn("device mode %s(%d) is not allowed",
5507 hdd_device_mode_to_string(pAdapter->device_mode),
5508 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509 return -EINVAL;
5510 }
5511
5512 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5513
5514 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005515 hdd_info("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 return -EBUSY;
5517 }
5518 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5519 return -EINVAL;
5520
5521 pRoamProfile = &pWextState->roamProfile;
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005522 if (hdd_conn_is_connected(pHddStaCtx) ||
5523 (pAdapter->device_mode == QDF_IBSS_MODE)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305524 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005525
5526 /* Need to issue a disconnect to CSR. */
5527 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305528 qdf_status = sme_roam_disconnect(hHal, pAdapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5530
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305531 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005532 rc = wait_for_completion_timeout(&pAdapter->
5533 disconnect_comp_var,
5534 msecs_to_jiffies
5535 (WLAN_WAIT_TIME_DISCONNECT));
5536 if (!rc)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005537 hdd_err("Disconnect event timed out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538 }
5539 }
5540
5541 /*
5542 * when cfg80211 defined, wpa_supplicant wext driver uses
5543 * zero-length, null-string ssid for force disconnection.
5544 * after disconnection (if previously connected) and cleaning ssid,
5545 * driver MUST return success.
5546 */
5547 if (0 == wrqu->essid.length)
5548 return 0;
5549
5550 status = hdd_wmm_get_uapsd_mask(pAdapter,
5551 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305552 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 pWextState->roamProfile.uapsd_mask = 0;
5554
5555 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5556
5557 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5558 wrqu->essid.length;
5559
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305560 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305562 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563 ssId), extra, wrqu->essid.length);
5564 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5565 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5566
5567 /* set gen ie */
5568 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5569
5570 /* set auth */
5571 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5572 }
5573#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005574 hdd_notice("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 if (pAdapter->wapi_info.nWapiMode) {
5576 switch (pAdapter->wapi_info.wapiAuthMode) {
5577 case WAPI_AUTH_MODE_PSK:
5578 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005579 hdd_notice("WAPI AUTH TYPE: PSK: %d",
5580 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005581 pRoamProfile->AuthType.numEntries = 1;
5582 pRoamProfile->AuthType.authType[0] =
5583 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5584 break;
5585 }
5586 case WAPI_AUTH_MODE_CERT:
5587 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005588 hdd_notice("WAPI AUTH TYPE: CERT: %d",
5589 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005590 pRoamProfile->AuthType.numEntries = 1;
5591 pRoamProfile->AuthType.authType[0] =
5592 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5593 break;
5594 }
5595 } /* End of switch */
5596 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5597 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005598 hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005599 pRoamProfile->EncryptionType.numEntries = 1;
5600 pRoamProfile->EncryptionType.encryptionType[0] =
5601 eCSR_ENCRYPT_TYPE_WPI;
5602 pRoamProfile->mcEncryptionType.numEntries = 1;
5603 pRoamProfile->mcEncryptionType.encryptionType[0] =
5604 eCSR_ENCRYPT_TYPE_WPI;
5605 }
5606 }
5607#endif /* FEATURE_WLAN_WAPI */
5608 /* if previous genIE is not NULL, update AssocIE */
5609 if (0 != pWextState->genIE.length) {
5610 memset(&pWextState->assocAddIE, 0,
5611 sizeof(pWextState->assocAddIE));
5612 memcpy(pWextState->assocAddIE.addIEdata,
5613 pWextState->genIE.addIEdata, pWextState->genIE.length);
5614 pWextState->assocAddIE.length = pWextState->genIE.length;
5615 pWextState->roamProfile.pAddIEAssoc =
5616 pWextState->assocAddIE.addIEdata;
5617 pWextState->roamProfile.nAddIEAssocLength =
5618 pWextState->assocAddIE.length;
5619
5620 /* clear previous genIE after use it */
5621 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5622 }
5623
5624 /*
5625 * Assumes it is not WPS Association by default, except when
5626 * pAddIEAssoc has WPS IE.
5627 */
5628 pWextState->roamProfile.bWPSAssociation = false;
5629
5630 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5631 pWextState->roamProfile.
5632 nAddIEAssocLength))
5633 pWextState->roamProfile.bWPSAssociation = true;
5634
5635 /* Disable auto BMPS entry by PMC until DHCP is done */
5636 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5637 true);
5638
5639 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5640
5641 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005642 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005644 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5645 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005647
Agrawal Ashish6b015762016-05-05 11:22:18 +05305648 /*
5649 * Change conn_state to connecting before sme_roam_connect(),
5650 * because sme_roam_connect() has a direct path to call
5651 * hdd_sme_roam_callback(), which will change the conn_state
5652 * If direct path, conn_state will be accordingly changed to
5653 * NotConnected or Associated by either
5654 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5655 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5656 * Connecting state will remain until it is completed.
5657 *
5658 * If connection state is not changed,
5659 * connection state will remain in eConnectionState_NotConnected state.
5660 * In hdd_association_completion_handler, "hddDisconInProgress" is
5661 * set to true if conn state is eConnectionState_NotConnected.
5662 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5663 * informed of connect result indication which is an issue.
5664 */
5665 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305666 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305667 hdd_conn_set_connection_state(pAdapter,
5668 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 status = sme_roam_connect(hHal, pAdapter->sessionId,
5671 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305672 if ((QDF_STATUS_SUCCESS != status) &&
5673 (QDF_STA_MODE == pAdapter->device_mode ||
5674 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
5675 hdd_err("sme_roam_connect (session %d) failed with status %d. -> NotConnected",
5676 pAdapter->sessionId, status);
5677 /* change back to NotAssociated */
5678 hdd_conn_set_connection_state(pAdapter,
5679 eConnectionState_NotConnected);
5680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681 pRoamProfile->ChannelInfo.ChannelList = NULL;
5682 pRoamProfile->ChannelInfo.numOfChannels = 0;
5683
5684 EXIT();
5685 return status;
5686}
5687
5688/**
5689 * iw_set_essid() - set essid handler function
5690 * @dev: Pointer to the net device.
5691 * @info: Pointer to the iw_request_info.
5692 * @wrqu: Pointer to the iwreq_data.
5693 * @extra: Pointer to the data.
5694 *
5695 * Return: 0 for success, error number on failure
5696 */
5697int iw_set_essid(struct net_device *dev,
5698 struct iw_request_info *info,
5699 union iwreq_data *wrqu, char *extra)
5700{
5701 int ret;
5702
5703 cds_ssr_protect(__func__);
5704 ret = __iw_set_essid(dev, info, wrqu, extra);
5705 cds_ssr_unprotect(__func__);
5706
5707 return ret;
5708}
5709
5710/**
5711 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5712 * @dev: pointer to the net device
5713 * @info: pointer to the iw request info
5714 * @dwrq: pointer to iw_point
5715 * @extra: pointer to the data
5716 *
5717 * Return: 0 on success, error number otherwise
5718 */
5719static int __iw_get_essid(struct net_device *dev,
5720 struct iw_request_info *info,
5721 struct iw_point *dwrq, char *extra)
5722{
5723 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5724 hdd_context_t *hdd_ctx;
5725 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5726 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5727 int ret;
5728
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005729 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730
5731 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5732 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305733 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 return ret;
5735
5736 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5737 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5738 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5739 || pHddStaCtx->conn_info.connState ==
5740 eConnectionState_IbssDisconnected)
5741 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5742 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5743 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5744 dwrq->length);
5745 dwrq->flags = 1;
5746 } else {
5747 memset(extra, 0, dwrq->length);
5748 dwrq->length = 0;
5749 dwrq->flags = 0;
5750 }
5751 EXIT();
5752 return 0;
5753}
5754
5755/**
5756 * iw_get_essid() - get essid handler function
5757 * @dev: Pointer to the net device.
5758 * @info: Pointer to the iw_request_info.
5759 * @wrqu: Pointer to the iwreq_data.
5760 * @extra: Pointer to the data.
5761 *
5762 * Return: 0 for success, error number on failure
5763 */
5764int iw_get_essid(struct net_device *dev,
5765 struct iw_request_info *info,
5766 struct iw_point *wrqu, char *extra)
5767{
5768 int ret;
5769
5770 cds_ssr_protect(__func__);
5771 ret = __iw_get_essid(dev, info, wrqu, extra);
5772 cds_ssr_unprotect(__func__);
5773
5774 return ret;
5775}
5776
5777/**
5778 * __iw_set_auth() -
5779 * This function sets the auth type received from the wpa_supplicant
5780 * @dev: pointer to the net device
5781 * @info: pointer to the iw request info
5782 * @wrqu: pointer to iwreq_data
5783 * @extra: pointer to the data
5784 *
5785 * Return: 0 on success, error number otherwise
5786 */
5787static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5788 union iwreq_data *wrqu, char *extra)
5789{
5790 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5791 hdd_context_t *hdd_ctx;
5792 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5793 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5794 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5795 eCsrEncryptionType mcEncryptionType;
5796 eCsrEncryptionType ucEncryptionType;
5797 int ret;
5798
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005799 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800
5801 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5802 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305803 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 return ret;
5805
5806 switch (wrqu->param.flags & IW_AUTH_INDEX) {
5807 case IW_AUTH_WPA_VERSION:
5808 pWextState->wpaVersion = wrqu->param.value;
5809 break;
5810
5811 case IW_AUTH_CIPHER_PAIRWISE:
5812 {
5813 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5814 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5815 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5816 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5817 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5818 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5819 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5820 if ((IW_AUTH_KEY_MGMT_802_1X
5821 ==
5822 (pWextState->
5823 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5824 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5825 pHddStaCtx->conn_info.authType))
5826 /*Dynamic WEP key */
5827 ucEncryptionType =
5828 eCSR_ENCRYPT_TYPE_WEP40;
5829 else
5830 /*Static WEP key */
5831 ucEncryptionType =
5832 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5833 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5834 if ((IW_AUTH_KEY_MGMT_802_1X
5835 ==
5836 (pWextState->
5837 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5838 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5839 pHddStaCtx->conn_info.authType))
5840 /*Dynamic WEP key */
5841 ucEncryptionType =
5842 eCSR_ENCRYPT_TYPE_WEP104;
5843 else
5844 /*Static WEP key */
5845 ucEncryptionType =
5846 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5847 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005848 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
5849 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 return -EINVAL;
5851 }
5852
5853 pRoamProfile->EncryptionType.numEntries = 1;
5854 pRoamProfile->EncryptionType.encryptionType[0] =
5855 ucEncryptionType;
5856 }
5857 break;
5858 case IW_AUTH_CIPHER_GROUP:
5859 {
5860 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5861 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5862 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5863 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5864 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5865 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5866 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5867 if ((IW_AUTH_KEY_MGMT_802_1X
5868 ==
5869 (pWextState->
5870 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5871 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5872 pHddStaCtx->conn_info.authType))
5873 mcEncryptionType =
5874 eCSR_ENCRYPT_TYPE_WEP40;
5875 else
5876 mcEncryptionType =
5877 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5878 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5879 /* Dynamic WEP keys won't work with shared keys */
5880 if ((IW_AUTH_KEY_MGMT_802_1X
5881 ==
5882 (pWextState->
5883 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5884 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5885 pHddStaCtx->conn_info.authType)) {
5886 mcEncryptionType =
5887 eCSR_ENCRYPT_TYPE_WEP104;
5888 } else {
5889 mcEncryptionType =
5890 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5891 }
5892 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005893 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005894 wrqu->param.value);
5895 return -EINVAL;
5896 }
5897
5898 pRoamProfile->mcEncryptionType.numEntries = 1;
5899 pRoamProfile->mcEncryptionType.encryptionType[0] =
5900 mcEncryptionType;
5901 }
5902 break;
5903
5904 case IW_AUTH_80211_AUTH_ALG:
5905 {
Jeff Johnson5a062372017-01-12 09:51:25 -08005906 /* Save the auth algo here and set auth type to SME
5907 * Roam profile in the iw_set_ap_address
5908 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005909 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
5910 pHddStaCtx->conn_info.authType =
5911 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5912
5913 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5914 pHddStaCtx->conn_info.authType =
5915 eCSR_AUTH_TYPE_SHARED_KEY;
5916
5917 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
5918 /*Not supported */
5919 pHddStaCtx->conn_info.authType =
5920 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5921 pWextState->roamProfile.AuthType.authType[0] =
5922 pHddStaCtx->conn_info.authType;
5923 }
5924 break;
5925
5926 case IW_AUTH_KEY_MGMT:
5927 {
5928#ifdef FEATURE_WLAN_ESE
5929#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5930 /*Check for CCKM AKM type */
5931 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005932 hdd_info("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 /* Set the CCKM bit in authKeyMgmt */
5934 /*
5935 * Right now, this breaks all ref to authKeyMgmt because
5936 * our code doesn't realize it is a "bitfield"
5937 */
5938 pWextState->authKeyMgmt |=
5939 IW_AUTH_KEY_MGMT_CCKM;
5940 /* Set the key management to 802.1X */
5941 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
5942 pWextState->isESEConnection = true;
5943 /*
5944 * This is test code. I need to actually KNOW whether
5945 * this is an RSN Assoc or WPA.
5946 */
5947 pWextState->collectedAuthType =
5948 eCSR_AUTH_TYPE_CCKM_RSN;
5949 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5950 /* Save the key management */
5951 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5952 pWextState->collectedAuthType =
5953 eCSR_AUTH_TYPE_RSN;
5954 } else
5955 if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5956 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE;
5957 /* Save the key management anyway */
5958 pWextState->authKeyMgmt = wrqu->param.value;
5959 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
5960 /* Save the key management */
5961 pWextState->authKeyMgmt |=
5962 IW_AUTH_KEY_MGMT_802_1X;
5963 pWextState->collectedAuthType =
5964 eCSR_AUTH_TYPE_RSN;
5965 }
5966#else
5967 /* Save the key management */
5968 pWextState->authKeyMgmt = wrqu->param.value;
5969#endif /* FEATURE_WLAN_ESE */
5970 }
5971 break;
5972
5973 case IW_AUTH_TKIP_COUNTERMEASURES:
5974 {
5975 if (wrqu->param.value) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005976 hdd_info("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005977 wrqu->param.value);
5978 pWextState->mTKIPCounterMeasures =
5979 TKIP_COUNTER_MEASURE_STARTED;
5980 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005981 hdd_info("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 wrqu->param.value);
5983 pWextState->mTKIPCounterMeasures =
5984 TKIP_COUNTER_MEASURE_STOPED;
5985 }
5986 }
5987 break;
5988 case IW_AUTH_DROP_UNENCRYPTED:
5989 case IW_AUTH_WPA_ENABLED:
5990 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5991 case IW_AUTH_ROAMING_CONTROL:
5992 case IW_AUTH_PRIVACY_INVOKED:
5993
5994 default:
5995
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005996 hdd_warn("called with unsupported auth type %d",
5997 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005998 break;
5999 }
6000
6001 EXIT();
6002 return 0;
6003}
6004
6005/**
6006 * iw_set_auth() - set auth callback function
6007 * @dev: Pointer to the net device.
6008 * @info: Pointer to the iw_request_info.
6009 * @wrqu: Pointer to the iwreq_data.
6010 * @extra: Pointer to the data.
6011 *
6012 * Return: 0 for success, error number on failure.
6013 */
6014int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6015 union iwreq_data *wrqu, char *extra)
6016{
6017 int ret;
6018
6019 cds_ssr_protect(__func__);
6020 ret = __iw_set_auth(dev, info, wrqu, extra);
6021 cds_ssr_unprotect(__func__);
6022
6023 return ret;
6024}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025/**
6026 * __iw_get_auth() -
6027 * This function returns the auth type to the wpa_supplicant
6028 * @dev: pointer to the net device
6029 * @info: pointer to the iw request info
6030 * @wrqu: pointer to iwreq_data
6031 * @extra: pointer to the data
6032 *
6033 * Return: 0 on success, error number otherwise
6034 */
6035static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6036 union iwreq_data *wrqu, char *extra)
6037{
6038 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6039 hdd_context_t *hdd_ctx;
6040 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6041 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6042 int ret;
6043
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006044 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045
6046 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6047 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306048 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049 return ret;
6050
6051 switch (pRoamProfile->negotiatedAuthType) {
6052 case eCSR_AUTH_TYPE_WPA_NONE:
6053 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6054 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6055 break;
6056 case eCSR_AUTH_TYPE_WPA:
6057 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6058 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6059 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006061 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062 case eCSR_AUTH_TYPE_RSN:
6063 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6064 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6065 break;
6066 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6067 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6068 break;
6069 case eCSR_AUTH_TYPE_SHARED_KEY:
6070 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6071 break;
6072 case eCSR_AUTH_TYPE_UNKNOWN:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006073 hdd_info("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6075 break;
6076 case eCSR_AUTH_TYPE_AUTOSWITCH:
6077 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6078 break;
6079 case eCSR_AUTH_TYPE_WPA_PSK:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006080 hdd_info("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6082 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006083
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006084 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006085 case eCSR_AUTH_TYPE_RSN_PSK:
6086#ifdef WLAN_FEATURE_11W
6087 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6088 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6089#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006090 hdd_info("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6092 return -EIO;
6093 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006094 hdd_err("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006095 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6096 return -EIO;
6097 }
6098 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6099 switch (pRoamProfile->negotiatedUCEncryptionType) {
6100 case eCSR_ENCRYPT_TYPE_NONE:
6101 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6102 break;
6103 case eCSR_ENCRYPT_TYPE_WEP40:
6104 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6105 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6106 break;
6107 case eCSR_ENCRYPT_TYPE_TKIP:
6108 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6109 break;
6110 case eCSR_ENCRYPT_TYPE_WEP104:
6111 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6112 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6113 break;
6114 case eCSR_ENCRYPT_TYPE_AES:
6115 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6116 break;
6117 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006118 hdd_notice("called with unknown auth type %d",
6119 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 return -EIO;
6121 }
6122 }
6123
6124 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6125 switch (pRoamProfile->negotiatedMCEncryptionType) {
6126 case eCSR_ENCRYPT_TYPE_NONE:
6127 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6128 break;
6129 case eCSR_ENCRYPT_TYPE_WEP40:
6130 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6131 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6132 break;
6133 case eCSR_ENCRYPT_TYPE_TKIP:
6134 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6135 break;
6136 case eCSR_ENCRYPT_TYPE_WEP104:
6137 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6138 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6139 break;
6140 case eCSR_ENCRYPT_TYPE_AES:
6141 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6142 break;
6143 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006144 hdd_info("called with unknown auth type %d",
6145 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 return -EIO;
6147 }
6148 }
6149
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006150 hdd_info("called with auth type %d",
6151 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006152 EXIT();
6153 return 0;
6154}
6155
6156/**
6157 * iw_get_auth() - get auth callback function
6158 * @dev: Pointer to the net device.
6159 * @info: Pointer to the iw_request_info.
6160 * @wrqu: Pointer to the iwreq_data.
6161 * @extra: Pointer to the data.
6162 *
6163 * Return: 0 for success, error number on failure.
6164 */
6165int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6166 union iwreq_data *wrqu, char *extra)
6167{
6168 int ret;
6169
6170 cds_ssr_protect(__func__);
6171 ret = __iw_get_auth(dev, info, wrqu, extra);
6172 cds_ssr_unprotect(__func__);
6173
6174 return ret;
6175}
6176
6177/**
6178 * __iw_set_ap_address() - set ap address
6179 * @dev: pointer to the net device
6180 * @info: pointer to the iw request info
6181 * @wrqu: pointer to iwreq_data
6182 * @extra: pointer to the data
6183 *
6184 * This function updates the HDD global station context connection info
6185 * BSSID with the MAC address received from the wpa_supplicant.
6186 *
6187 * Return: 0 on success, error number otherwise
6188 */
6189static int __iw_set_ap_address(struct net_device *dev,
6190 struct iw_request_info *info,
6191 union iwreq_data *wrqu, char *extra)
6192{
6193
6194 hdd_adapter_t *adapter;
6195 hdd_context_t *hdd_ctx;
6196 hdd_station_ctx_t *pHddStaCtx =
6197 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6198 uint8_t *pMacAddress = NULL;
6199 int ret;
6200
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006201 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006202
6203 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6204
6205 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6206 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306207 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006208 return ret;
6209
6210 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006211 hdd_info(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306212 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306213 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006214 EXIT();
6215
6216 return 0;
6217}
6218
6219/**
6220 * iw_set_ap_address() - set ap addresses callback function
6221 * @dev: Pointer to the net device.
6222 * @info: Pointer to the iw_request_info.
6223 * @wrqu: Pointer to the iwreq_data.
6224 * @extra: Pointer to the data.
6225 *
6226 * Return: 0 for success, error number on failure.
6227 */
6228int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6229 union iwreq_data *wrqu, char *extra)
6230{
6231 int ret;
6232
6233 cds_ssr_protect(__func__);
6234 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6235 cds_ssr_unprotect(__func__);
6236
6237 return ret;
6238}
6239
6240/**
6241 * __iw_get_ap_address() - get ap address
6242 * @dev: pointer to the net device
6243 * @info: pointer to the iw request info
6244 * @wrqu: pointer to iwreq_data
6245 * @extra: pointer to the data
6246 *
6247 * This function returns currently associated BSSID.
6248 *
6249 * Return: 0 on success, error number otherwise
6250 */
6251static int __iw_get_ap_address(struct net_device *dev,
6252 struct iw_request_info *info,
6253 union iwreq_data *wrqu, char *extra)
6254{
6255 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6256 hdd_context_t *hdd_ctx;
6257 hdd_station_ctx_t *pHddStaCtx =
6258 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6259 int ret;
6260
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006261 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006262
6263 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6264 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306265 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006266 return ret;
6267
6268 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6269 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306270 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006271 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306272 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273 } else {
6274 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6275 }
6276 EXIT();
6277 return 0;
6278}
6279
6280/**
6281 * iw_get_ap_address() - get ap addresses callback function
6282 * @dev: Pointer to the net device.
6283 * @info: Pointer to the iw_request_info.
6284 * @wrqu: Pointer to the iwreq_data.
6285 * @extra: Pointer to the data.
6286 *
6287 * Return: 0 for success, error number on failure.
6288 */
6289int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6290 union iwreq_data *wrqu, char *extra)
6291{
6292 int ret;
6293
6294 cds_ssr_protect(__func__);
6295 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6296 cds_ssr_unprotect(__func__);
6297
6298 return ret;
6299}