blob: fe9b4a869e6d470f6419ef5253ab69893a2dab17 [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
Archana Ramachandran75c1ca72016-08-22 17:20:25 -070035/* denote that this file does not allow legacy hddLog */
36#define HDD_DISALLOW_LEGACY_HDDLOG 1
37
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038#include "wlan_hdd_includes.h"
39#include <ani_global.h>
40#include "dot11f.h"
41#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053042#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#include <linux/ieee80211.h>
44#include <linux/wireless.h>
45#include <linux/etherdevice.h>
46#include <net/cfg80211.h>
47#include "wlan_hdd_cfg80211.h"
48#include "csr_inside_api.h"
49#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051#include "sme_api.h"
52#include "wlan_hdd_hostapd.h"
53#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070054#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070055#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include <cds_sched.h>
57#include "cds_concurrency.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053058#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070060#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070061#include <cdp_txrx_cmn.h>
62#include <cdp_txrx_flow_ctrl_legacy.h>
63#include <cdp_txrx_peer_ops.h>
64#include <cdp_txrx_misc.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053065#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
67/* These are needed to recognize WPA and RSN suite types */
68#define HDD_WPA_OUI_SIZE 4
69#define HDD_RSN_OUI_SIZE 4
70uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
71uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
72uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
73uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
74uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
75uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
76
77#ifdef FEATURE_WLAN_ESE
78/* CCKM */
79uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
80/* CCKM */
81uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
82#endif /* FEATURE_WLAN_ESE */
83
84/* group cipher */
85uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
86
87/* WEP-40 or RSN */
88uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
89
90/* TKIP or RSN-PSK */
91uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
92
93/* Reserved */
94uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
95
96/* AES-CCMP */
97uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
98
99/* WEP-104 */
100uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
101
102#ifdef WLAN_FEATURE_11W
103/* RSN-PSK-SHA256 */
104uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
105
106/* RSN-8021X-SHA256 */
107uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
108#endif
109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110/* Offset where the EID-Len-IE, start. */
111#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
112#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113
114#define BEACON_FRAME_IES_OFFSET 12
115#define HDD_PEER_AUTHORIZE_WAIT 10
116
117/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700118 * beacon_filter_table - table of IEs used for beacon filtering
119 */
120static const int beacon_filter_table[] = {
121 SIR_MAC_DS_PARAM_SET_EID,
122 SIR_MAC_ERP_INFO_EID,
123 SIR_MAC_EDCA_PARAM_SET_EID,
124 SIR_MAC_QOS_CAPABILITY_EID,
125 SIR_MAC_HT_INFO_EID,
126 SIR_MAC_VHT_OPMODE_EID,
127 SIR_MAC_VHT_OPERATION_EID,
128};
129
130/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 * hdd_conn_set_authenticated() - set authentication state
132 * @pAdapter: pointer to the adapter
133 * @authState: authentication state
134 *
135 * This function updates the global HDD station context
136 * authentication state.
137 *
138 * Return: none
139 */
140static void
141hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
142{
143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
144 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
145
146 /* save the new connection state */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700147 hdd_notice("Authenticated state Changed from oldState:%d to State:%d",
148 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 pHddStaCtx->conn_info.uIsAuthenticated = authState;
150
151 /* Check is pending ROC request or not when auth state changed */
152 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
153}
154
155/**
156 * hdd_conn_set_connection_state() - set connection state
157 * @pAdapter: pointer to the adapter
158 * @connState: connection state
159 *
160 * This function updates the global HDD station context connection state.
161 *
162 * Return: none
163 */
164void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
165 eConnectionState connState)
166{
167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
168 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
169
170 /* save the new connection state */
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530171 hdd_info("%pS Changed connectionState Changed from oldState:%d to State:%d",
172 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
173 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 pHddStaCtx->conn_info.connState = connState;
175
176 /* Check is pending ROC request or not when connection state changed */
177 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
178}
179
180/**
181 * hdd_conn_get_connection_state() - get connection state
182 * @pAdapter: pointer to the adapter
183 * @pConnState: pointer to connection state
184 *
185 * This function updates the global HDD station context connection state.
186 *
187 * Return: true if (Infra Associated or IBSS Connected)
188 * and sets output parameter pConnState;
189 * false otherwise
190 */
191static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
192 eConnectionState *pConnState)
193{
194 bool fConnected = false;
195 eConnectionState connState;
196
197 /* get the connection state. */
198 connState = pHddStaCtx->conn_info.connState;
199
200 if (eConnectionState_Associated == connState ||
201 eConnectionState_IbssConnected == connState ||
202 eConnectionState_IbssDisconnected == connState) {
203 fConnected = true;
204 }
205
206 if (pConnState)
207 *pConnState = connState;
208
209 return fConnected;
210}
211
212/**
213 * hdd_is_connecting() - Function to check connection progress
214 * @hdd_sta_ctx: pointer to global HDD Station context
215 *
216 * Return: true if connecting, false otherwise
217 */
218bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
219{
220 return hdd_sta_ctx->conn_info.connState ==
221 eConnectionState_Connecting;
222}
223
224/**
225 * hdd_conn_is_connected() - Function to check connection status
226 * @pHddStaCtx: pointer to global HDD Station context
227 *
228 * Return: false if any errors encountered, true otherwise
229 */
230bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
231{
232 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
233}
234
235/**
236 * hdd_conn_get_connected_band() - get current connection radio band
237 * @pHddStaCtx: pointer to global HDD Station context
238 *
239 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
240 * eCSR_BAND_ALL if not connected
241 */
242eCsrBand hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
243{
244 uint8_t staChannel = 0;
245
246 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
247 staChannel = pHddStaCtx->conn_info.operationChannel;
248
249 if (staChannel > 0 && staChannel < 14)
250 return eCSR_BAND_24;
251 else if (staChannel >= 36 && staChannel <= 184)
252 return eCSR_BAND_5G;
253 else /* If station is not connected return as eCSR_BAND_ALL */
254 return eCSR_BAND_ALL;
255}
256
257/**
258 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
259 * @pHddStaCtx: pointer to global HDD Station context
260 * @pConnectedCipherAlgo: pointer to connected cipher algo
261 *
262 * Return: false if any errors encountered, true otherwise
263 */
264static inline bool
265hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
266 eCsrEncryptionType *pConnectedCipherAlgo)
267{
268 bool fConnected = false;
269
270 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
271
272 if (pConnectedCipherAlgo)
273 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
274
275 return fConnected;
276}
277
278/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700279 * hdd_remove_beacon_filter() - remove beacon filter
280 * @adapter: Pointer to the hdd adapter
281 *
282 * Return: 0 on success and errno on failure
283 */
284static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
285{
286 QDF_STATUS status;
287 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
288
289 status = sme_remove_beacon_filter(hdd_ctx->hHal,
290 adapter->sessionId);
291 if (!QDF_IS_STATUS_SUCCESS(status)) {
292 hdd_err("sme_remove_beacon_filter() failed");
293 return -EFAULT;
294 }
295
296 return 0;
297}
298
299/**
300 * hdd_add_beacon_filter() - add beacon filter
301 * @adapter: Pointer to the hdd adapter
302 *
303 * Return: 0 on success and errno on failure
304 */
305static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
306{
307 int i;
308 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
309 QDF_STATUS status;
310 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
311
312 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530313 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700314 (unsigned long int *)ie_map);
315
316 status = sme_add_beacon_filter(hdd_ctx->hHal,
317 adapter->sessionId, ie_map);
318 if (!QDF_IS_STATUS_SUCCESS(status)) {
319 hdd_err("sme_add_beacon_filter() failed");
320 return -EFAULT;
321 }
322 return 0;
323}
324
325/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530326 * hdd_copy_vht_caps()- copy vht caps info from roam info to
327 * hdd station context.
328 * @hdd_sta_ctx: pointer to hdd station context
329 * @roam_info: pointer to roam info
330 *
331 * Return: None
332 */
333static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
334 tCsrRoamInfo *roam_info)
335{
336 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
337 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
338 uint32_t i, temp_ht_cap;
339
340 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
341
342 if (roam_ht_cap->advCodingCap)
343 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
344 if (roam_ht_cap->supportedChannelWidthSet)
345 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
346 temp_ht_cap = roam_ht_cap->mimoPowerSave &
347 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
348 if (temp_ht_cap)
349 hdd_ht_cap->cap_info |=
350 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
351 if (roam_ht_cap->greenField)
352 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
353 if (roam_ht_cap->shortGI20MHz)
354 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
355 if (roam_ht_cap->shortGI40MHz)
356 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
357 if (roam_ht_cap->txSTBC)
358 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
359 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
360 IEEE80211_HT_CAP_RX_STBC_SHIFT);
361 if (temp_ht_cap)
362 hdd_ht_cap->cap_info |=
363 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
364 if (roam_ht_cap->delayedBA)
365 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
366 if (roam_ht_cap->maximalAMSDUsize)
367 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
368 if (roam_ht_cap->dsssCckMode40MHz)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
370 if (roam_ht_cap->psmp)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
372 if (roam_ht_cap->stbcControlFrame)
373 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
374 if (roam_ht_cap->lsigTXOPProtection)
375 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
376
377 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
378 if (roam_ht_cap->maxRxAMPDUFactor)
379 hdd_ht_cap->ampdu_params_info |=
380 IEEE80211_HT_AMPDU_PARM_FACTOR;
381 temp_ht_cap = roam_ht_cap->mpduDensity &
382 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
383 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
384 if (temp_ht_cap)
385 hdd_ht_cap->ampdu_params_info |=
386 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
387
388 /* 802.11n HT extended capabilities masks */
389 if (roam_ht_cap->pco)
390 hdd_ht_cap->extended_ht_cap_info |=
391 IEEE80211_HT_EXT_CAP_PCO;
392 temp_ht_cap = roam_ht_cap->transitionTime &
393 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
394 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
395 if (temp_ht_cap)
396 hdd_ht_cap->extended_ht_cap_info |=
397 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
398 temp_ht_cap = roam_ht_cap->mcsFeedback &
399 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
400 if (temp_ht_cap)
401 hdd_ht_cap->extended_ht_cap_info |=
402 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
403
404 /* tx_bf_cap_info capabilities */
405 if (roam_ht_cap->txBF)
406 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
407 if (roam_ht_cap->rxStaggeredSounding)
408 hdd_ht_cap->tx_BF_cap_info |=
409 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
410 if (roam_ht_cap->txStaggeredSounding)
411 hdd_ht_cap->tx_BF_cap_info |=
412 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
413 if (roam_ht_cap->rxZLF)
414 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
415 if (roam_ht_cap->txZLF)
416 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
417 if (roam_ht_cap->implicitTxBF)
418 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
419 temp_ht_cap = roam_ht_cap->calibration &
420 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
421 if (temp_ht_cap)
422 hdd_ht_cap->tx_BF_cap_info |=
423 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
424 if (roam_ht_cap->explicitCSITxBF)
425 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
426 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
427 hdd_ht_cap->tx_BF_cap_info |=
428 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
429 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
430 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
431 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
432 if (temp_ht_cap)
433 hdd_ht_cap->tx_BF_cap_info |=
434 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
435 temp_ht_cap =
436 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
437 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
438 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
439 if (temp_ht_cap)
440 hdd_ht_cap->tx_BF_cap_info |=
441 temp_ht_cap <<
442 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
443 temp_ht_cap =
444 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
445 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
446 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
447 if (temp_ht_cap)
448 hdd_ht_cap->tx_BF_cap_info |=
449 temp_ht_cap <<
450 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
451 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
452 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
453 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
454 if (temp_ht_cap)
455 hdd_ht_cap->tx_BF_cap_info |=
456 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
457 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
458 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
459 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
460 if (temp_ht_cap)
461 hdd_ht_cap->tx_BF_cap_info |=
462 temp_ht_cap <<
463 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
464 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
465 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
466 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
467 if (temp_ht_cap)
468 hdd_ht_cap->tx_BF_cap_info |=
469 temp_ht_cap <<
470 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
471
472 /* antenna selection */
473 if (roam_ht_cap->antennaSelection)
474 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
475 if (roam_ht_cap->explicitCSIFeedbackTx)
476 hdd_ht_cap->antenna_selection_info |=
477 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
478 if (roam_ht_cap->antennaIndicesFeedbackTx)
479 hdd_ht_cap->antenna_selection_info |=
480 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
481 if (roam_ht_cap->explicitCSIFeedback)
482 hdd_ht_cap->antenna_selection_info |=
483 ANTENNA_SEL_INFO_EXP_CSI_FB;
484 if (roam_ht_cap->antennaIndicesFeedback)
485 hdd_ht_cap->antenna_selection_info |=
486 ANTENNA_SEL_INFO_ANT_ID_FB;
487 if (roam_ht_cap->rxAS)
488 hdd_ht_cap->antenna_selection_info |=
489 ANTENNA_SEL_INFO_RX_AS;
490 if (roam_ht_cap->txSoundingPPDUs)
491 hdd_ht_cap->antenna_selection_info |=
492 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
493
494 /* mcs data rate */
495 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
496 hdd_ht_cap->mcs.rx_mask[i] =
497 roam_ht_cap->supportedMCSSet[i];
498 hdd_ht_cap->mcs.rx_highest =
499 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
500 ((short) (roam_ht_cap->supportedMCSSet[10]));
501 hdd_ht_cap->mcs.tx_params =
502 roam_ht_cap->supportedMCSSet[12];
503}
504
505#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
506#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
507#define VHT_CAP_RXSTBC_MASK_SHIFT 8
508#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
509#define VHT_CAP_BEAMFORMEE_STS_MASK \
510 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
511#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
512#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
513 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
514#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
515#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
516 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
517#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
518
519/**
520 * hdd_copy_ht_caps()- copy ht caps info from roam info to
521 * hdd station context.
522 * @hdd_sta_ctx: pointer to hdd station context
523 * @roam_info: pointer to roam info
524 *
525 * Return: None
526 */
527static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
528 tCsrRoamInfo *roam_info)
529{
530 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
531 struct ieee80211_vht_cap *hdd_vht_cap =
532 &hdd_sta_ctx->conn_info.vht_caps;
533 uint32_t temp_vht_cap;
534
535 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
536
537 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
538 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
539 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
540 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
541 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
542 if (temp_vht_cap)
543 if (roam_vht_cap->supportedChannelWidthSet &
544 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
545 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
546 hdd_vht_cap->vht_cap_info |=
547 temp_vht_cap <<
548 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
549 if (roam_vht_cap->supportedChannelWidthSet &
550 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
551 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
552 hdd_vht_cap->vht_cap_info |=
553 temp_vht_cap <<
554 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
555 if (roam_vht_cap->ldpcCodingCap)
556 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
557 if (roam_vht_cap->shortGI80MHz)
558 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
559 if (roam_vht_cap->shortGI160and80plus80MHz)
560 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
561 if (roam_vht_cap->txSTBC)
562 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
563 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
564 VHT_CAP_RXSTBC_MASK_SHIFT);
565 if (temp_vht_cap)
566 hdd_vht_cap->vht_cap_info |=
567 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
568 if (roam_vht_cap->suBeamFormerCap)
569 hdd_vht_cap->vht_cap_info |=
570 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
571 if (roam_vht_cap->suBeamformeeCap)
572 hdd_vht_cap->vht_cap_info |=
573 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
574 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
575 (VHT_CAP_BEAMFORMEE_STS_MASK);
576 if (temp_vht_cap)
577 hdd_vht_cap->vht_cap_info |=
578 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
579 temp_vht_cap = roam_vht_cap->numSoundingDim &
580 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
581 if (temp_vht_cap)
582 hdd_vht_cap->vht_cap_info |=
583 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
584 if (roam_vht_cap->muBeamformerCap)
585 hdd_vht_cap->vht_cap_info |=
586 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
587 if (roam_vht_cap->muBeamformeeCap)
588 hdd_vht_cap->vht_cap_info |=
589 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
590 if (roam_vht_cap->vhtTXOPPS)
591 hdd_vht_cap->vht_cap_info |=
592 IEEE80211_VHT_CAP_VHT_TXOP_PS;
593 if (roam_vht_cap->htcVHTCap)
594 hdd_vht_cap->vht_cap_info |=
595 IEEE80211_VHT_CAP_HTC_VHT;
596 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
597 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
598 if (temp_vht_cap)
599 hdd_vht_cap->vht_cap_info |=
600 temp_vht_cap <<
601 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
602 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
603 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
604 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
605 if (temp_vht_cap)
606 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
607 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
608 if (roam_vht_cap->rxAntPattern)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
611 if (roam_vht_cap->txAntPattern)
612 hdd_vht_cap->vht_cap_info |=
613 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
614 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
615 hdd_vht_cap->supp_mcs.rx_highest =
616 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
617 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
618 hdd_vht_cap->supp_mcs.tx_highest =
619 ((uint16_t)roam_vht_cap->txSupDataRate);
620}
621
622/* ht param */
623#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
624#define HT_PARAM_SERVICE_INT_GRAN 0xe0
625#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
626
627/* operatinon mode */
628#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
629
630/* stbc_param */
631#define HT_STBC_PARAM_MCS 0x007f
632
633/**
634 * hdd_copy_ht_operation()- copy HT operation element from roam info to
635 * hdd station context.
636 * @hdd_sta_ctx: pointer to hdd station context
637 * @roam_info: pointer to roam info
638 *
639 * Return: None
640 */
641static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
642 tCsrRoamInfo *roam_info)
643{
644 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
645 struct ieee80211_ht_operation *hdd_ht_ops =
646 &hdd_sta_ctx->conn_info.ht_operation;
647 uint32_t i, temp_ht_ops;
648
649 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
650
651 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
652
653 /* HT_PARAMS */
654 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
655 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
656 if (temp_ht_ops)
657 hdd_ht_ops->ht_param |= temp_ht_ops;
658 else
659 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
660 if (roam_ht_ops->recommendedTxWidthSet)
661 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
662 if (roam_ht_ops->rifsMode)
663 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
664 if (roam_ht_ops->controlledAccessOnly)
665 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
666 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
667 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
668 if (temp_ht_ops)
669 hdd_ht_ops->ht_param |= temp_ht_ops <<
670 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
671
672 /* operation mode */
673 temp_ht_ops = roam_ht_ops->opMode &
674 IEEE80211_HT_OP_MODE_PROTECTION;
675 switch (temp_ht_ops) {
676 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
677 hdd_ht_ops->operation_mode |=
678 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
679 break;
680 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
681 hdd_ht_ops->operation_mode |=
682 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
683 break;
684 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
685 hdd_ht_ops->operation_mode |=
686 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
687 break;
688 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
689 default:
690 hdd_ht_ops->operation_mode |=
691 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
692 }
693 if (roam_ht_ops->nonGFDevicesPresent)
694 hdd_ht_ops->operation_mode |=
695 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
696 if (roam_ht_ops->transmitBurstLimit)
697 hdd_ht_ops->operation_mode |=
698 HT_OP_MODE_TX_BURST_LIMIT;
699 if (roam_ht_ops->obssNonHTStaPresent)
700 hdd_ht_ops->operation_mode |=
701 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
702
703 /* stbc_param */
704 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
705 HT_STBC_PARAM_MCS;
706 if (temp_ht_ops)
707 hdd_ht_ops->stbc_param |= temp_ht_ops;
708 if (roam_ht_ops->dualCTSProtection)
709 hdd_ht_ops->stbc_param |=
710 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
711 if (roam_ht_ops->secondaryBeacon)
712 hdd_ht_ops->stbc_param |=
713 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
714 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
715 hdd_ht_ops->stbc_param |=
716 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
717 if (roam_ht_ops->pcoActive)
718 hdd_ht_ops->stbc_param |=
719 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
720 if (roam_ht_ops->pcoPhase)
721 hdd_ht_ops->stbc_param |=
722 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
723
724 /* basic MCs set */
725 for (i = 0; i < 16; ++i)
726 hdd_ht_ops->basic_set[i] =
727 roam_ht_ops->basicMCSSet[i];
728}
729
730/**
731 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
732 * hdd station context.
733 * @hdd_sta_ctx: pointer to hdd station context
734 * @roam_info: pointer to roam info
735 *
736 * Return: None
737 */
738static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
739 tCsrRoamInfo *roam_info)
740{
741 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
742 struct ieee80211_vht_operation *hdd_vht_ops =
743 &hdd_sta_ctx->conn_info.vht_operation;
744
745 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
746
747 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
748 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
749 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
750 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
751}
752
753
754/**
755 * hdd_save_bss_info() - save connection info in hdd sta ctx
756 * @adapter: Pointer to adapter
757 * @roam_info: pointer to roam info
758 *
759 * Return: None
760 */
761static void hdd_save_bss_info(hdd_adapter_t *adapter,
762 tCsrRoamInfo *roam_info)
763{
764 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
765
766 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
767 hdd_sta_ctx->conn_info.operationChannel);
768 if (roam_info->vht_caps.present) {
769 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
770 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
771 } else {
772 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
773 }
774 if (roam_info->ht_caps.present) {
775 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
776 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
777 } else {
778 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
779 }
780 if (roam_info->reassoc)
781 hdd_sta_ctx->conn_info.roam_count++;
782 if (roam_info->hs20vendor_ie.present) {
783 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
784 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
785 &roam_info->hs20vendor_ie,
786 sizeof(roam_info->hs20vendor_ie));
787 } else {
788 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
789 }
790 if (roam_info->ht_operation.present) {
791 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
792 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
793 } else {
794 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
795 }
796 if (roam_info->vht_operation.present) {
797 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
798 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
799 } else {
800 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
801 }
802}
803
804/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 * hdd_conn_save_connect_info() - save current connection information
806 * @pAdapter: pointer to adapter
807 * @pRoamInfo: pointer to roam info
808 * @eBssType: bss type
809 *
810 * Return: none
811 */
812static void
813hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
814 eCsrRoamBssType eBssType)
815{
816 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
817 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
818
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530819 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820
821 if (pRoamInfo) {
822 /* Save the BSSID for the connection */
823 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530824 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530825 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 &pRoamInfo->bssid);
827
828 /*
829 * Save the Station ID for this station from
830 * the 'Roam Info'. For IBSS mode, staId is
831 * assigned in NEW_PEER_IND. For reassoc,
832 * the staID doesn't change and it may be invalid
833 * in this structure so no change here.
834 */
835 if (!pRoamInfo->fReassocReq) {
836 pHddStaCtx->conn_info.staId[0] =
837 pRoamInfo->staId;
838 }
839 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530840 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 &pRoamInfo->bssid);
842 } else {
843 /*
844 * can't happen. We need a valid IBSS or Infra setting
845 * in the BSSDescription or we can't function.
846 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530847 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 }
849
850 /* notify WMM */
851 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
852
853 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530854 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 } else {
856 /* Get Multicast Encryption Type */
857 encryptType =
858 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
859 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
860 /* Get Unicast Encryption Type */
861 encryptType =
862 pRoamInfo->u.pConnectedProfile->EncryptionType;
863 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
864
865 pHddStaCtx->conn_info.authType =
866 pRoamInfo->u.pConnectedProfile->AuthType;
867
868 pHddStaCtx->conn_info.operationChannel =
869 pRoamInfo->u.pConnectedProfile->operationChannel;
870
871 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530872 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 &pRoamInfo->u.pConnectedProfile->SSID,
874 sizeof(tSirMacSSid));
875
876 /* Save dot11mode in which STA associated to AP */
877 pHddStaCtx->conn_info.dot11Mode =
878 pRoamInfo->u.pConnectedProfile->dot11Mode;
879
880 pHddStaCtx->conn_info.proxyARPService =
881 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530882
883 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
884
885 pHddStaCtx->conn_info.rate_flags =
886 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530888 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890}
891
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892/**
893 * hdd_send_ft_assoc_response() - send fast transition assoc response
894 * @dev: pointer to net device
895 * @pAdapter: pointer to adapter
896 * @pCsrRoamInfo: pointer to roam info
897 *
898 * Send the 11R key information to the supplicant. Only then can the supplicant
899 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
900 * for the same purpose.)
901 *
902 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
903 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
904 * This is the Assoc Response.
905 *
906 * Return: none
907 */
908static void
909hdd_send_ft_assoc_response(struct net_device *dev,
910 hdd_adapter_t *pAdapter,
911 tCsrRoamInfo *pCsrRoamInfo)
912{
913 union iwreq_data wrqu;
914 char *buff;
915 unsigned int len = 0;
916 u8 *pFTAssocRsp = NULL;
917
918 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700919 hdd_err("pCsrRoamInfo->nAssocRspLength=%d",
920 (int)pCsrRoamInfo->nAssocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 return;
922 }
923
924 pFTAssocRsp =
925 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
926 pCsrRoamInfo->nAssocReqLength);
927 if (pFTAssocRsp == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700928 hdd_err("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 return;
930 }
931 /* pFTAssocRsp needs to point to the IEs */
932 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700933 hdd_notice("AssocRsp is now at %02x%02x",
934 (unsigned int)pFTAssocRsp[0],
935 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
937 /* We need to send the IEs to the supplicant. */
938 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
939 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700940 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 return;
942 }
943 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
944 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
945 wrqu.data.length = len;
946 memset(buff, 0, IW_GENERIC_IE_MAX);
947 memcpy(buff, pFTAssocRsp, len);
948 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
949
950 kfree(buff);
951}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953/**
954 * hdd_send_ft_event() - send fast transition event
955 * @pAdapter: pointer to adapter
956 *
957 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
958 * FT events to the supplicant. At the reception of Auth2 we send the RIC
959 * followed by the auth response IEs to the supplicant.
960 * Once both are received in the supplicant, an FT event is generated
961 * to the supplicant.
962 *
963 * Return: none
964 */
965static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
966{
967 uint16_t auth_resp_len = 0;
968 uint32_t ric_ies_length = 0;
969 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
970
971#if defined(KERNEL_SUPPORT_11R_CFG80211)
972 struct cfg80211_ft_event_params ftEvent;
973 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
974 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
975 struct net_device *dev = pAdapter->dev;
976#else
977 char *buff;
978 union iwreq_data wrqu;
979 uint16_t str_len;
980#endif
981
982#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530983 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
984 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985
986 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
987 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
988 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700989 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 }
991
992 ftEvent.ric_ies = ricIe;
993 ftEvent.ric_ies_len = ric_ies_length;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700994 hdd_notice("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995
996 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
997 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
998 &auth_resp_len);
999
1000 if (auth_resp_len == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001001 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 return;
1003 }
1004
1005 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1006
1007 ftEvent.target_ap = ftIe;
1008
Anurag Chouhan6d760662016-02-20 16:05:43 +05301009 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1010 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001012 hdd_notice("ftEvent.ies_len %zu", ftEvent.ies_len);
1013 hdd_notice("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1014 hdd_notice("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 ftEvent.target_ap[0], ftEvent.target_ap[1],
1016 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1017 ftEvent.target_ap[5]);
1018
1019 (void)cfg80211_ft_event(dev, &ftEvent);
1020
1021#else
1022 /* We need to send the IEs to the supplicant */
1023 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
1024 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001025 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 return;
1027 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301028 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029
1030 /* Sme needs to send the RIC IEs first */
1031 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1032 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1033 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1034 &ric_ies_length);
1035 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001036 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 } else {
1038 wrqu.data.length = str_len + ric_ies_length;
1039 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1040 }
1041
1042 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301043 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1045 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1046 (u8 *) &buff[str_len],
1047 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1048
1049 if (auth_resp_len == 0) {
1050 kfree(buff);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001051 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 return;
1053 }
1054
1055 wrqu.data.length = str_len + auth_resp_len;
1056 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1057
1058 kfree(buff);
1059#endif
1060}
1061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062#ifdef FEATURE_WLAN_ESE
1063/**
1064 * hdd_send_new_ap_channel_info() - send new ap channel info
1065 * @dev: pointer to net device
1066 * @pAdapter: pointer to adapter
1067 * @pCsrRoamInfo: pointer to roam info
1068 *
1069 * Send the ESE required "new AP Channel info" to the supplicant.
1070 * (This keeps the supplicant "up to date" on the current channel.)
1071 *
1072 * The current (new AP) channel information is passed in.
1073 *
1074 * Return: none
1075 */
1076static void
1077hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1078 tCsrRoamInfo *pCsrRoamInfo)
1079{
1080 union iwreq_data wrqu;
1081 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1082
1083 if (descriptor == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001084 hdd_err("pCsrRoamInfo->pBssDesc(%p)", descriptor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 return;
1086 }
1087 /*
1088 * Send the Channel event, the supplicant needs this to generate
1089 * the Adjacent AP report.
1090 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001091 hdd_warn("Sending up an SIOCGIWFREQ, channelId(%d)",
1092 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 memset(&wrqu, '\0', sizeof(wrqu));
1094 wrqu.freq.m = descriptor->channelId;
1095 wrqu.freq.e = 0;
1096 wrqu.freq.i = 0;
1097 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1098}
1099
1100#endif /* FEATURE_WLAN_ESE */
1101
1102/**
1103 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1104 * @pAdapter: pointer to adapter
1105 * @pCsrRoamInfo: pointer to roam info
1106 *
1107 * Return: none
1108 */
1109static void
1110hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1111 tCsrRoamInfo *pCsrRoamInfo)
1112{
1113 union iwreq_data wrqu;
1114 u8 *pBeaconIes;
1115 u8 currentLen = 0;
1116 char *buff;
1117 int totalIeLen = 0, currentOffset = 0, strLen;
1118
1119 memset(&wrqu, '\0', sizeof(wrqu));
1120
1121 if (0 == pCsrRoamInfo->nBeaconLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001122 hdd_warn("pCsrRoamInfo->nBeaconFrameLength = 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123 return;
1124 }
1125 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1126 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001127 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 return;
1129 }
1130 /* pBeaconIes needs to point to the IEs */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001131 hdd_notice("Beacon IEs is now at %02x%02x",
1132 (unsigned int)pBeaconIes[0],
1133 (unsigned int)pBeaconIes[1]);
1134 hdd_notice("Beacon IEs length = %d",
1135 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136
1137 /* We need to send the IEs to the supplicant. */
1138 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
1139 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001140 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001141 return;
1142 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301143 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144
1145 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1146 currentLen = strLen + 1;
1147
1148 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1149 do {
1150 /*
1151 * If the beacon size exceeds max CUSTOM event size, break it
1152 * into chunks of CUSTOM event max size and send it to
1153 * supplicant. Changes are done in supplicant to handle this.
1154 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301155 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301157 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301158 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159 currentLen);
1160 currentOffset += currentLen;
1161 totalIeLen -= currentLen;
1162 wrqu.data.length = strLen + 1 + currentLen;
1163 if (totalIeLen)
1164 buff[strLen] = 1; /* more chunks pending */
1165 else
1166 buff[strLen] = 0; /* last chunk */
1167
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001168 hdd_notice("Beacon IEs length to supplicant = %d",
1169 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1171 } while (totalIeLen > 0);
1172
1173 kfree(buff);
1174}
1175
1176/**
1177 * hdd_send_association_event() - send association event
1178 * @dev: pointer to net device
1179 * @pCsrRoamInfo: pointer to roam info
1180 *
1181 * Return: none
1182 */
1183static void hdd_send_association_event(struct net_device *dev,
1184 tCsrRoamInfo *pCsrRoamInfo)
1185{
1186 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1187 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1188 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1189 union iwreq_data wrqu;
1190 int we_event;
1191 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301192 struct qdf_mac_addr peerMacAddr;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301193 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 /* Added to find the auth type on the fly at run time */
1196 /* rather than with cfg to see if FT is enabled */
1197 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1198 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001199
1200 memset(&wrqu, '\0', sizeof(wrqu));
1201 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1202 we_event = SIOCGIWAP;
1203#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1204 if (NULL != pCsrRoamInfo)
1205 if (pCsrRoamInfo->roamSynchInProgress)
1206 /* change logging before release */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001207 hdd_info("LFR3:hdd_send_association_event");
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 wlan_hdd_enable_roaming(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329
1330#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1331 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1332#endif
1333
Abhishek Singh1c676222016-05-09 14:20:28 +05301334 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1335 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301336 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 &pHddStaCtx->conn_info.bssId);
1338
1339 /* send peer status indication to oem app */
1340 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301341 ePeerDisconnected, 0,
1342 pAdapter->sessionId,
1343 NULL,
1344 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301346
1347 qdf_status = hdd_remove_peer_object(pAdapter->hdd_vdev,
1348 peerMacAddr.bytes);
1349 if (QDF_IS_STATUS_ERROR(qdf_status))
1350 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1351 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1352
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001353 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001354 /* Update tdls module about the disconnection event */
1355 wlan_hdd_tdls_notify_disconnect(pAdapter);
1356
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357#ifdef MSM_PLATFORM
1358 /* stop timer in sta/p2p_cli */
1359 spin_lock_bh(&pHddCtx->bus_bw_lock);
1360 pAdapter->prev_tx_packets = 0;
1361 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301362 pAdapter->prev_fwd_tx_packets = 0;
1363 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1365 hdd_stop_bus_bw_compute_timer(pAdapter);
1366#endif
1367 }
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001368 cds_dump_concurrency_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 /* Send SCC/MCC Switching event to IPA */
1370 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1371
1372 msg = NULL;
1373 /*During the WLAN uninitialization,supplicant is stopped before the
1374 driver so not sending the status of the connection to supplicant */
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;
1939 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1940 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1941 uint8_t *buf_ptr, ssid_ie_len;
1942 struct cfg80211_bss *bss = NULL;
1943 uint8_t *final_req_ie = NULL;
1944 tCsrRoamConnectedProfile roam_profile;
1945 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1946
Jeff Johnsonfdb73432016-10-11 08:07:27 -07001947 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
1948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001950 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001951 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 }
1953
Naveen Rawat14298b92015-11-25 16:27:41 -08001954 if (!assoc_req_ies) {
1955 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001956 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001957 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001959 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 goto done;
1961 }
1962
1963 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001964 hdd_err("Invalid assoc response length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 goto done;
1966 }
1967
1968 pFTAssocRsp =
1969 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1970 pCsrRoamInfo->nAssocReqLength);
1971 if (pFTAssocRsp == NULL)
1972 goto done;
1973
1974 /* pFTAssocRsp needs to point to the IEs */
1975 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001976 hdd_info("AssocRsp is now at %02x%02x",
1977 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978
1979 /*
1980 * Active session count is decremented upon disconnection, but during
1981 * roaming, there is no disconnect indication and hence active session
1982 * count is not decremented.
1983 * After roaming is completed, active session count is incremented
1984 * as a part of connect indication but effectively after roaming the
1985 * active session count should still be the same and hence upon
1986 * successful reassoc decrement the active session count here.
1987 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001988 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301989 cds_decr_session_set_pcl(pAdapter->device_mode,
1990 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991
1992 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
1993 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1994 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301995 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
1996 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997
1998 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1999 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2001 &roam_profile);
2002 bss = cfg80211_get_bss(pAdapter->wdev.wiphy, chan,
2003 pCsrRoamInfo->bssid.bytes,
2004 &roam_profile.SSID.ssId[0], roam_profile.SSID.length,
Ryan Hsu535d16a2016-01-18 16:45:12 -08002005#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
Ryan Hsu535d16a2016-01-18 16:45:12 -08002007#else
2008 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
2009#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010
2011 if (bss == NULL)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002012 hdd_err("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 buf_ptr = buf_ssid_ie;
2014 *buf_ptr = SIR_MAC_SSID_EID;
2015 buf_ptr++;
2016 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2017 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302018 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 roam_profile.SSID.length);
2020 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08002021 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302022 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002023 buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 final_req_ie = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
2025 if (final_req_ie == NULL)
2026 goto done;
2027 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302028 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302030 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2031 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2032 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08002034 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302035 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002036 final_req_ie, (ssid_ie_len + reqRsnLength));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 cfg80211_roamed_bss(dev, bss,
2038 final_req_ie, (ssid_ie_len + reqRsnLength),
2039 rspRsnIe, rspRsnLength, GFP_KERNEL);
2040
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302041 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002042 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2043 pCsrRoamInfo->nAssocReqLength);
2044
2045 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302046 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002047 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2048
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002049 wlan_hdd_send_roam_auth_event(pHddCtx, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002050 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2051 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002052 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002054 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 if (final_req_ie)
2056 kfree(final_req_ie);
2057 kfree(rspRsnIe);
Naveen Rawat14298b92015-11-25 16:27:41 -08002058 kfree(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059}
2060
2061/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302062 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002063 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302064 *
2065 * Return: roam sync status if roaming offloaded else false
2066 */
2067#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002068bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302069{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002070 if (roaminfo)
2071 return roaminfo->roamSynchInProgress;
2072 else
2073 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302074}
2075#endif
2076
2077
2078/**
2079 * hdd_change_sta_state_authenticated()-
2080 * This function changes STA state to authenticated
2081 * @adapter: pointer to the adapter structure.
2082 * @roaminfo: pointer to the RoamInfo structure.
2083 *
2084 * This is called from hdd_RoamSetKeyCompleteHandler
2085 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2086 *
2087 * Return: 0 on success and errno on failure
2088 */
2089static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2090 tCsrRoamInfo *roaminfo)
2091{
2092 int ret;
Dustin Brownf660fb42016-09-09 12:04:00 -07002093 uint32_t timeout;
Govind Singhedc5cda2015-10-23 17:11:35 +05302094 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002095 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302096
Dustin Brownf660fb42016-09-09 12:04:00 -07002097 timeout = hddstactx->hdd_ReassocScenario ?
2098 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002099 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002100
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002101 hdd_info("Changing TL state to AUTHENTICATED for StaId= %d",
2102 hddstactx->conn_info.staId[0]);
Govind Singhedc5cda2015-10-23 17:11:35 +05302103
2104 /* Connections that do not need Upper layer authentication,
2105 * transition TL to 'Authenticated' state after the keys are set
2106 */
2107 ret = hdd_change_peer_state(adapter,
2108 hddstactx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002109 OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302110 hdd_is_roam_sync_in_progress(roaminfo));
2111 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08002112 if ((QDF_STA_MODE == adapter->device_mode) ||
2113 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302114 sme_ps_enable_auto_ps_timer(
2115 WLAN_HDD_GET_HAL_CTX(adapter),
2116 adapter->sessionId,
Dustin Brownf660fb42016-09-09 12:04:00 -07002117 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302118 }
2119
2120 return ret;
2121}
2122
2123/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 * hdd_roam_set_key_complete_handler() - Update the security parameters
2125 * @pAdapter: pointer to adapter
2126 * @pRoamInfo: pointer to roam info
2127 * @roamId: roam id
2128 * @roamStatus: roam status
2129 * @roamResult: roam result
2130 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302131 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302133static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 tCsrRoamInfo *pRoamInfo,
2135 uint32_t roamId,
2136 eRoamCmdStatus roamStatus,
2137 eCsrRoamResult roamResult)
2138{
2139 eCsrEncryptionType connectedCipherAlgo;
2140 bool fConnected = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302141 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302143 tHalHandle hal_ctx = WLAN_HDD_GET_HAL_CTX(pAdapter);
2144 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
2145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 ENTER();
2147
2148 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002149 hdd_info("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302150 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151 }
2152 /*
2153 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2154 * then go to 'authenticated'. For all other authentication types
2155 * (those that do not require upper layer authentication) we can put TL
2156 * directly into 'authenticated' state.
2157 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002158 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 MAC_ADDRESS_STR, roamStatus, roamResult,
2160 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2161
2162 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2163 &connectedCipherAlgo);
2164 if (fConnected) {
Krunal Sonibe766b02016-03-10 13:00:44 -08002165 if (QDF_IBSS_MODE == pAdapter->device_mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 uint8_t staId;
2167
Anurag Chouhanc5548422016-02-24 18:33:27 +05302168 if (qdf_is_macaddr_broadcast(&pRoamInfo->peerMac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 pHddStaCtx->roam_info.roamingState =
2170 HDD_ROAM_STATE_NONE;
2171 } else {
Deepak Dhamdhere5872c8c2016-06-02 15:51:47 -07002172 qdf_status = hdd_get_peer_sta_id(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 pHddStaCtx,
2174 &pRoamInfo->peerMac,
2175 &staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302176 if (QDF_STATUS_SUCCESS == qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002177 hdd_info("WLAN TL STA Ptk Installed for STAID=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178 staId);
2179 pHddStaCtx->roam_info.roamingState =
2180 HDD_ROAM_STATE_NONE;
2181 }
2182 }
2183 } else {
2184 /*
2185 * TODO: Considering getting a state machine in
Govind Singhedc5cda2015-10-23 17:11:35 +05302186 * HDD later.This routine is invoked twice.
2187 * 1)set PTK 2)set GTK.The following if
2188 * statement will be TRUE when setting GTK.
2189 * At this time we don't handle the state in detail.
2190 * Related CR: 174048 - TL not in authenticated state
2191 */
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302192 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302193 pHddStaCtx->conn_info.gtk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302194 /*
2195 * PTK exchange happens in preauthentication
2196 * itself if key_mgmt is FT-PSK, ptk_installed
2197 * was false as there is no set PTK after
2198 * roaming. STA TL state moves to authenticated
2199 * only if ptk_installed is true. So, make
2200 * ptk_installed to true in case of 11R roaming.
2201 */
2202 if (csr_neighbor_roam_is11r_assoc(mac_ctx,
2203 pAdapter->sessionId))
2204 pHddStaCtx->conn_info.ptk_installed =
2205 true;
2206 } else {
Govind Singhedc5cda2015-10-23 17:11:35 +05302207 pHddStaCtx->conn_info.ptk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302208 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302209
2210 /* In WPA case move STA to authenticated when
2211 * ptk is installed.Earlier in WEP case STA
2212 * was moved to AUTHENTICATED prior to setting
2213 * the unicast key and it was resulting in sending
2214 * few un-encrypted packet. Now in WEP case
2215 * STA state will be moved to AUTHENTICATED
2216 * after we set the unicast and broadcast key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 */
Govind Singhedc5cda2015-10-23 17:11:35 +05302218 if ((pHddStaCtx->conn_info.ucEncryptionType ==
2219 eCSR_ENCRYPT_TYPE_WEP40) ||
2220 (pHddStaCtx->conn_info.ucEncryptionType ==
2221 eCSR_ENCRYPT_TYPE_WEP104) ||
2222 (pHddStaCtx->conn_info.ucEncryptionType ==
2223 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2224 (pHddStaCtx->conn_info.ucEncryptionType ==
2225 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2226 if (pHddStaCtx->conn_info.gtk_installed &&
2227 pHddStaCtx->conn_info.ptk_installed)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302228 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302229 hdd_change_sta_state_authenticated(pAdapter,
2230 pRoamInfo);
2231 } else if (pHddStaCtx->conn_info.ptk_installed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302232 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302233 hdd_change_sta_state_authenticated(pAdapter,
2234 pRoamInfo);
2235 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236
Govind Singhedc5cda2015-10-23 17:11:35 +05302237 if (pHddStaCtx->conn_info.gtk_installed &&
2238 pHddStaCtx->conn_info.ptk_installed) {
2239 pHddStaCtx->conn_info.gtk_installed = false;
2240 pHddStaCtx->conn_info.ptk_installed = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 }
2242
2243 pHddStaCtx->roam_info.roamingState =
Govind Singhedc5cda2015-10-23 17:11:35 +05302244 HDD_ROAM_STATE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 }
2246 } else {
2247 /*
2248 * possible disassoc after issuing set key and waiting
2249 * set key complete.
2250 */
2251 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2252 }
2253
2254 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302255 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256}
2257
2258/**
2259 * hdd_perform_roam_set_key_complete() - perform set key complete
2260 * @pAdapter: pointer to adapter
2261 *
2262 * Return: none
2263 */
2264void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2265{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302266 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2268 tCsrRoamInfo roamInfo;
2269 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302270 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302271 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302272 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302273 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302275 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 hdd_roam_set_key_complete_handler(pAdapter,
2277 &roamInfo,
2278 pHddStaCtx->roam_info.roamId,
2279 pHddStaCtx->roam_info.roamStatus,
2280 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302281 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002282 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283
2284 pHddStaCtx->roam_info.deferKeyComplete = false;
2285}
2286
2287/**
2288 * hdd_association_completion_handler() - association completion handler
2289 * @pAdapter: pointer to adapter
2290 * @pRoamInfo: pointer to roam info
2291 * @roamId: roam id
2292 * @roamStatus: roam status
2293 * @roamResult: roam result
2294 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302295 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302297static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 tCsrRoamInfo *pRoamInfo,
2299 uint32_t roamId,
2300 eRoamCmdStatus roamStatus,
2301 eCsrRoamResult roamResult)
2302{
2303 struct net_device *dev = pAdapter->dev;
2304 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2305 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302306 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2308 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 bool hddDisconInProgress = false;
2311 unsigned long rc;
2312
2313 if (!pHddCtx) {
2314 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302315 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 }
2317
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302318 /* validate config */
2319 if (!pHddCtx->config) {
2320 hdd_err("config is NULL");
2321 return QDF_STATUS_E_NULL_VALUE;
2322 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 /* HDD has initiated disconnect, do not send connect result indication
2324 * to kernel as it will be handled by __cfg80211_disconnect.
2325 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302326 if (((eConnectionState_Disconnecting ==
2327 pHddStaCtx->conn_info.connState) ||
2328 (eConnectionState_NotConnected ==
2329 pHddStaCtx->conn_info.connState)) &&
2330 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2331 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002332 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 hddDisconInProgress = true;
2334 }
2335
2336 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2337 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002338 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302339 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 }
2341 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 hdd_conn_set_connection_state(pAdapter,
2343 eConnectionState_Associated);
2344 }
2345 /* Save the connection info from CSR... */
2346 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2347 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002348
2349 if (hdd_add_beacon_filter(pAdapter) != 0)
2350 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351#ifdef FEATURE_WLAN_WAPI
2352 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2353 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2354 || pRoamInfo->u.pConnectedProfile->AuthType ==
2355 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2356 pAdapter->wapi_info.fIsWapiSta = 1;
2357 } else {
2358 pAdapter->wapi_info.fIsWapiSta = 0;
2359 }
2360#endif /* FEATURE_WLAN_WAPI */
2361
2362 /* Indicate 'connect' status to user space */
2363 hdd_send_association_event(dev, pRoamInfo);
2364
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002365 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 if (pHddCtx->miracast_value)
2367 cds_set_mas(pAdapter, pHddCtx->miracast_value);
2368 }
2369
2370 /* Initialize the Linkup event completion variable */
2371 INIT_COMPLETION(pAdapter->linkup_event_var);
2372
2373 /*
2374 * Sometimes Switching ON the Carrier is taking time to activate
2375 * the device properly. Before allowing any packet to go up to
2376 * the application, device activation has to be ensured for
2377 * proper queue mapping by the kernel. we have registered net
2378 * device notifier for device change notification. With this we
2379 * will come to know that the device is getting
2380 * activated properly.
2381 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002383 /*
2384 * Enable Linkup Event Servicing which allows the net
2385 * device notifier to set the linkup event variable.
2386 */
2387 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002389 /* Switch on the Carrier to activate the device */
2390 wlan_hdd_netif_queue_control(pAdapter,
2391 WLAN_NETIF_CARRIER_ON,
2392 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002394 /*
2395 * Wait for the Link to up to ensure all the queues
2396 * are set properly by the kernel.
2397 */
2398 rc = wait_for_completion_timeout(
2399 &pAdapter->linkup_event_var,
2400 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2401 );
2402 if (!rc)
2403 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002405 /*
2406 * Disable Linkup Event Servicing - no more service
2407 * required from the net device notifier call.
2408 */
2409 pAdapter->isLinkUpSvcNeeded = false;
2410 } else {
2411 pHddStaCtx->ft_carrier_on = false;
2412 ft_carrier_on = true;
2413 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2415 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2416 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002417 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418
2419 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2420
2421 if (hdd_ipa_is_enabled(pHddCtx))
2422 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002423 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 pRoamInfo->bssid.bytes);
2425
2426#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2427 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2428#endif
2429
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302430 hdd_info("check for SAP restart");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002431 cds_check_concurrent_intf_and_restart_sap(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432
Nirav Shah1da77682016-05-03 20:16:39 +05302433 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2434 pAdapter->sessionId,
2435 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 /*
2438 * For reassoc, the station is already registered, all we need
2439 * is to change the state of the STA in TL.
2440 * If authentication is required (WPA/WPA2/DWEP), change TL to
2441 * CONNECTED instead of AUTHENTICATED.
2442 */
2443 if (!pRoamInfo->fReassocReq) {
2444 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002445 u8 *pFTAssocRsp = NULL;
2446 unsigned int assocRsplen = 0;
2447 u8 *pFTAssocReq = NULL;
2448 unsigned int assocReqlen = 0;
2449 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2451 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2452
2453 /* add bss_id to cfg80211 data base */
2454 bss =
2455 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2456 pRoamInfo);
2457 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302458 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 wlan_hdd_netif_queue_control(pAdapter,
2460 WLAN_NETIF_CARRIER_OFF,
2461 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302462 if (!hddDisconInProgress) {
2463 /*
2464 * Here driver was not able to add bss
2465 * in cfg80211 database this can happen
2466 * if connected channel is not valid,
2467 * i.e reg domain was changed during
2468 * connection. Queue disconnect for the
2469 * session if disconnect is not in
2470 * progress.
2471 */
2472 hdd_err("Disconnecting...");
2473 sme_roam_disconnect(
2474 WLAN_HDD_GET_HAL_CTX(pAdapter),
2475 pAdapter->sessionId,
2476 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2477 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302478 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2481 eCSR_AUTH_TYPE_FT_RSN
2482 || pRoamInfo->u.pConnectedProfile->AuthType ==
2483 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2484
2485 /* Association Response */
2486 pFTAssocRsp =
2487 (u8 *) (pRoamInfo->pbFrames +
2488 pRoamInfo->nBeaconLength +
2489 pRoamInfo->nAssocReqLength);
2490 if (pFTAssocRsp != NULL) {
2491 /*
2492 * pFTAssocRsp needs to point to the IEs
2493 */
2494 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002495 hdd_info("AssocRsp is now at %02x%02x",
2496 (unsigned int)pFTAssocRsp[0],
2497 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 assocRsplen =
2499 pRoamInfo->nAssocRspLength -
2500 FT_ASSOC_RSP_IES_OFFSET;
2501 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002502 hdd_err("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 assocRsplen = 0;
2504 }
2505
2506 /* Association Request */
2507 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2508 pRoamInfo->nBeaconLength);
2509 if (pFTAssocReq != NULL) {
2510 if (!ft_carrier_on) {
2511 /*
2512 * pFTAssocReq needs to point to
2513 * the IEs
2514 */
2515 pFTAssocReq +=
2516 FT_ASSOC_REQ_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002517 hdd_info("pFTAssocReq is now at %02x%02x",
2518 (unsigned int)
2519 pFTAssocReq[0],
2520 (unsigned int)
2521 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 assocReqlen =
2523 pRoamInfo->nAssocReqLength -
2524 FT_ASSOC_REQ_IES_OFFSET;
2525 } else {
2526 /*
2527 * This should contain only the
2528 * FTIEs
2529 */
2530 assocReqlen =
2531 pRoamInfo->nAssocReqLength;
2532 }
2533 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002534 hdd_err("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535 assocReqlen = 0;
2536 }
2537
2538 if (ft_carrier_on) {
2539 if (!hddDisconInProgress) {
2540 /*
2541 * After roaming is completed,
2542 * active session count is
2543 * incremented as a part of
2544 * connect indication but
2545 * effectively the active
2546 * session count should still
2547 * be the same and hence upon
2548 * successful reassoc
2549 * decrement the active session
2550 * count here.
2551 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002552 if (!hdd_is_roam_sync_in_progress
2553 (pRoamInfo))
2554 cds_decr_session_set_pcl
2555 (pAdapter->device_mode,
2556 pAdapter->sessionId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002557 hdd_info("ft_carrier_on is %d, sending roamed indication",
2558 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559 chan =
2560 ieee80211_get_channel
2561 (pAdapter->wdev.wiphy,
2562 (int)pRoamInfo->pBssDesc->
2563 channelId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002564 hdd_info(
2565 "assocReqlen %d assocRsplen %d",
2566 assocReqlen,
2567 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002568
2569 hdd_notice(
2570 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302571 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302572 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302573 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002574 pFTAssocReq,
2575 assocReqlen);
2576
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 cfg80211_roamed(dev, chan,
2578 pRoamInfo->
2579 bssid.bytes,
2580 pFTAssocReq,
2581 assocReqlen,
2582 pFTAssocRsp,
2583 assocRsplen,
2584 GFP_KERNEL);
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002585 wlan_hdd_send_roam_auth_event(
2586 pHddCtx,
2587 pRoamInfo->bssid.bytes,
2588 pFTAssocReq,
2589 assocReqlen,
2590 pFTAssocRsp,
2591 assocRsplen,
2592 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 }
2594 if (sme_get_ftptk_state
2595 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2596 pAdapter->sessionId)) {
2597 sme_set_ftptk_state
2598 (WLAN_HDD_GET_HAL_CTX
2599 (pAdapter),
2600 pAdapter->sessionId,
2601 false);
2602 pRoamInfo->fAuthRequired =
2603 false;
2604
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302605 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 roam_info.bssid,
2607 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302608 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302609 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 roam_info.peerMac,
2611 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302612 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 pHddStaCtx->roam_info.roamId =
2614 roamId;
2615 pHddStaCtx->roam_info.
2616 roamStatus = roamStatus;
2617 pHddStaCtx->roam_info.
2618 deferKeyComplete = true;
2619 }
2620 } else if (!hddDisconInProgress) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002621 hdd_info("ft_carrier_on is %d, sending connect indication",
2622 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302623 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 pRoamInfo->
2625 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302626 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 pFTAssocReq,
2628 assocReqlen,
2629 pFTAssocRsp,
2630 assocRsplen,
2631 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302632 GFP_KERNEL,
2633 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002635 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 /*
2637 * wpa supplicant expecting WPA/RSN IE in
2638 * connect result.
2639 */
2640 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2641 (pAdapter),
2642 pAdapter->sessionId,
2643 &reqRsnLength,
2644 reqRsnIe);
2645
2646 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2647 (pAdapter),
2648 pAdapter->sessionId,
2649 &rspRsnLength,
2650 rspRsnIe);
2651 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 if (ft_carrier_on)
2653 hdd_send_re_assoc_event(dev,
2654 pAdapter,
2655 pRoamInfo,
2656 reqRsnIe,
2657 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002658 else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002659 hdd_info("sending connect indication to nl80211:for bssid "
2660 MAC_ADDRESS_STR
2661 " result:%d and Status:%d",
2662 MAC_ADDR_ARRAY
2663 (pRoamInfo->bssid.bytes),
2664 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665
2666 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302667 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 pRoamInfo->
2669 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302670 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 reqRsnIe,
2672 reqRsnLength,
2673 rspRsnIe,
2674 rspRsnLength,
2675 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302676 GFP_KERNEL,
2677 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 }
2679 }
2680 }
2681 if (!hddDisconInProgress) {
2682 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 bss);
2685
2686 /*
2687 * Perform any WMM-related association
2688 * processing.
2689 */
2690 hdd_wmm_assoc(pAdapter, pRoamInfo,
2691 eCSR_BSS_TYPE_INFRASTRUCTURE);
2692
2693 /*
2694 * Start the Queue - Start tx queues before
2695 * hdd_roam_register_sta, since
2696 * hdd_roam_register_sta will flush any cached
2697 * data frames immediately.
2698 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002699 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 wlan_hdd_netif_queue_control(pAdapter,
2701 WLAN_WAKE_ALL_NETIF_QUEUE,
2702 WLAN_CONTROL_PATH);
2703
2704 /*
2705 * Register the Station with TL after associated
2706 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302707 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 pRoamInfo,
2709 pHddStaCtx->
2710 conn_info.
2711 staId[0],
2712 NULL,
2713 pRoamInfo->
2714 pBssDesc);
2715 }
2716 } else {
2717 /*
2718 * wpa supplicant expecting WPA/RSN IE in connect result
2719 * in case of reassociation also need to indicate it to
2720 * supplicant.
2721 */
2722 csr_roam_get_wpa_rsn_req_ie(
2723 WLAN_HDD_GET_HAL_CTX(pAdapter),
2724 pAdapter->sessionId,
2725 &reqRsnLength, reqRsnIe);
2726
2727 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2728 reqRsnIe, reqRsnLength);
2729 /* Reassoc successfully */
2730 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302731 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 hdd_change_peer_state(pAdapter,
2733 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002734 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2736 pRoamInfo->roamSynchInProgress
2737#else
2738 false
2739#endif
2740 );
2741 hdd_conn_set_authenticated(pAdapter, false);
2742 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002743 hdd_info("staId: %d Changing TL state to AUTHENTICATED",
2744 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302745 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 hdd_change_peer_state(pAdapter,
2747 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002748 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2750 pRoamInfo->roamSynchInProgress
2751#else
2752 false
2753#endif
2754 );
2755 hdd_conn_set_authenticated(pAdapter, true);
2756 }
2757
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302758 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 /*
2760 * Perform any WMM-related association
2761 * processing
2762 */
2763 hdd_wmm_assoc(pAdapter, pRoamInfo,
2764 eCSR_BSS_TYPE_INFRASTRUCTURE);
2765 }
2766
2767 /* Start the tx queues */
2768#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2769 if (pRoamInfo->roamSynchInProgress)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002770 hdd_info("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002772 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 wlan_hdd_netif_queue_control(pAdapter,
2774 WLAN_WAKE_ALL_NETIF_QUEUE,
2775 WLAN_CONTROL_PATH);
2776 }
2777
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302778#ifdef FEATURE_WLAN_TDLS
2779 wlan_hdd_tdls_connection_callback(pAdapter);
2780#endif
2781
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302782 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002783 hdd_err("STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302784 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 }
2786#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302787 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 sizeof(pAdapter->hdd_stats.hddPmfStats));
2789#endif
2790 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302791 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 hdd_wext_state_t *pWextState =
2793 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2794 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302795 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2796 " result:%d and Status:%d",
2797 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2798 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302800 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2801 " result:%d and Status:%d",
2802 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2803 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302804
2805 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2806 (pRoamInfo &&
2807 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2808 pRoamInfo->statusCode) ||
2809 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2810 pRoamInfo->statusCode) ||
2811 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2812 pRoamInfo->statusCode)))) {
2813 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2814 pRoamInfo ?
2815 pRoamInfo->bssid.bytes :
2816 pWextState->req_bssId.bytes);
2817 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2818 pRoamInfo ?
2819 pRoamInfo->bssid.bytes :
2820 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05302821 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05302822 }
2823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 /*
2825 * CR465478: Only send up a connection failure result when CSR
2826 * has completed operation - with a ASSOCIATION_FAILURE status.
2827 */
2828 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2829 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302830 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002831 hdd_err("send connect failure to nl80211: for bssid "
2832 MAC_ADDRESS_STR
2833 " result:%d and Status:%d reasoncode %d",
2834 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2835 roamResult, roamStatus,
2836 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302837 pHddStaCtx->conn_info.assoc_status_code =
2838 pRoamInfo->statusCode;
2839 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002841 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 MAC_ADDRESS_STR
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002843 " result:%d and Status:%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2845 roamResult, roamStatus);
2846
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05302847 hdd_err("Invoking packetdump deregistration API");
2848 wlan_deregister_txrx_packetdump();
2849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 /* inform association failure event to nl80211 */
2851 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
2852 roamResult) {
2853 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302854 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302856 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302858 GFP_KERNEL,
2859 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302861 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302863 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302865 GFP_KERNEL,
2866 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 } else {
Wu Gao77d28352016-11-23 17:50:56 +08002868 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302869 hdd_connect_result(dev,
2870 pRoamInfo->bssid.bytes,
2871 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08002872 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05302873 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302875 GFP_KERNEL,
2876 connect_timeout);
Wu Gao77d28352016-11-23 17:50:56 +08002877 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302878 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302880 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302882 GFP_KERNEL,
2883 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 }
Abhishek Singhac2be142015-12-03 16:16:25 +05302885 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002886 } else if ((eCSR_ROAM_CANCELLED == roamStatus
2887 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05302888 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002889 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05302890 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002891 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302892 GFP_KERNEL,
2893 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 }
2895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 /*
2897 * Set connection state to eConnectionState_NotConnected only
2898 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002899 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002901 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
2902 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 hdd_conn_set_connection_state(pAdapter,
2905 eConnectionState_NotConnected);
2906 }
2907 hdd_wmm_init(pAdapter);
2908
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002909 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 wlan_hdd_netif_queue_control(pAdapter,
2911 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2912 WLAN_CONTROL_PATH);
2913 }
2914
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302915 if (QDF_STATUS_SUCCESS != cds_check_and_restart_sap(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 roamResult, pHddStaCtx))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302917 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918
Govind Singh24db1ed2015-12-18 15:54:59 +05302919 if (NULL != pRoamInfo && NULL != pRoamInfo->pBssDesc) {
2920 cds_force_sap_on_scc(roamResult,
2921 pRoamInfo->pBssDesc->channelId);
2922 } else {
2923 hdd_err("pRoamInfo profile is not set properly");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302924 return QDF_STATUS_E_FAILURE;
Govind Singh24db1ed2015-12-18 15:54:59 +05302925 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302927 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928}
2929
2930/**
2931 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
2932 * @pAdapter: pointer to adapter
2933 * @pRoamInfo: pointer to roam info
2934 * @roamId: roam id
2935 * @roamStatus: roam status
2936 * @roamResult: roam result
2937 *
2938 * Here we update the status of the Ibss when we receive information that we
2939 * have started/joined an ibss session.
2940 *
2941 * Return: none
2942 */
2943static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
2944 tCsrRoamInfo *pRoamInfo,
2945 uint32_t roamId,
2946 eRoamCmdStatus roamStatus,
2947 eCsrRoamResult roamResult)
2948{
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002949 hdd_info("%s: id %d, status %d, result %d",
2950 pAdapter->dev->name, roamId,
2951 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952
2953 switch (roamResult) {
2954 /* both IBSS Started and IBSS Join should come in here. */
2955 case eCSR_ROAM_RESULT_IBSS_STARTED:
2956 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
2957 case eCSR_ROAM_RESULT_IBSS_COALESCED:
2958 {
2959 hdd_context_t *pHddCtx =
2960 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302961 hdd_station_ctx_t *hdd_sta_ctx =
2962 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302963 struct qdf_mac_addr broadcastMacAddr =
2964 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965
2966 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302967 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 return;
2969 }
2970
2971 /* When IBSS Started comes from CSR, we need to move
2972 * connection state to IBSS Disconnected (meaning no peers
2973 * are in the IBSS).
2974 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 hdd_conn_set_connection_state(pAdapter,
2976 eConnectionState_IbssDisconnected);
2977 /* notify wmm */
2978 hdd_wmm_connect(pAdapter, pRoamInfo,
2979 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302980
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07002981 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302982
2983 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002984 pAdapter;
2985 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302986 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 &broadcastMacAddr,
2988 pRoamInfo->pBssDesc);
2989
2990 if (pRoamInfo->pBssDesc) {
2991 struct cfg80211_bss *bss;
2992#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
2993 struct ieee80211_channel *chan;
2994 int chan_no;
2995 unsigned int freq;
2996#endif
2997 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002998 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
2999 pAdapter->dev->name,
3000 MAC_ADDR_ARRAY(
3001 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002
3003 /* we must first give cfg80211 the BSS information */
3004 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3005 pRoamInfo);
3006 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003007 hdd_err("%s: unable to create IBSS entry",
3008 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009 return;
3010 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003011 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 wlan_hdd_netif_queue_control(pAdapter,
3013 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3014 WLAN_CONTROL_PATH);
3015
3016#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3017 chan_no = pRoamInfo->pBssDesc->channelId;
3018
3019 if (chan_no <= 14)
3020 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003021 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022 else
3023 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003024 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025
3026 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3027
3028 if (chan)
3029 cfg80211_ibss_joined(pAdapter->dev,
3030 bss->bssid, chan,
3031 GFP_KERNEL);
3032 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003033 hdd_err("%s: chanId: %d, can't find channel",
3034 pAdapter->dev->name,
3035 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036#else
3037 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3038 GFP_KERNEL);
3039#endif
3040 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 bss);
3043 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003044 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003045 cds_incr_active_session(pAdapter->device_mode,
Krunal Soni2c68f232015-10-26 20:52:51 -07003046 pAdapter->sessionId);
3047 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3048 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003049 cds_update_connection_info(pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003050 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051 break;
3052 }
3053
3054 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3055 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003056 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 break;
3058 }
3059
3060 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003061 hdd_err("%s: unexpected result %d",
3062 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 break;
3064 }
3065
3066 return;
3067}
3068
3069/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003070 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3071 * @sta_ctx: pointer to hdd station context
3072 * @sta_id: station ID
3073 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 *
3075 * This information is passed to iwconfig later. The peer that joined
3076 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003077
3078 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003080bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3081 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003083 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003085 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3086 if (0 == sta_ctx->conn_info.staId[idx]) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003087 hdd_info("adding peer: %pM, sta_id: %d, at idx: %d",
3088 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003089 sta_ctx->conn_info.staId[idx] = sta_id;
3090 qdf_copy_macaddr(
3091 &sta_ctx->conn_info.peerMacAddress[idx],
3092 peer_mac_addr);
3093 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 }
3095 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003096 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097}
3098
3099/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003100 * hdd_delete_peer() - removes peer from hdd station context peer table
3101 * @sta_ctx: pointer to hdd station context
3102 * @sta_id: station ID
3103 *
3104 * Return: None
3105 */
3106void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3107{
3108 int i;
3109
3110 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3111 if (sta_id == sta_ctx->conn_info.staId[i]) {
3112 sta_ctx->conn_info.staId[i] = 0;
3113 return;
3114 }
3115 }
3116
3117 hdd_err(FL("sta_id %d is not present in peer table"), sta_id);
3118}
3119
3120/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3122 * @pAdapter: pointer to adapter
3123 * @staId: station id
3124 *
3125 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003126 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 * false otherwise.
3128 */
3129static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3130{
3131 bool fSuccess = false;
3132 int idx = 0;
3133 uint8_t valid_idx = 0;
3134 uint8_t del_idx = 0;
3135 uint8_t empty_slots = 0;
3136 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3137
Naveen Rawatc45d1622016-07-05 12:20:09 -07003138 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003139 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3140 pHddStaCtx->conn_info.staId[idx] = 0;
3141
Anurag Chouhanc5548422016-02-24 18:33:27 +05303142 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 peerMacAddress[idx]);
3144
3145 fSuccess = true;
3146
3147 /*
3148 * Note the deleted Index, if its 0 we need special
3149 * handling.
3150 */
3151 del_idx = idx;
3152
3153 empty_slots++;
3154 } else {
3155 if (pHddStaCtx->conn_info.staId[idx] != 0) {
3156 valid_idx = idx;
3157 } else {
3158 /* Found an empty slot */
3159 empty_slots++;
3160 }
3161 }
3162 }
3163
Naveen Rawatc45d1622016-07-05 12:20:09 -07003164 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 /* Last peer departed, set the IBSS state appropriately */
3166 pHddStaCtx->conn_info.connState =
3167 eConnectionState_IbssDisconnected;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003168 hdd_err("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 }
3170 /* Find next active staId, to have a valid sta trigger for TL. */
3171 if (fSuccess == true) {
3172 if (del_idx == 0) {
3173 if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
3174 pHddStaCtx->conn_info.staId[0] =
3175 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303176 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 peerMacAddress[0],
3178 &pHddStaCtx->conn_info.
3179 peerMacAddress[valid_idx]);
3180
3181 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303182 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 peerMacAddress[valid_idx]);
3184 }
3185 }
3186 }
3187 return fSuccess;
3188}
3189
3190/**
3191 * roam_ibss_connect_handler() - IBSS connection handler
3192 * @pAdapter: pointer to adapter
3193 * @pRoamInfo: pointer to roam info
3194 *
3195 * We update the status of the IBSS to connected in this function.
3196 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303197 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303199static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 tCsrRoamInfo *pRoamInfo)
3201{
3202 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 /*
3204 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3205 * a partner stations).
3206 */
3207 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3208
3209 /* Save the connection info from CSR... */
3210 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3211
3212 /* Send the bssid address to the wext. */
3213 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3214 /* add bss_id to cfg80211 data base */
3215 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3216 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003217 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303219 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 }
3221 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 bss);
3224
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303225 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226}
3227
3228/**
3229 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3230 * @pAdapter: pointer to adapter
3231 * @pRoamInfo: pointer to roam info
3232 * @roamId: roam id
3233 * @roamStatus: roam status
3234 * @roamResult: roam result
3235 *
3236 * This function indicates the Mic failure to the supplicant
3237 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303238 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303240static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3242 tCsrRoamInfo *pRoamInfo,
3243 uint32_t roamId,
3244 eRoamCmdStatus roamStatus,
3245 eCsrRoamResult roamResult)
3246{
3247 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3248
3249 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3250 TKIP_COUNTER_MEASURE_STOPED ==
3251 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3252 struct iw_michaelmicfailure msg;
3253 union iwreq_data wreq;
3254 memset(&msg, '\0', sizeof(msg));
3255 msg.src_addr.sa_family = ARPHRD_ETHER;
3256 memcpy(msg.src_addr.sa_data,
3257 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3258 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003259 hdd_info("MIC MAC " MAC_ADDRESS_STR,
3260 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261
3262 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3263 msg.flags = IW_MICFAILURE_GROUP;
3264 else
3265 msg.flags = IW_MICFAILURE_PAIRWISE;
3266 memset(&wreq, 0, sizeof(wreq));
3267 wreq.data.length = sizeof(msg);
3268 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3269 (char *)&msg);
3270 /* inform mic failure to nl80211 */
3271 cfg80211_michael_mic_failure(pAdapter->dev,
3272 pRoamInfo->u.pMICFailureInfo->
3273 taMacAddr,
3274 ((pRoamInfo->u.pMICFailureInfo->
3275 multicast ==
3276 eSIR_TRUE) ?
3277 NL80211_KEYTYPE_GROUP :
3278 NL80211_KEYTYPE_PAIRWISE),
3279 pRoamInfo->u.pMICFailureInfo->
3280 keyId,
3281 pRoamInfo->u.pMICFailureInfo->TSC,
3282 GFP_KERNEL);
3283
3284 }
3285
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303286 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287}
3288
3289/**
3290 * roam_roam_connect_status_update_handler() - IBSS connect status update
3291 * @pAdapter: pointer to adapter
3292 * @pRoamInfo: pointer to roam info
3293 * @roamId: roam id
3294 * @roamStatus: roam status
3295 * @roamResult: roam result
3296 *
3297 * The Ibss connection status is updated regularly here in this function.
3298 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303299 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303301static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3303 tCsrRoamInfo *pRoamInfo,
3304 uint32_t roamId,
3305 eRoamCmdStatus roamStatus,
3306 eCsrRoamResult roamResult)
3307{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303308 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311 switch (roamResult) {
3312 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3313 {
3314 hdd_station_ctx_t *pHddStaCtx =
3315 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003316 struct station_info *stainfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303318 hdd_err("IBSS New Peer indication from SME "
3319 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3320 MAC_ADDRESS_STR " and stationID= %d",
3321 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3322 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3323 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003325 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3327 pRoamInfo->staId,
3328 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003329 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 break;
3331 }
3332
3333 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3334
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303336 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 pRoamInfo,
3338 pRoamInfo->staId,
3339 &pRoamInfo->peerMac,
3340 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303341 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003342 hdd_err("Cannot register STA with TL for IBSS. Failed with qdf_status = %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303343 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 }
3345 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003346 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3347 if (stainfo == NULL) {
3348 hdd_err("memory allocation for station_info failed");
3349 return QDF_STATUS_E_NOMEM;
3350 }
3351 stainfo->filled = 0;
3352 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353
3354 cfg80211_new_sta(pAdapter->dev,
3355 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003356 stainfo, GFP_KERNEL);
3357 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358
3359 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
3360 pHddStaCtx->ibss_enc_key.encType
3361 || eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
3362 pHddStaCtx->ibss_enc_key.encType
3363 || eCSR_ENCRYPT_TYPE_TKIP ==
3364 pHddStaCtx->ibss_enc_key.encType
3365 || eCSR_ENCRYPT_TYPE_AES ==
3366 pHddStaCtx->ibss_enc_key.encType) {
3367 pHddStaCtx->ibss_enc_key.keyDirection =
3368 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303369 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 &pRoamInfo->peerMac);
3371
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003372 hdd_info("New peer joined set PTK encType=%d",
3373 pHddStaCtx->ibss_enc_key.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303375 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3377 (pAdapter),
3378 pAdapter->sessionId,
3379 &pHddStaCtx->ibss_enc_key,
3380 &roamId);
3381
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303382 if (QDF_STATUS_SUCCESS != qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003383 hdd_err("sme_roam_set_key failed, status=%d",
3384 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303385 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 }
3387 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003388 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 wlan_hdd_netif_queue_control(pAdapter,
3390 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3391 WLAN_CONTROL_PATH);
3392 break;
3393 }
3394
3395 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3396 {
3397
3398 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3399
3400 break;
3401 }
3402 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3403 {
3404 hdd_station_ctx_t *pHddStaCtx =
3405 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3406
3407 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003408 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303410 hdd_err("IBSS Peer Departed from SME "
3411 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3412 MAC_ADDRESS_STR " and stationID= %d",
3413 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3414 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3415 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416
3417 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3418
3419 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3420 pHddStaCtx->ibss_sta_generation++;
3421
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303422 qdf_status = hdd_remove_peer_object(pAdapter->hdd_vdev,
3423 pRoamInfo->peerMac.bytes);
3424 if (QDF_IS_STATUS_ERROR(qdf_status))
3425 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
3426 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 cfg80211_del_sta(pAdapter->dev,
3429 (const u8 *)&pRoamInfo->peerMac.bytes,
3430 GFP_KERNEL);
3431 break;
3432 }
3433 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3434 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003435 hdd_info("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003437 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 wlan_hdd_netif_queue_control(pAdapter,
3439 WLAN_NETIF_TX_DISABLE_N_CARRIER,
3440 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441 hdd_conn_set_connection_state(pAdapter,
3442 eConnectionState_NotConnected);
3443
3444 /* Send the bssid address to the wext. */
3445 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3446 break;
3447 }
3448 default:
3449 break;
3450
3451 }
3452
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303453 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454}
3455
3456#ifdef FEATURE_WLAN_TDLS
3457/**
3458 * hdd_roam_register_tdlssta() - register new TDLS station
3459 * @pAdapter: pointer to adapter
3460 * @peerMac: pointer to peer MAC address
3461 * @staId: station identifier
3462 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303463 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 *
3465 * Construct the staDesc and register with TL the new STA.
3466 * This is called as part of ADD_STA in the TDLS setup.
3467 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303468 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303470QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303472 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303474 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003476 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003477 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3478 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479
3480 /*
3481 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3482 * be peer MAC, here we are working on direct Link
3483 */
3484 staDesc.sta_id = staId;
3485
3486 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303487 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488
Dhanashri Atre50141c52016-04-07 13:15:29 -07003489 /* Register the vdev transmit and receive functions */
3490 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3491 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003492 cdp_vdev_register(soc,
3493 cdp_get_vdev_from_vdev_id(soc, pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003494 pAdapter, &txrx_ops);
3495 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496
3497 /* Register the Station with TL... */
Leo Changfdb45c32016-10-28 11:09:23 -07003498 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303499 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003500 hdd_err("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303501 qdf_status, qdf_status);
3502 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 }
3504
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303505 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506}
3507
3508/**
3509 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3510 * @pAdapter: pointer to adapter
3511 * @staId: station identifier
3512 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303515static QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 uint8_t staId)
3517{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303518 QDF_STATUS qdf_status;
Leo Changfdb45c32016-10-28 11:09:23 -07003519 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
3520 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303521 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003522 hdd_warn("cdp_peer_clear() failed for staID %d. Status=%d [0x%08X]",
3523 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303525 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526}
3527
3528/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003529 * hdd_tdls_connection_tracker_update() - update connection tracker state
3530 * @adapter: pointer to adapter
3531 * @roam_info: pointer to roam info
3532 * @hdd_tdls_ctx: tdls context
3533 *
3534 * Return: QDF_STATUS enumeration
3535 */
3536static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3537 tCsrRoamInfo *roam_info,
3538 tdlsCtx_t *hdd_tdls_ctx)
3539{
3540 hddTdlsPeer_t *curr_peer;
3541 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3542
3543 curr_peer = wlan_hdd_tdls_find_peer(adapter,
3544 roam_info->peerMac.bytes, true);
3545
3546 if (!curr_peer) {
3547 hdd_err("curr_peer is null");
3548 return QDF_STATUS_E_FAILURE;
3549 }
3550
3551 mutex_lock(&hdd_ctx->tdls_lock);
3552
3553 if (eTDLS_LINK_CONNECTED ==
3554 curr_peer->link_status) {
3555 hdd_err("Received CONNECTION_TRACKER_NOTIFICATION "
3556 MAC_ADDRESS_STR
3557 " staId: %d, reason: %d",
3558 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3559 roam_info->staId,
3560 roam_info->reasonCode);
3561
3562 if (roam_info->reasonCode ==
3563 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3564 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003565 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3566 roam_info->reasonCode ==
3567 eWMI_TDLS_SCAN_STARTED_EVENT)
3568 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003569 else if (roam_info->reasonCode ==
3570 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3571 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003572 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3573 roam_info->reasonCode ==
3574 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3575 hdd_ctx->enable_tdls_connection_tracker = true;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003576
3577 } else {
3578 hdd_err("TDLS not connected, ignore notification, reason: %d",
3579 roam_info->reasonCode);
3580 }
3581
3582 mutex_unlock(&hdd_ctx->tdls_lock);
3583
3584 return QDF_STATUS_SUCCESS;
3585}
3586
3587
3588
3589
3590/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3592 * @pAdapter: pointer to adapter
3593 * @pRoamInfo: pointer to roam info
3594 * @roamId: roam id
3595 * @roamStatus: roam status
3596 * @roamResult: roam result
3597 *
3598 * HDD interface between SME and TL to ensure TDLS client registration with
3599 * TL in case of new TDLS client is added and deregistration at the time
3600 * TDLS client is deleted.
3601 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303602 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303604static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3606 tCsrRoamInfo *pRoamInfo,
3607 uint32_t roamId,
3608 eRoamCmdStatus roamStatus,
3609 eCsrRoamResult roamResult)
3610{
3611 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3612 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
3613 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303614 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 uint8_t staIdx;
3616 hddTdlsPeer_t *curr_peer;
3617 uint32_t reason;
3618
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003619 hdd_info("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 roamResult ==
3621 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3622 ==
3623 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3624 roamResult ==
3625 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3626 : roamResult ==
3627 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3628 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3629 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3630 roamResult ==
3631 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3632 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3633 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3634 : roamResult ==
3635 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3636 : roamResult ==
3637 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3638 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3639 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3640
3641 if (!pHddTdlsCtx) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003642 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
3643 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 return status;
3645 }
3646
3647 switch (roamResult) {
3648 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3649 {
3650 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003651 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303653 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3654
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 } else {
3656 /*
3657 * Check if there is available index for this new TDLS
3658 * STA.
3659 */
3660 for (staIdx = 0;
3661 staIdx < pHddCtx->max_num_tdls_sta;
3662 staIdx++) {
3663 if (0 ==
3664 pHddCtx->tdlsConnInfo[staIdx].
3665 staId) {
3666 pHddCtx->tdlsConnInfo[staIdx].
3667 sessionId =
3668 pRoamInfo->sessionId;
3669 pHddCtx->tdlsConnInfo[staIdx].
3670 staId = pRoamInfo->staId;
3671
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003672 hdd_warn("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003674 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 staIdx,
3676 pHddCtx->
3677 tdlsConnInfo[staIdx].
3678 staId,
3679 MAC_ADDR_ARRAY
3680 (pRoamInfo->peerMac.bytes));
3681
Anurag Chouhanc5548422016-02-24 18:33:27 +05303682 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683 tdlsConnInfo
3684 [staIdx].
3685 peerMac,
3686 &pRoamInfo->
3687 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303688 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 break;
3690 }
3691 }
3692 if (staIdx < pHddCtx->max_num_tdls_sta) {
3693 if (-1 ==
3694 wlan_hdd_tdls_set_sta_id(pAdapter,
3695 pRoamInfo->
3696 peerMac.bytes,
3697 pRoamInfo->
3698 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003699 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303700 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 }
3702
3703 (WLAN_HDD_GET_CTX(pAdapter))->
3704 sta_to_adapter[pRoamInfo->staId] =
3705 pAdapter;
3706 /*
3707 * store the ucast signature,
3708 * if required for further reference.
3709 */
3710
3711 wlan_hdd_tdls_set_signature(pAdapter,
3712 pRoamInfo->
3713 peerMac.bytes,
3714 pRoamInfo->
3715 ucastSig);
3716 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303717 status = QDF_STATUS_E_FAILURE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003718 hdd_err("no available slot in conn_info. staId %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 pRoamInfo->staId);
3720 }
3721 pAdapter->tdlsAddStaStatus = status;
3722 }
3723 complete(&pAdapter->tdls_add_station_comp);
3724 break;
3725 }
3726 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3727 {
3728 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003729 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 pRoamInfo->statusCode);
3731 }
3732 /* store the ucast signature which will be used later when
3733 * registering to TL
3734 */
3735 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3736 complete(&pAdapter->tdls_add_station_comp);
3737 break;
3738 }
3739 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3740 {
3741 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003742 hdd_err("Link Establish Request failed. status(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 pRoamInfo->statusCode);
3744 }
3745 complete(&pAdapter->tdls_link_establish_req_comp);
3746 break;
3747 }
3748 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3749 {
3750 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3751 staIdx++) {
3752 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3753 pRoamInfo->sessionId)
3754 && pRoamInfo->staId ==
3755 pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003756 hdd_warn("HDD: del STA IDX = %x",
3757 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758
3759 curr_peer =
3760 wlan_hdd_tdls_find_peer(pAdapter,
3761 pRoamInfo->
3762 peerMac.bytes,
3763 true);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303764 if (NULL != curr_peer) {
3765 hdd_info("Current status for peer " MAC_ADDRESS_STR " is %d",
3766 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3767 curr_peer->link_status);
3768 if (TDLS_IS_CONNECTED(curr_peer)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003769 hdd_roam_deregister_tdlssta
3770 (pAdapter,
3771 pRoamInfo->staId);
3772 wlan_hdd_tdls_decrement_peer_count
3773 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303774 } else if (eTDLS_LINK_CONNECTING ==
3775 curr_peer->link_status) {
3776 hdd_roam_deregister_tdlssta
3777 (pAdapter,
3778 pRoamInfo->staId);
3779 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780 }
3781 wlan_hdd_tdls_reset_peer(pAdapter,
3782 pRoamInfo->
3783 peerMac.bytes);
3784
3785 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3786 pHddCtx->tdlsConnInfo[staIdx].
3787 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303788 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 tdlsConnInfo[staIdx].
3790 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303791 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303792 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793 break;
3794 }
3795 }
3796 complete(&pAdapter->tdls_del_station_comp);
3797 }
3798 break;
3799 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3800 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003801 hdd_err("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802 pRoamInfo->reasonCode);
3803
3804 curr_peer =
3805 wlan_hdd_tdls_find_peer(pAdapter,
3806 pRoamInfo->peerMac.bytes, true);
3807 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
3808 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303809 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3810 curr_peer->peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303811 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 break;
3813 }
3814 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3815 {
3816 /* 0 staIdx is assigned to AP we dont want to touch that */
3817 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3818 staIdx++) {
3819 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3820 pRoamInfo->sessionId)
3821 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003822 hdd_warn("hdd_tdlsStatusUpdate: staIdx %d "
3823 MAC_ADDRESS_STR,
3824 pHddCtx->tdlsConnInfo[staIdx].
3825 staId,
3826 MAC_ADDR_ARRAY(pHddCtx->
3827 tdlsConnInfo
3828 [staIdx].
3829 peerMac.
3830 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831 wlan_hdd_tdls_reset_peer(pAdapter,
3832 pHddCtx->
3833 tdlsConnInfo
3834 [staIdx].
3835 peerMac.bytes);
3836 hdd_roam_deregister_tdlssta(pAdapter,
3837 pHddCtx->
3838 tdlsConnInfo
3839 [staIdx].
3840 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303841 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003842 sizeof
3843 (smeTdlsPeerStateParams));
3844 smeTdlsPeerStateParams.vdevId =
3845 pHddCtx->tdlsConnInfo[staIdx].
3846 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303847 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848 peerMacAddr,
3849 &pHddCtx->
3850 tdlsConnInfo[staIdx].
3851 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303852 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 smeTdlsPeerStateParams.peerState =
3854 eSME_TDLS_PEER_STATE_TEARDOWN;
3855
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003856 hdd_info("calling sme_update_tdls_peer_state for staIdx %d "
3857 MAC_ADDRESS_STR,
3858 pHddCtx->tdlsConnInfo[staIdx].
3859 staId,
3860 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861 tdlsConnInfo
3862 [staIdx].
3863 peerMac.
3864 bytes));
3865 status =
3866 sme_update_tdls_peer_state(
3867 pHddCtx->hHal,
3868 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303869 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003870 hdd_err("sme_update_tdls_peer_state failed for "
3871 MAC_ADDRESS_STR,
3872 MAC_ADDR_ARRAY
3873 (pHddCtx->
3874 tdlsConnInfo[staIdx].
3875 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 }
3877 wlan_hdd_tdls_decrement_peer_count
3878 (pAdapter);
3879
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303880 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 tdlsConnInfo[staIdx].
3882 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303883 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3885 pHddCtx->tdlsConnInfo[staIdx].
3886 sessionId = 255;
3887
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303888 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 }
3890 }
3891 break;
3892 }
3893 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
3894 {
3895 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07003896 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
3897 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303898 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 break;
3900 }
3901
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07003902 if (pHddCtx->tdls_nss_switch_in_progress) {
3903 hdd_err("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
3904 status = QDF_STATUS_SUCCESS;
3905 break;
3906 }
3907
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 curr_peer =
3909 wlan_hdd_tdls_get_peer(pAdapter,
Kabilan Kannan36090ce2016-05-03 19:28:44 -07003910 pRoamInfo->peerMac.bytes,
3911 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303913 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303914 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 } else {
3916 if (eTDLS_LINK_CONNECTED ==
3917 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003918 hdd_err("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 } else {
3920 /*
3921 * If external control is enabled then initiate
3922 * TDLS only if forced peer is set otherwise
3923 * ignore should Discover trigger from fw.
3924 */
3925 if (pHddCtx->config->
3926 fTDLSExternalControl
3927 && (false ==
3928 curr_peer->isForcedPeer)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003929 hdd_info("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303930 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 break;
3932 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003933 hdd_info("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003934 pHddCtx->config->
3935 fTDLSExternalControl,
3936 curr_peer->isForcedPeer,
3937 pRoamInfo->reasonCode);
3938 }
Nitesh Shah983e8f52016-11-25 12:36:29 +05303939 pHddTdlsCtx->curr_candidate = curr_peer;
3940 wlan_hdd_tdls_implicit_send_discovery_request(
3941 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303943 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 }
3945 break;
3946 }
3947
3948 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
3949 {
3950 curr_peer =
3951 wlan_hdd_tdls_find_peer(pAdapter,
3952 pRoamInfo->peerMac.bytes, true);
3953 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303954 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303955 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003956 } else {
3957 if (eTDLS_LINK_CONNECTED ==
3958 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003959 hdd_err("Received SHOULD_TEARDOWN for peer "
3960 MAC_ADDRESS_STR
3961 " staId: %d, reason: %d",
3962 MAC_ADDR_ARRAY(pRoamInfo->
3963 peerMac.bytes),
3964 pRoamInfo->staId,
3965 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966
3967 if (pRoamInfo->reasonCode ==
3968 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
3969 pRoamInfo->reasonCode ==
3970 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
3971 pRoamInfo->reasonCode ==
3972 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
3973 pRoamInfo->reasonCode ==
3974 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
3975 reason =
3976 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
3977 } else
3978 reason =
3979 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
3980
3981 wlan_hdd_tdls_indicate_teardown
3982 (pHddTdlsCtx->pAdapter, curr_peer,
3983 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303984 hdd_send_wlan_tdls_teardown_event(
3985 eTDLS_TEARDOWN_BSS_DISCONNECT,
3986 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003988 hdd_err("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
3989 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303991 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 }
3993 break;
3994 }
3995
3996 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
3997 {
3998 curr_peer =
3999 wlan_hdd_tdls_find_peer(pAdapter,
4000 pRoamInfo->peerMac.bytes, true);
4001 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05304002 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304003 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004004 } else {
4005 if (eTDLS_LINK_CONNECTED ==
4006 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004007 hdd_err("Received SHOULD_PEER_DISCONNECTED for peer "
4008 MAC_ADDRESS_STR
4009 " staId: %d, reason: %d",
4010 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4011 pRoamInfo->staId,
4012 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013
4014 if (pRoamInfo->reasonCode ==
4015 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4016 pRoamInfo->reasonCode ==
4017 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4018 pRoamInfo->reasonCode ==
4019 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4020 pRoamInfo->reasonCode ==
4021 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4022 reason =
4023 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4024 } else
4025 reason =
4026 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4027
4028 wlan_hdd_tdls_indicate_teardown
4029 (pHddTdlsCtx->pAdapter, curr_peer,
4030 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304031 hdd_send_wlan_tdls_teardown_event(
4032 eTDLS_TEARDOWN_BSS_DISCONNECT,
4033 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004035 hdd_err("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
4036 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304038 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 }
4040 break;
4041 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004042
4043 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
4044 status = hdd_tdls_connection_tracker_update(pAdapter,
4045 pRoamInfo,
4046 pHddTdlsCtx);
4047 break;
4048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 default:
4050 {
4051 break;
4052 }
4053 }
4054
4055 return status;
4056}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004057#else
4058
4059static inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
4060 uint8_t staId)
4061{
4062 return QDF_STATUS_SUCCESS;
4063}
4064
4065static inline QDF_STATUS
4066hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4067 tCsrRoamInfo *pRoamInfo,
4068 uint32_t roamId,
4069 eRoamCmdStatus roamStatus,
4070 eCsrRoamResult roamResult)
4071{
4072 return QDF_STATUS_SUCCESS;
4073}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074#endif
4075
4076#ifdef WLAN_FEATURE_11W
4077/**
4078 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4079 * @pAdapter: pointer to the adapter
4080 * @nFrameLength: Length of the unprotected frame being passed
4081 * @pbFrames: Pointer to the frame buffer
4082 * @frameType: 802.11 frame type
4083 *
4084 * This function forwards the unprotected management frame to the supplicant.
4085 *
4086 * Return: nothing
4087 */
4088static void
4089hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4090 uint8_t *pbFrames, uint8_t frameType)
4091{
4092 uint8_t type = 0;
4093 uint8_t subType = 0;
4094
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004095 hdd_info("Frame Type = %d Frame Length = %d",
4096 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097
4098 /* Sanity Checks */
4099 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004100 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 return;
4102 }
4103
4104 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004105 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 return;
4107 }
4108
4109 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004110 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 return;
4112 }
4113
4114 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004115 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 return;
4117 }
4118
4119 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004120 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 return;
4122 }
4123
4124 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4125 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4126
4127 /* Get pAdapter from Destination mac address of the frame */
4128 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4129#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4130 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4131 nFrameLength);
4132#else
4133 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4134 nFrameLength);
4135#endif
4136 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4137 } else if (type == SIR_MAC_MGMT_FRAME &&
4138 subType == SIR_MAC_MGMT_DEAUTH) {
4139#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4140 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4141 nFrameLength);
4142#else
4143 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4144 nFrameLength);
4145#endif
4146 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4147 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004148 hdd_err("Frame type %d and subtype %d are not valid",
4149 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150 return;
4151 }
4152}
4153#endif
4154
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004155#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156/**
4157 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4158 * @pAdapter: pointer to adapter
4159 * @tid: traffic identifier
4160 * @state: state
4161 * @measInterval: measurement interval
4162 *
4163 * This function sends traffic stream metrics IE information to
4164 * the supplicant via wireless event.
4165 *
4166 * Return: none
4167 */
4168static void
4169hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4170 uint8_t state, uint16_t measInterval)
4171{
4172 union iwreq_data wrqu;
4173 char buf[IW_CUSTOM_MAX + 1];
4174 int nBytes = 0;
4175
4176 if (NULL == pAdapter)
4177 return;
4178
4179 /* create the event */
4180 memset(&wrqu, '\0', sizeof(wrqu));
4181 memset(buf, '\0', sizeof(buf));
4182
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004183 hdd_info("TSM Ind tid(%d) state(%d) MeasInt(%d)",
4184 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185
4186 nBytes =
4187 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4188 measInterval);
4189
4190 wrqu.data.pointer = buf;
4191 wrqu.data.length = nBytes;
4192 /* send the event */
4193 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4194}
4195
4196/**
4197 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4198 * @pAdapter: pointer to adapter
4199 * @pRoamInfo: pointer to roam info
4200 *
4201 * This function sends cckm preauth indication to the supplicant
4202 * via wireless custom event.
4203 *
4204 * Return: none
4205 */
4206static void
4207hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4208{
4209 union iwreq_data wrqu;
4210 char buf[IW_CUSTOM_MAX + 1];
4211 char *pos = buf;
4212 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4213
4214 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4215 return;
4216
4217 /* create the event */
4218 memset(&wrqu, '\0', sizeof(wrqu));
4219 memset(buf, '\0', sizeof(buf));
4220
4221 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004222 hdd_info("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
4223 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4224 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225
4226 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4227 pos += nBytes;
4228 freeBytes -= nBytes;
4229
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304230 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304231 pos += QDF_MAC_ADDR_SIZE;
4232 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233
4234 nBytes = snprintf(pos, freeBytes, " %u:%u",
4235 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4236 freeBytes -= nBytes;
4237
4238 wrqu.data.pointer = buf;
4239 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4240
4241 /* send the event */
4242 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4243}
4244
4245/**
4246 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4247 * @pAdapter: pointer to adapter
4248 * @pRoamInfo: pointer to roam info
4249 *
4250 * Return: none
4251 */
4252static void
4253hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4254 tCsrRoamInfo *pRoamInfo)
4255{
4256 union iwreq_data wrqu;
4257 char buf[IW_CUSTOM_MAX + 1];
4258 int nBytes = 0;
4259
4260 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4261 return;
4262
4263 /* create the event */
4264 memset(&wrqu, '\0', sizeof(wrqu));
4265 memset(buf, '\0', sizeof(buf));
4266
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004267 hdd_info("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268
4269 nBytes =
4270 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4271 pRoamInfo->tsmRoamDelay);
4272
4273 wrqu.data.pointer = buf;
4274 wrqu.data.length = nBytes;
4275
4276 /* send the event */
4277 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4278}
4279
4280/**
4281 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4282 * @pAdapter: pointer to adapter
4283 * @measurementToken: measurement token
4284 * @flag: flag
4285 * @numBss: number of bss
4286 *
4287 * If the measurement is none and no scan results found,
4288 * indicate the supplicant about measurement done.
4289 *
4290 * Return: none
4291 */
4292void
4293hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4294 const uint16_t measurementToken,
4295 const bool flag, const uint8_t numBss)
4296{
4297 union iwreq_data wrqu;
4298 char buf[IW_CUSTOM_MAX];
4299 char *pos = buf;
4300 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4301
4302 memset(&wrqu, '\0', sizeof(wrqu));
4303 memset(buf, '\0', sizeof(buf));
4304
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004305 hdd_info("CCXBCNREP=%d %d %d", measurementToken,
4306 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307
4308 nBytes =
4309 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4310 flag, numBss);
4311
4312 wrqu.data.pointer = buf;
4313 wrqu.data.length = nBytes;
4314 /* send the event */
4315 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4316}
4317
4318/**
4319 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4320 * @pAdapter: pointer to adapter
4321 * @pRoamInfo: pointer to roam info
4322 *
4323 * If the measurement is none and no scan results found,
4324 * indicate the supplicant about measurement done.
4325 *
4326 * Return: none
4327 */
4328static void
4329hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4330 const tCsrRoamInfo *pRoamInfo)
4331{
4332 union iwreq_data wrqu;
4333 char buf[IW_CUSTOM_MAX];
4334 char *pos = buf;
4335 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4336 uint8_t i = 0, len = 0;
4337 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4338 uint8_t lastSent = 0, sendBss = 0;
4339 int bcnRepFieldSize =
4340 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4341 bcnReportFields);
4342 uint8_t ieLenByte = 1;
4343 /*
4344 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4345 */
4346#define ESEBCNREPHEADER_LEN (18)
4347
4348 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4349 return;
4350
4351 /*
4352 * Custom event can pass maximum of 256 bytes of data,
4353 * based on the IE len we need to identify how many BSS info can
4354 * be filled in to custom event data.
4355 */
4356 /*
4357 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4358 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4359 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4360 */
4361
4362 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4363 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004364 hdd_info("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 /* If the measurement is none and no scan results found,
4366 indicate the supplicant about measurement done */
4367 hdd_indicate_ese_bcn_report_no_results(
4368 pAdapter,
4369 pRoamInfo->pEseBcnReportRsp->
4370 measurementToken,
4371 pRoamInfo->pEseBcnReportRsp->flag,
4372 pRoamInfo->pEseBcnReportRsp->numBss);
4373 } else {
4374 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4375 memset(&wrqu, '\0', sizeof(wrqu));
4376 memset(buf, '\0', sizeof(buf));
4377 tot_bcn_ieLen = 0;
4378 sendBss = 0;
4379 pos = buf;
4380 freeBytes = IW_CUSTOM_MAX;
4381
4382 for (i = lastSent;
4383 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4384 len =
4385 bcnRepFieldSize + ieLenByte +
4386 pRoamInfo->pEseBcnReportRsp->
4387 bcnRepBssInfo[i].ieLen;
4388 if ((len + tot_bcn_ieLen) >
4389 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4390 break;
4391 }
4392 tot_bcn_ieLen += len;
4393 sendBss++;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004394 hdd_info("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
4395 i, bcnRepFieldSize, 1,
4396 pRoamInfo->pEseBcnReportRsp->
4397 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 }
4399
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004400 hdd_info("Sending %d BSS Info", sendBss);
4401 hdd_info("CCXBCNREP=%d %d %d %d",
4402 pRoamInfo->pEseBcnReportRsp->measurementToken,
4403 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4404 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405
4406 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4407 pRoamInfo->pEseBcnReportRsp->
4408 measurementToken,
4409 pRoamInfo->pEseBcnReportRsp->flag,
4410 sendBss);
4411 pos += nBytes;
4412 freeBytes -= nBytes;
4413
4414 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304415 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 sizeof(tot_bcn_ieLen));
4417 pos += sizeof(tot_bcn_ieLen);
4418 freeBytes -= sizeof(tot_bcn_ieLen);
4419
4420 for (i = 0; i < sendBss; i++) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004421 hdd_info("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4423 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4424 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4425 pRoamInfo->pEseBcnReportRsp->
4426 bcnRepBssInfo[i +
4427 lastSent].bcnReportFields.
4428 ChanNum,
4429 pRoamInfo->pEseBcnReportRsp->
4430 bcnRepBssInfo[i +
4431 lastSent].bcnReportFields.
4432 Spare,
4433 pRoamInfo->pEseBcnReportRsp->
4434 bcnRepBssInfo[i +
4435 lastSent].bcnReportFields.
4436 MeasDuration,
4437 pRoamInfo->pEseBcnReportRsp->
4438 bcnRepBssInfo[i +
4439 lastSent].bcnReportFields.
4440 PhyType,
4441 pRoamInfo->pEseBcnReportRsp->
4442 bcnRepBssInfo[i +
4443 lastSent].bcnReportFields.
4444 RecvSigPower,
4445 pRoamInfo->pEseBcnReportRsp->
4446 bcnRepBssInfo[i +
4447 lastSent].bcnReportFields.
4448 ParentTsf,
4449 pRoamInfo->pEseBcnReportRsp->
4450 bcnRepBssInfo[i +
4451 lastSent].bcnReportFields.
4452 TargetTsf[0],
4453 pRoamInfo->pEseBcnReportRsp->
4454 bcnRepBssInfo[i +
4455 lastSent].bcnReportFields.
4456 TargetTsf[1],
4457 pRoamInfo->pEseBcnReportRsp->
4458 bcnRepBssInfo[i +
4459 lastSent].bcnReportFields.
4460 BcnInterval,
4461 pRoamInfo->pEseBcnReportRsp->
4462 bcnRepBssInfo[i +
4463 lastSent].bcnReportFields.
4464 CapabilityInfo,
4465 pRoamInfo->pEseBcnReportRsp->
4466 bcnRepBssInfo[i +
4467 lastSent].bcnReportFields.
4468 Bssid[0],
4469 pRoamInfo->pEseBcnReportRsp->
4470 bcnRepBssInfo[i +
4471 lastSent].bcnReportFields.
4472 Bssid[1],
4473 pRoamInfo->pEseBcnReportRsp->
4474 bcnRepBssInfo[i +
4475 lastSent].bcnReportFields.
4476 Bssid[2],
4477 pRoamInfo->pEseBcnReportRsp->
4478 bcnRepBssInfo[i +
4479 lastSent].bcnReportFields.
4480 Bssid[3],
4481 pRoamInfo->pEseBcnReportRsp->
4482 bcnRepBssInfo[i +
4483 lastSent].bcnReportFields.
4484 Bssid[4],
4485 pRoamInfo->pEseBcnReportRsp->
4486 bcnRepBssInfo[i +
4487 lastSent].bcnReportFields.
4488 Bssid[5]);
4489
4490 /* bcn report fields are copied */
4491 len =
4492 sizeof(pRoamInfo->pEseBcnReportRsp->
4493 bcnRepBssInfo[i +
4494 lastSent].
4495 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304496 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 (char *)&pRoamInfo->
4498 pEseBcnReportRsp->bcnRepBssInfo[i +
4499 lastSent].
4500 bcnReportFields, len);
4501 pos += len;
4502 freeBytes -= len;
4503
4504 /* Add 1 byte of ie len */
4505 len =
4506 pRoamInfo->pEseBcnReportRsp->
4507 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304508 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 pos += sizeof(len);
4510 freeBytes -= sizeof(len);
4511
4512 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304513 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 (char *)pRoamInfo->
4515 pEseBcnReportRsp->bcnRepBssInfo[i +
4516 lastSent].
4517 pBuf, len);
4518 pos += len;
4519 freeBytes -= len;
4520 }
4521
4522 wrqu.data.pointer = buf;
4523 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4524
4525 /* send the event */
4526 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4527 buf);
4528 lastSent += sendBss;
4529 }
4530 }
4531}
4532
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004533#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534
4535/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304536 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4537 * @pHddStaCtx: Station Context
4538 *
4539 * API to check if the connection authentication type is 8021x_sha256.
4540 *
4541 * Return: bool
4542 */
4543#ifdef WLAN_FEATURE_11W
4544static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4545{
4546 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4547 pHddStaCtx->conn_info.authType;
4548}
4549#else
4550static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4551{
4552 return false;
4553}
4554#endif
4555
4556/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 * hdd_sme_roam_callback() - hdd sme roam callback
4558 * @pContext: pointer to adapter context
4559 * @pRoamInfo: pointer to roam info
4560 * @roamId: roam id
4561 * @roamStatus: roam status
4562 * @roamResult: roam result
4563 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304564 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304566QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4568 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4569{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304570 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4572 hdd_wext_state_t *pWextState = NULL;
4573 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304574 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 hdd_context_t *pHddCtx = NULL;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05304576 struct hdd_chan_change_params chan_change;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304577 struct cfg80211_bss *bss_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004579 hdd_info("CSR Callback: status= %d result= %d roamID=%d",
4580 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581
4582 /* Sanity check */
4583 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004584 hdd_alert("invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304585 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 }
4587
4588 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4589 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4590
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304591 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304592 pAdapter->sessionId, roamStatus));
4593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 switch (roamStatus) {
4595 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304596 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4597 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004598 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 break;
4600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 /*
4602 * We did pre-auth,then we attempted a 11r or ese reassoc.
4603 * reassoc failed due to failure, timeout, reject from ap
4604 * in any case tell the OS, our carrier is off and mark
4605 * interface down.
4606 */
4607 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004608 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4609 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304610 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4612 roamStatus, roamResult);
4613 /*
4614 * Check if Mcast/Bcast Filters are set, if yes
4615 * clear the filters here.
4616 */
4617 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set ==
4618 true) {
4619 (WLAN_HDD_GET_CTX(pAdapter))->
4620 hdd_mcastbcast_filter_set = false;
4621 }
4622 pHddStaCtx->ft_carrier_on = false;
4623 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004624 hdd_info("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
4625 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 break;
4627
4628 case eCSR_ROAM_FT_START:
4629 /*
4630 * When we roam for ESE and 11r, we dont want the OS to be
4631 * informed that the link is down. So mark the link ready for
4632 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4633 * be received. Where in we will not mark the link down
4634 * Also we want to stop tx at this point when we will be
4635 * doing disassoc at this time. This saves 30-60 msec
4636 * after reassoc.
4637 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004638 hdd_info("Disabling queues");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004639 hdd_info("Roam Synch Ind: NAPI Serialize ON");
4640 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004641 wlan_hdd_netif_queue_control(pAdapter,
4642 WLAN_NETIF_TX_DISABLE,
4643 WLAN_CONTROL_PATH);
4644 status = hdd_roam_deregister_sta(pAdapter,
4645 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304646 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304647 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 pHddStaCtx->ft_carrier_on = true;
4649 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004650 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4651 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004653 case eCSR_ROAM_NAPI_OFF:
4654 hdd_info("After Roam Synch Comp: NAPI Serialize OFF");
4655 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004656 hdd_set_roaming_in_progress(false);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004657 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004660 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661 wlan_hdd_netif_queue_control(pAdapter,
4662 WLAN_NETIF_TX_DISABLE,
4663 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 wlan_hdd_netif_queue_control(pAdapter,
4666 WLAN_NETIF_CARRIER_OFF,
4667 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 break;
4670 case eCSR_ROAM_LOSTLINK:
4671 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004672 hdd_info("Roaming started due to connection lost");
4673 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 wlan_hdd_netif_queue_control(pAdapter,
4675 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4676 WLAN_CONTROL_PATH);
4677 break;
4678 }
4679 case eCSR_ROAM_DISASSOCIATED:
4680 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004681 hdd_info("****eCSR_ROAM_DISASSOCIATED****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304682 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004683 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4684 roamStatus, roamResult);
4685 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4686 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4687 if (pHddCtx->hdd_mcastbcast_filter_set == true) {
4688 hdd_conf_mcastbcast_filter(pHddCtx, false);
4689
4690 if (true ==
4691 pHddCtx->sus_res_mcastbcast_filter_valid) {
4692 pHddCtx->configuredMcastBcastFilter =
4693 pHddCtx->sus_res_mcastbcast_filter;
4694 pHddCtx->
4695 sus_res_mcastbcast_filter_valid =
4696 false;
4697 }
4698
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004699 hdd_info("offload: disassociation happening, restoring configuredMcastBcastFilter");
4700 hdd_info("McastBcastFilter = %d",
4701 pHddCtx->configuredMcastBcastFilter);
4702 hdd_info("offload: already called mcastbcast filter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 (WLAN_HDD_GET_CTX(pAdapter))->
4704 hdd_mcastbcast_filter_set = false;
4705 }
4706 /* Call to clear any MC Addr List filter applied after
4707 * successful connection.
4708 */
4709 wlan_hdd_set_mc_addr_list(pAdapter, false);
4710 }
4711 break;
4712 case eCSR_ROAM_IBSS_LEAVE:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004713 hdd_info("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304714 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4716 roamStatus, roamResult);
4717 break;
4718 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004719 hdd_info("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720 /*
4721 * To Do - address probable memory leak with WEP encryption upon
4722 * successful association.
4723 */
4724 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4725 /* Clear saved connection information in HDD */
4726 hdd_conn_remove_connect_info(
4727 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4728 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304729 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004730 hdd_association_completion_handler(pAdapter, pRoamInfo,
4731 roamId, roamStatus,
4732 roamResult);
4733#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4734 if (pRoamInfo)
4735 pRoamInfo->roamSynchInProgress = false;
4736#endif
4737 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004738 case eCSR_ROAM_CANCELLED:
4739 hdd_info("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004740 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304741 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 pRoamInfo,
4743 roamId,
4744 roamStatus,
4745 roamResult);
4746 break;
4747 case eCSR_ROAM_IBSS_IND:
4748 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4749 roamStatus, roamResult);
4750 break;
4751
4752 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304753 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 roam_roam_connect_status_update_handler(pAdapter,
4755 pRoamInfo,
4756 roamId,
4757 roamStatus,
4758 roamResult);
4759 break;
4760
4761 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304762 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 hdd_roam_mic_error_indication_handler(pAdapter,
4764 pRoamInfo,
4765 roamId,
4766 roamStatus,
4767 roamResult);
4768 break;
4769
4770 case eCSR_ROAM_SET_KEY_COMPLETE:
4771 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304772 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4774 roamId, roamStatus,
4775 roamResult);
4776 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4777 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004778 hdd_info("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 pHddStaCtx->hdd_ReassocScenario,
4780 pAdapter->sessionId);
4781 }
4782 }
4783#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4784 if (pRoamInfo != NULL)
4785 pRoamInfo->roamSynchInProgress = false;
4786#endif
4787 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004788
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 case eCSR_ROAM_FT_RESPONSE:
4790 hdd_send_ft_event(pAdapter);
4791 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304794 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4795 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304797 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798 wlan_hdd_cfg80211_pmksa_candidate_notify(
4799 pAdapter, pRoamInfo, 1, false);
4800 }
4801 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802
4803#ifdef FEATURE_WLAN_LFR_METRICS
4804 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4805 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304806 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4808 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304809 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 }
4811 break;
4812 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4813 /*
4814 * This event will notify pre-auth completion in case of success
4815 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304816 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4818 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304819 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 }
4821 break;
4822 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4823 /*
4824 * This event will notify pre-auth completion incase of failure.
4825 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304826 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4828 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304829 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830 }
4831 break;
4832 case eCSR_ROAM_HANDOVER_SUCCESS:
4833 /* This event is to notify handover success.
4834 It will be only invoked on success */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304835 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4837 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304838 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 }
4840 break;
4841#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 case eCSR_ROAM_REMAIN_CHAN_READY:
4843 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4844 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845#ifdef FEATURE_WLAN_TDLS
4846 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304847 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4849 roamId,
4850 roamStatus,
4851 roamResult);
4852 break;
4853 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4854 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4855 pRoamInfo->reasonCode);
4856 break;
4857#endif
4858#ifdef WLAN_FEATURE_11W
4859 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4860 hdd_indicate_unprot_mgmt_frame(pAdapter,
4861 pRoamInfo->nFrameLength,
4862 pRoamInfo->pbFrames,
4863 pRoamInfo->frameType);
4864 break;
4865#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004866#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004867 case eCSR_ROAM_TSM_IE_IND:
4868 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
4869 pRoamInfo->tsmIe.state,
4870 pRoamInfo->tsmIe.msmt_interval);
4871 break;
4872
4873 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4874 {
4875 if (eCSR_AUTH_TYPE_CCKM_WPA ==
4876 pHddStaCtx->conn_info.authType
4877 || eCSR_AUTH_TYPE_CCKM_RSN ==
4878 pHddStaCtx->conn_info.authType) {
4879 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
4880 }
4881 break;
4882 }
4883
4884 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4885 {
4886 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
4887 break;
4888 }
4889
4890 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4891 {
4892 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
4893 break;
4894 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004895#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304896 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4897 hdd_info("channel switch for session:%d to channel:%d",
4898 pAdapter->sessionId, pRoamInfo->chan_info.chan_id);
4899
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05304900 chan_change.chan = pRoamInfo->chan_info.chan_id;
4901 chan_change.chan_params.ch_width =
4902 pRoamInfo->chan_info.ch_width;
4903 chan_change.chan_params.sec_ch_offset =
4904 pRoamInfo->chan_info.sec_ch_offset;
4905 chan_change.chan_params.center_freq_seg0 =
4906 pRoamInfo->chan_info.band_center_freq1;
4907 chan_change.chan_params.center_freq_seg1 =
4908 pRoamInfo->chan_info.band_center_freq2;
4909
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304910 status = hdd_chan_change_notify(pAdapter, pAdapter->dev,
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05304911 chan_change);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304912 if (QDF_IS_STATUS_ERROR(status))
4913 hdd_err("channel change notification failed");
4914
4915 status = cds_set_hw_mode_on_channel_switch(pAdapter->sessionId);
4916 if (QDF_IS_STATUS_ERROR(status))
4917 hdd_info("set hw mode change not done");
4918 break;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304919 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4920 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
4921 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
4922 pAdapter, pRoamInfo->pBssDesc);
4923 if (NULL == bss_status)
4924 hdd_info("UPDATE_SCAN_RESULT returned NULL");
4925 else
4926 cfg80211_put_bss(
4927#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4928 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4929#endif
4930 bss_status);
4931 }
4932 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004933 case eCSR_ROAM_NDP_STATUS_UPDATE:
4934 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
4935 roamResult);
4936 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004937 case eCSR_ROAM_START:
4938 hdd_info("Process ROAM_START from firmware");
4939 wlan_hdd_netif_queue_control(pAdapter,
4940 WLAN_NETIF_TX_DISABLE,
4941 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004942 hdd_napi_serialize(1);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004943 cds_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004944 hdd_set_roaming_in_progress(true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004945 cds_restart_opportunistic_timer(true);
4946 break;
4947 case eCSR_ROAM_ABORT:
4948 hdd_info("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004949 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004950 wlan_hdd_netif_queue_control(pAdapter,
4951 WLAN_WAKE_ALL_NETIF_QUEUE,
4952 WLAN_CONTROL_PATH);
4953 cds_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004954 hdd_set_roaming_in_progress(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004955 break;
4956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 default:
4958 break;
4959 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304960 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961}
4962
4963/**
4964 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4965 * @auth_suite: auth suite
4966 *
4967 * Return: eCsrAuthType enumeration
4968 */
4969eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4970{
4971 eCsrAuthType auth_type;
4972 /* is the auth type supported? */
4973 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4974 auth_type = eCSR_AUTH_TYPE_RSN;
4975 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
4976 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004977 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978 /* Check for 11r FT Authentication with PSK */
4979 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
4980 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
4981 /* Check for 11R FT Authentication with 802.1X */
4982 auth_type = eCSR_AUTH_TYPE_FT_RSN;
4983 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984#ifdef FEATURE_WLAN_ESE
4985 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
4986 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4987 } else
4988#endif /* FEATURE_WLAN_ESE */
4989#ifdef WLAN_FEATURE_11W
4990 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
4991 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4992 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
4993 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4994 } else
4995#endif
4996 {
4997 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4998 }
4999 return auth_type;
5000}
5001
5002/**
5003 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5004 * @auth_suite: auth suite
5005 *
5006 * Return: eCsrAuthType enumeration
5007 */
5008eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5009{
5010 eCsrAuthType auth_type;
5011 /* is the auth type supported? */
5012 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5013 auth_type = eCSR_AUTH_TYPE_WPA;
5014 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5015 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5016 } else
5017#ifdef FEATURE_WLAN_ESE
5018 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5019 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5020 } else
5021#endif /* FEATURE_WLAN_ESE */
5022 {
5023 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5024 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005025 hdd_info("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005026 return auth_type;
5027}
5028
5029/**
5030 * hdd_translate_rsn_to_csr_encryption_type() -
5031 * Translate RSN to CSR encryption type
5032 * @cipher_suite: cipher suite
5033 *
5034 * Return: eCsrEncryptionType enumeration
5035 */
5036eCsrEncryptionType
5037hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5038{
5039 eCsrEncryptionType cipher_type;
5040
5041 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5042 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5043 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5044 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5045 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5046 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5047 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5048 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5049 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5050 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5051 else
5052 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5053
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005054 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055 return cipher_type;
5056}
5057
5058/**
5059 * hdd_translate_wpa_to_csr_encryption_type() -
5060 * Translate WPA to CSR encryption type
5061 * @cipher_suite: cipher suite
5062 *
5063 * Return: eCsrEncryptionType enumeration
5064 */
5065eCsrEncryptionType
5066hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5067{
5068 eCsrEncryptionType cipher_type;
5069
5070 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5071 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5072 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5073 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5074 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5075 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5076 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5077 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5078 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5079 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5080 else
5081 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5082
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005083 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 return cipher_type;
5085}
5086
5087/**
5088 * hdd_process_genie() - process gen ie
5089 * @pAdapter: pointer to adapter
5090 * @bssid: pointer to mac address
5091 * @pEncryptType: pointer to encryption type
5092 * @mcEncryptType: pointer to multicast encryption type
5093 * @pAuthType: pointer to auth type
5094 *
5095 * Return: 0 on success, error number otherwise
5096 */
5097static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5098 u8 *bssid,
5099 eCsrEncryptionType *pEncryptType,
5100 eCsrEncryptionType *mcEncryptType,
5101 eCsrAuthType *pAuthType,
5102#ifdef WLAN_FEATURE_11W
5103 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5104#endif
5105 uint16_t gen_ie_len, uint8_t *gen_ie)
5106{
5107 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305108 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 tDot11fIERSN dot11RSNIE;
5110 tDot11fIEWPA dot11WPAIE;
5111 uint32_t i;
5112 uint8_t *pRsnIe;
5113 uint16_t RSNIeLen;
5114 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5115 bool updatePMKCache = false;
5116
5117 /*
5118 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5119 * setting present flag to 0.
5120 */
5121 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5122 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5123
5124 /* Type check */
5125 if (gen_ie[0] == DOT11F_EID_RSN) {
5126 /* Validity checks */
5127 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5128 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005129 hdd_err("Invalid DOT11F RSN IE length :%d",
5130 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131 return -EINVAL;
5132 }
5133 /* Skip past the EID byte and length byte */
5134 pRsnIe = gen_ie + 2;
5135 RSNIeLen = gen_ie_len - 2;
5136 /* Unpack the RSN IE */
5137 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
5138 pRsnIe, RSNIeLen, &dot11RSNIE);
5139 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005140 hdd_info("pairwise cipher suite count: %d",
5141 dot11RSNIE.pwise_cipher_suite_count);
5142 hdd_info("authentication suite count: %d",
5143 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 /*Here we have followed the apple base code,
5145 but probably I suspect we can do something different */
5146 /* dot11RSNIE.akm_suite_count */
5147 /* Just translate the FIRST one */
5148 *pAuthType =
5149 hdd_translate_rsn_to_csr_auth_type(
5150 dot11RSNIE.akm_suites[0]);
5151 /* dot11RSNIE.pwise_cipher_suite_count */
5152 *pEncryptType =
5153 hdd_translate_rsn_to_csr_encryption_type(
5154 dot11RSNIE.pwise_cipher_suites[0]);
5155 /* dot11RSNIE.gp_cipher_suite_count */
5156 *mcEncryptType =
5157 hdd_translate_rsn_to_csr_encryption_type(
5158 dot11RSNIE.gp_cipher_suite);
5159#ifdef WLAN_FEATURE_11W
5160 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5161 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5162#endif
5163 /* Set the PMKSA ID Cache for this interface */
5164 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5165 if (is_zero_ether_addr(bssid)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005166 hdd_err("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 break;
5168 }
5169 updatePMKCache = true;
5170 /*
5171 * For right now, I assume setASSOCIATE() has passed
5172 * in the bssid.
5173 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305174 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305175 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305176 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5178 }
5179
5180 if (updatePMKCache) {
5181 /*
5182 * Calling csr_roam_set_pmkid_cache to configure the
5183 * PMKIDs into the cache.
5184 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005185 hdd_info("Calling sme_roam_set_pmkid_cache with cache entry %d.",
5186 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005187 /* Finally set the PMKSA ID Cache in CSR */
5188 result =
5189 sme_roam_set_pmkid_cache(halHandle,
5190 pAdapter->sessionId,
5191 PMKIDCache,
5192 dot11RSNIE.pmkid_count,
5193 false);
5194 }
5195 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5196 /* Validity checks */
5197 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5198 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005199 hdd_err("Invalid DOT11F WPA IE length :%d",
5200 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 return -EINVAL;
5202 }
5203 /* Skip past the EID and length byte - and four byte WiFi OUI */
5204 pRsnIe = gen_ie + 2 + 4;
5205 RSNIeLen = gen_ie_len - (2 + 4);
5206 /* Unpack the WPA IE */
5207 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
5208 pRsnIe, RSNIeLen, &dot11WPAIE);
5209 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005210 hdd_info("WPA unicast cipher suite count: %d",
5211 dot11WPAIE.unicast_cipher_count);
5212 hdd_info("WPA authentication suite count: %d",
5213 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005214 /* dot11WPAIE.auth_suite_count */
5215 /* Just translate the FIRST one */
5216 *pAuthType =
5217 hdd_translate_wpa_to_csr_auth_type(
5218 dot11WPAIE.auth_suites[0]);
5219 /* dot11WPAIE.unicast_cipher_count */
5220 *pEncryptType =
5221 hdd_translate_wpa_to_csr_encryption_type(
5222 dot11WPAIE.unicast_ciphers[0]);
5223 /* dot11WPAIE.unicast_cipher_count */
5224 *mcEncryptType =
5225 hdd_translate_wpa_to_csr_encryption_type(
5226 dot11WPAIE.multicast_cipher);
5227 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005228 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 return -EINVAL;
5230 }
5231 return 0;
5232}
5233
5234/**
5235 * hdd_set_genie_to_csr() - set genie to csr
5236 * @pAdapter: pointer to adapter
5237 * @RSNAuthType: pointer to auth type
5238 *
5239 * Return: 0 on success, error number otherwise
5240 */
5241int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5242{
5243 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5244 uint32_t status = 0;
5245 eCsrEncryptionType RSNEncryptType;
5246 eCsrEncryptionType mcRSNEncryptType;
5247#ifdef WLAN_FEATURE_11W
5248 uint8_t RSNMfpRequired = 0;
5249 uint8_t RSNMfpCapable = 0;
5250#endif
5251 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5252 /* MAC address of assoc peer */
5253 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305254 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 pWextState->roamProfile.BSSIDs.bssid,
5256 sizeof(bssid));
5257 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5258 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5259 /* continue */
5260 } else {
5261 return 0;
5262 }
5263 /* The actual processing may eventually be more extensive than this. */
5264 /* Right now, just consume any PMKIDs that are sent in by the app. */
5265 status = hdd_process_genie(pAdapter, bssid,
5266 &RSNEncryptType,
5267 &mcRSNEncryptType, RSNAuthType,
5268#ifdef WLAN_FEATURE_11W
5269 &RSNMfpRequired, &RSNMfpCapable,
5270#endif
5271 pWextState->WPARSNIE[1] + 2,
5272 pWextState->WPARSNIE);
5273 if (status == 0) {
5274 /*
5275 * Now copy over all the security attributes
5276 * you have parsed out.
5277 */
5278 pWextState->roamProfile.EncryptionType.numEntries = 1;
5279 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5280
5281 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5282 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5283 mcRSNEncryptType;
5284
Krunal Sonibe766b02016-03-10 13:00:44 -08005285 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5287 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5288 /*
5289 * For wpa none supplicant sends the WPA IE with unicast
5290 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5291 * multicast cipher as either AES/TKIP based on group
5292 * cipher configuration mentioned in the
5293 * wpa_supplicant.conf.
5294 */
5295
5296 /* Set the unicast cipher same as multicast cipher */
5297 pWextState->roamProfile.EncryptionType.encryptionType[0]
5298 = mcRSNEncryptType;
5299 }
5300#ifdef WLAN_FEATURE_11W
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005301 hdd_info("RSNMfpRequired = %d, RSNMfpCapable = %d",
5302 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5304 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5305#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005306 hdd_info("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
5307 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 }
5309 return 0;
5310}
5311
5312/**
5313 * hdd_set_csr_auth_type() - set csr auth type
5314 * @pAdapter: pointer to adapter
5315 * @RSNAuthType: auth type
5316 *
5317 * Return: 0 on success, error number otherwise
5318 */
5319int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5320{
5321 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5322 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5323 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324
5325 pRoamProfile->AuthType.numEntries = 1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005326 hdd_info("pHddStaCtx->conn_info.authType = %d",
5327 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328
5329 switch (pHddStaCtx->conn_info.authType) {
5330 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5331#ifdef FEATURE_WLAN_ESE
5332 case eCSR_AUTH_TYPE_CCKM_WPA:
5333 case eCSR_AUTH_TYPE_CCKM_RSN:
5334#endif
5335 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5336
5337 pRoamProfile->AuthType.authType[0] =
5338 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5339 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5340
5341#ifdef FEATURE_WLAN_ESE
5342 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5343 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5344 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005345 hdd_info("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005346 pRoamProfile->AuthType.authType[0] =
5347 eCSR_AUTH_TYPE_CCKM_WPA;
5348 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005349 hdd_info("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005350 pRoamProfile->AuthType.authType[0] =
5351 eCSR_AUTH_TYPE_CCKM_WPA;
5352 } else
5353#endif
5354 if ((pWextState->
5355 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5356 == IW_AUTH_KEY_MGMT_802_1X) {
5357 pRoamProfile->AuthType.authType[0] =
5358 eCSR_AUTH_TYPE_WPA;
5359 } else
5360 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5361 == IW_AUTH_KEY_MGMT_PSK) {
5362 pRoamProfile->AuthType.authType[0] =
5363 eCSR_AUTH_TYPE_WPA_PSK;
5364 } else {
5365 pRoamProfile->AuthType.authType[0] =
5366 eCSR_AUTH_TYPE_WPA_NONE;
5367 }
5368 }
5369 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5370#ifdef FEATURE_WLAN_ESE
5371 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5372 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5373 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005374 hdd_info("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005375 pRoamProfile->AuthType.authType[0] =
5376 eCSR_AUTH_TYPE_CCKM_RSN;
5377 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005378 hdd_info("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 pRoamProfile->AuthType.authType[0] =
5380 eCSR_AUTH_TYPE_CCKM_RSN;
5381 } else
5382#endif
5383
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5385 ((pWextState->
5386 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5387 == IW_AUTH_KEY_MGMT_802_1X)) {
5388 pRoamProfile->AuthType.authType[0] =
5389 eCSR_AUTH_TYPE_FT_RSN;
5390 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5391 &&
5392 ((pWextState->
5393 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5394 == IW_AUTH_KEY_MGMT_PSK)) {
5395 pRoamProfile->AuthType.authType[0] =
5396 eCSR_AUTH_TYPE_FT_RSN_PSK;
5397 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398
5399#ifdef WLAN_FEATURE_11W
5400 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5401 pRoamProfile->AuthType.authType[0] =
5402 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5403 } else if (RSNAuthType ==
5404 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5405 pRoamProfile->AuthType.authType[0] =
5406 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5407 } else
5408#endif
5409
5410 if ((pWextState->
5411 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5412 == IW_AUTH_KEY_MGMT_802_1X) {
5413 pRoamProfile->AuthType.authType[0] =
5414 eCSR_AUTH_TYPE_RSN;
5415 } else
5416 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5417 == IW_AUTH_KEY_MGMT_PSK) {
5418 pRoamProfile->AuthType.authType[0] =
5419 eCSR_AUTH_TYPE_RSN_PSK;
5420 } else {
5421 pRoamProfile->AuthType.authType[0] =
5422 eCSR_AUTH_TYPE_UNKNOWN;
5423 }
5424 }
5425 break;
5426
5427 case eCSR_AUTH_TYPE_SHARED_KEY:
5428
5429 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5430 break;
5431 default:
5432
5433#ifdef FEATURE_WLAN_ESE
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005434 hdd_info("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435#endif /* FEATURE_WLAN_ESE */
5436 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5437 break;
5438 }
5439
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005440 hdd_info("Set roam Authtype to %d",
5441 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 return 0;
5444}
5445
5446/**
5447 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5448 * to the CSR roam profile.
5449 *
5450 * @dev: Pointer to the net device.
5451 * @info: Pointer to the iw_request_info.
5452 * @wrqu: Pointer to the iwreq_data.
5453 * @extra: Pointer to the data.
5454 *
5455 * Return: 0 for success, error number on failure
5456 */
5457static int __iw_set_essid(struct net_device *dev,
5458 struct iw_request_info *info,
5459 union iwreq_data *wrqu, char *extra)
5460{
5461 unsigned long rc;
5462 uint32_t status = 0;
5463 hdd_wext_state_t *pWextState;
5464 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5465 hdd_context_t *hdd_ctx;
5466 uint32_t roamId;
5467 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468 eCsrAuthType RSNAuthType;
5469 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5470 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5471 int ret;
5472
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005473 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474
5475 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5476 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305477 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 return ret;
5479
Krunal Sonibe766b02016-03-10 13:00:44 -08005480 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005481 pAdapter->device_mode != QDF_IBSS_MODE &&
5482 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005483 hdd_warn("device mode %s(%d) is not allowed",
5484 hdd_device_mode_to_string(pAdapter->device_mode),
5485 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 return -EINVAL;
5487 }
5488
5489 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5490
5491 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005492 hdd_info("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493 return -EBUSY;
5494 }
5495 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5496 return -EINVAL;
5497
5498 pRoamProfile = &pWextState->roamProfile;
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005499 if (hdd_conn_is_connected(pHddStaCtx) ||
5500 (pAdapter->device_mode == QDF_IBSS_MODE)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305501 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502
5503 /* Need to issue a disconnect to CSR. */
5504 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305505 qdf_status = sme_roam_disconnect(hHal, pAdapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5507
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305508 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509 rc = wait_for_completion_timeout(&pAdapter->
5510 disconnect_comp_var,
5511 msecs_to_jiffies
5512 (WLAN_WAIT_TIME_DISCONNECT));
5513 if (!rc)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005514 hdd_err("Disconnect event timed out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 }
5516 }
5517
5518 /*
5519 * when cfg80211 defined, wpa_supplicant wext driver uses
5520 * zero-length, null-string ssid for force disconnection.
5521 * after disconnection (if previously connected) and cleaning ssid,
5522 * driver MUST return success.
5523 */
5524 if (0 == wrqu->essid.length)
5525 return 0;
5526
5527 status = hdd_wmm_get_uapsd_mask(pAdapter,
5528 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305529 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 pWextState->roamProfile.uapsd_mask = 0;
5531
5532 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5533
5534 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5535 wrqu->essid.length;
5536
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305537 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305539 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540 ssId), extra, wrqu->essid.length);
5541 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5542 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5543
5544 /* set gen ie */
5545 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5546
5547 /* set auth */
5548 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5549 }
5550#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005551 hdd_notice("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 if (pAdapter->wapi_info.nWapiMode) {
5553 switch (pAdapter->wapi_info.wapiAuthMode) {
5554 case WAPI_AUTH_MODE_PSK:
5555 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005556 hdd_notice("WAPI AUTH TYPE: PSK: %d",
5557 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 pRoamProfile->AuthType.numEntries = 1;
5559 pRoamProfile->AuthType.authType[0] =
5560 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5561 break;
5562 }
5563 case WAPI_AUTH_MODE_CERT:
5564 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005565 hdd_notice("WAPI AUTH TYPE: CERT: %d",
5566 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567 pRoamProfile->AuthType.numEntries = 1;
5568 pRoamProfile->AuthType.authType[0] =
5569 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5570 break;
5571 }
5572 } /* End of switch */
5573 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5574 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005575 hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 pRoamProfile->EncryptionType.numEntries = 1;
5577 pRoamProfile->EncryptionType.encryptionType[0] =
5578 eCSR_ENCRYPT_TYPE_WPI;
5579 pRoamProfile->mcEncryptionType.numEntries = 1;
5580 pRoamProfile->mcEncryptionType.encryptionType[0] =
5581 eCSR_ENCRYPT_TYPE_WPI;
5582 }
5583 }
5584#endif /* FEATURE_WLAN_WAPI */
5585 /* if previous genIE is not NULL, update AssocIE */
5586 if (0 != pWextState->genIE.length) {
5587 memset(&pWextState->assocAddIE, 0,
5588 sizeof(pWextState->assocAddIE));
5589 memcpy(pWextState->assocAddIE.addIEdata,
5590 pWextState->genIE.addIEdata, pWextState->genIE.length);
5591 pWextState->assocAddIE.length = pWextState->genIE.length;
5592 pWextState->roamProfile.pAddIEAssoc =
5593 pWextState->assocAddIE.addIEdata;
5594 pWextState->roamProfile.nAddIEAssocLength =
5595 pWextState->assocAddIE.length;
5596
5597 /* clear previous genIE after use it */
5598 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5599 }
5600
5601 /*
5602 * Assumes it is not WPS Association by default, except when
5603 * pAddIEAssoc has WPS IE.
5604 */
5605 pWextState->roamProfile.bWPSAssociation = false;
5606
5607 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5608 pWextState->roamProfile.
5609 nAddIEAssocLength))
5610 pWextState->roamProfile.bWPSAssociation = true;
5611
5612 /* Disable auto BMPS entry by PMC until DHCP is done */
5613 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5614 true);
5615
5616 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5617
5618 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005619 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005621 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5622 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005624
Agrawal Ashish6b015762016-05-05 11:22:18 +05305625 /*
5626 * Change conn_state to connecting before sme_roam_connect(),
5627 * because sme_roam_connect() has a direct path to call
5628 * hdd_sme_roam_callback(), which will change the conn_state
5629 * If direct path, conn_state will be accordingly changed to
5630 * NotConnected or Associated by either
5631 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5632 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5633 * Connecting state will remain until it is completed.
5634 *
5635 * If connection state is not changed,
5636 * connection state will remain in eConnectionState_NotConnected state.
5637 * In hdd_association_completion_handler, "hddDisconInProgress" is
5638 * set to true if conn state is eConnectionState_NotConnected.
5639 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5640 * informed of connect result indication which is an issue.
5641 */
5642 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305643 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305644 hdd_conn_set_connection_state(pAdapter,
5645 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 status = sme_roam_connect(hHal, pAdapter->sessionId,
5648 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305649 if ((QDF_STATUS_SUCCESS != status) &&
5650 (QDF_STA_MODE == pAdapter->device_mode ||
5651 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
5652 hdd_err("sme_roam_connect (session %d) failed with status %d. -> NotConnected",
5653 pAdapter->sessionId, status);
5654 /* change back to NotAssociated */
5655 hdd_conn_set_connection_state(pAdapter,
5656 eConnectionState_NotConnected);
5657 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 pRoamProfile->ChannelInfo.ChannelList = NULL;
5659 pRoamProfile->ChannelInfo.numOfChannels = 0;
5660
5661 EXIT();
5662 return status;
5663}
5664
5665/**
5666 * iw_set_essid() - set essid handler function
5667 * @dev: Pointer to the net device.
5668 * @info: Pointer to the iw_request_info.
5669 * @wrqu: Pointer to the iwreq_data.
5670 * @extra: Pointer to the data.
5671 *
5672 * Return: 0 for success, error number on failure
5673 */
5674int iw_set_essid(struct net_device *dev,
5675 struct iw_request_info *info,
5676 union iwreq_data *wrqu, char *extra)
5677{
5678 int ret;
5679
5680 cds_ssr_protect(__func__);
5681 ret = __iw_set_essid(dev, info, wrqu, extra);
5682 cds_ssr_unprotect(__func__);
5683
5684 return ret;
5685}
5686
5687/**
5688 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5689 * @dev: pointer to the net device
5690 * @info: pointer to the iw request info
5691 * @dwrq: pointer to iw_point
5692 * @extra: pointer to the data
5693 *
5694 * Return: 0 on success, error number otherwise
5695 */
5696static int __iw_get_essid(struct net_device *dev,
5697 struct iw_request_info *info,
5698 struct iw_point *dwrq, char *extra)
5699{
5700 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5701 hdd_context_t *hdd_ctx;
5702 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5703 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5704 int ret;
5705
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005706 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707
5708 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5709 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305710 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711 return ret;
5712
5713 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5714 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5715 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5716 || pHddStaCtx->conn_info.connState ==
5717 eConnectionState_IbssDisconnected)
5718 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5719 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5720 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5721 dwrq->length);
5722 dwrq->flags = 1;
5723 } else {
5724 memset(extra, 0, dwrq->length);
5725 dwrq->length = 0;
5726 dwrq->flags = 0;
5727 }
5728 EXIT();
5729 return 0;
5730}
5731
5732/**
5733 * iw_get_essid() - get essid handler function
5734 * @dev: Pointer to the net device.
5735 * @info: Pointer to the iw_request_info.
5736 * @wrqu: Pointer to the iwreq_data.
5737 * @extra: Pointer to the data.
5738 *
5739 * Return: 0 for success, error number on failure
5740 */
5741int iw_get_essid(struct net_device *dev,
5742 struct iw_request_info *info,
5743 struct iw_point *wrqu, char *extra)
5744{
5745 int ret;
5746
5747 cds_ssr_protect(__func__);
5748 ret = __iw_get_essid(dev, info, wrqu, extra);
5749 cds_ssr_unprotect(__func__);
5750
5751 return ret;
5752}
5753
5754/**
5755 * __iw_set_auth() -
5756 * This function sets the auth type received from the wpa_supplicant
5757 * @dev: pointer to the net device
5758 * @info: pointer to the iw request info
5759 * @wrqu: pointer to iwreq_data
5760 * @extra: pointer to the data
5761 *
5762 * Return: 0 on success, error number otherwise
5763 */
5764static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5765 union iwreq_data *wrqu, char *extra)
5766{
5767 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5768 hdd_context_t *hdd_ctx;
5769 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5770 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5771 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5772 eCsrEncryptionType mcEncryptionType;
5773 eCsrEncryptionType ucEncryptionType;
5774 int ret;
5775
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005776 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777
5778 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5779 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305780 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 return ret;
5782
5783 switch (wrqu->param.flags & IW_AUTH_INDEX) {
5784 case IW_AUTH_WPA_VERSION:
5785 pWextState->wpaVersion = wrqu->param.value;
5786 break;
5787
5788 case IW_AUTH_CIPHER_PAIRWISE:
5789 {
5790 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5791 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5792 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5793 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5794 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5795 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5796 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5797 if ((IW_AUTH_KEY_MGMT_802_1X
5798 ==
5799 (pWextState->
5800 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5801 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5802 pHddStaCtx->conn_info.authType))
5803 /*Dynamic WEP key */
5804 ucEncryptionType =
5805 eCSR_ENCRYPT_TYPE_WEP40;
5806 else
5807 /*Static WEP key */
5808 ucEncryptionType =
5809 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5810 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5811 if ((IW_AUTH_KEY_MGMT_802_1X
5812 ==
5813 (pWextState->
5814 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5815 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5816 pHddStaCtx->conn_info.authType))
5817 /*Dynamic WEP key */
5818 ucEncryptionType =
5819 eCSR_ENCRYPT_TYPE_WEP104;
5820 else
5821 /*Static WEP key */
5822 ucEncryptionType =
5823 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5824 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005825 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
5826 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 return -EINVAL;
5828 }
5829
5830 pRoamProfile->EncryptionType.numEntries = 1;
5831 pRoamProfile->EncryptionType.encryptionType[0] =
5832 ucEncryptionType;
5833 }
5834 break;
5835 case IW_AUTH_CIPHER_GROUP:
5836 {
5837 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5838 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5839 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5840 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5841 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5842 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5843 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5844 if ((IW_AUTH_KEY_MGMT_802_1X
5845 ==
5846 (pWextState->
5847 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5848 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5849 pHddStaCtx->conn_info.authType))
5850 mcEncryptionType =
5851 eCSR_ENCRYPT_TYPE_WEP40;
5852 else
5853 mcEncryptionType =
5854 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5855 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5856 /* Dynamic WEP keys won't work with shared keys */
5857 if ((IW_AUTH_KEY_MGMT_802_1X
5858 ==
5859 (pWextState->
5860 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5861 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5862 pHddStaCtx->conn_info.authType)) {
5863 mcEncryptionType =
5864 eCSR_ENCRYPT_TYPE_WEP104;
5865 } else {
5866 mcEncryptionType =
5867 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5868 }
5869 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005870 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 wrqu->param.value);
5872 return -EINVAL;
5873 }
5874
5875 pRoamProfile->mcEncryptionType.numEntries = 1;
5876 pRoamProfile->mcEncryptionType.encryptionType[0] =
5877 mcEncryptionType;
5878 }
5879 break;
5880
5881 case IW_AUTH_80211_AUTH_ALG:
5882 {
5883 /* Save the auth algo here and set auth type to SME Roam profile
5884 in the iw_set_ap_address */
5885 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
5886 pHddStaCtx->conn_info.authType =
5887 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5888
5889 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5890 pHddStaCtx->conn_info.authType =
5891 eCSR_AUTH_TYPE_SHARED_KEY;
5892
5893 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
5894 /*Not supported */
5895 pHddStaCtx->conn_info.authType =
5896 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5897 pWextState->roamProfile.AuthType.authType[0] =
5898 pHddStaCtx->conn_info.authType;
5899 }
5900 break;
5901
5902 case IW_AUTH_KEY_MGMT:
5903 {
5904#ifdef FEATURE_WLAN_ESE
5905#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5906 /*Check for CCKM AKM type */
5907 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005908 hdd_info("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005909 /* Set the CCKM bit in authKeyMgmt */
5910 /*
5911 * Right now, this breaks all ref to authKeyMgmt because
5912 * our code doesn't realize it is a "bitfield"
5913 */
5914 pWextState->authKeyMgmt |=
5915 IW_AUTH_KEY_MGMT_CCKM;
5916 /* Set the key management to 802.1X */
5917 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
5918 pWextState->isESEConnection = true;
5919 /*
5920 * This is test code. I need to actually KNOW whether
5921 * this is an RSN Assoc or WPA.
5922 */
5923 pWextState->collectedAuthType =
5924 eCSR_AUTH_TYPE_CCKM_RSN;
5925 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5926 /* Save the key management */
5927 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5928 pWextState->collectedAuthType =
5929 eCSR_AUTH_TYPE_RSN;
5930 } else
5931 if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5932 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE;
5933 /* Save the key management anyway */
5934 pWextState->authKeyMgmt = wrqu->param.value;
5935 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
5936 /* Save the key management */
5937 pWextState->authKeyMgmt |=
5938 IW_AUTH_KEY_MGMT_802_1X;
5939 pWextState->collectedAuthType =
5940 eCSR_AUTH_TYPE_RSN;
5941 }
5942#else
5943 /* Save the key management */
5944 pWextState->authKeyMgmt = wrqu->param.value;
5945#endif /* FEATURE_WLAN_ESE */
5946 }
5947 break;
5948
5949 case IW_AUTH_TKIP_COUNTERMEASURES:
5950 {
5951 if (wrqu->param.value) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005952 hdd_info("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005953 wrqu->param.value);
5954 pWextState->mTKIPCounterMeasures =
5955 TKIP_COUNTER_MEASURE_STARTED;
5956 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005957 hdd_info("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958 wrqu->param.value);
5959 pWextState->mTKIPCounterMeasures =
5960 TKIP_COUNTER_MEASURE_STOPED;
5961 }
5962 }
5963 break;
5964 case IW_AUTH_DROP_UNENCRYPTED:
5965 case IW_AUTH_WPA_ENABLED:
5966 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5967 case IW_AUTH_ROAMING_CONTROL:
5968 case IW_AUTH_PRIVACY_INVOKED:
5969
5970 default:
5971
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005972 hdd_warn("called with unsupported auth type %d",
5973 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005974 break;
5975 }
5976
5977 EXIT();
5978 return 0;
5979}
5980
5981/**
5982 * iw_set_auth() - set auth callback function
5983 * @dev: Pointer to the net device.
5984 * @info: Pointer to the iw_request_info.
5985 * @wrqu: Pointer to the iwreq_data.
5986 * @extra: Pointer to the data.
5987 *
5988 * Return: 0 for success, error number on failure.
5989 */
5990int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5991 union iwreq_data *wrqu, char *extra)
5992{
5993 int ret;
5994
5995 cds_ssr_protect(__func__);
5996 ret = __iw_set_auth(dev, info, wrqu, extra);
5997 cds_ssr_unprotect(__func__);
5998
5999 return ret;
6000}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006001/**
6002 * __iw_get_auth() -
6003 * This function returns the auth type to the wpa_supplicant
6004 * @dev: pointer to the net device
6005 * @info: pointer to the iw request info
6006 * @wrqu: pointer to iwreq_data
6007 * @extra: pointer to the data
6008 *
6009 * Return: 0 on success, error number otherwise
6010 */
6011static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6012 union iwreq_data *wrqu, char *extra)
6013{
6014 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6015 hdd_context_t *hdd_ctx;
6016 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6017 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6018 int ret;
6019
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006020 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021
6022 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6023 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306024 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025 return ret;
6026
6027 switch (pRoamProfile->negotiatedAuthType) {
6028 case eCSR_AUTH_TYPE_WPA_NONE:
6029 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6030 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6031 break;
6032 case eCSR_AUTH_TYPE_WPA:
6033 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6034 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6035 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006038 case eCSR_AUTH_TYPE_RSN:
6039 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6040 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6041 break;
6042 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6043 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6044 break;
6045 case eCSR_AUTH_TYPE_SHARED_KEY:
6046 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6047 break;
6048 case eCSR_AUTH_TYPE_UNKNOWN:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006049 hdd_info("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006050 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6051 break;
6052 case eCSR_AUTH_TYPE_AUTOSWITCH:
6053 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6054 break;
6055 case eCSR_AUTH_TYPE_WPA_PSK:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006056 hdd_info("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6058 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006061 case eCSR_AUTH_TYPE_RSN_PSK:
6062#ifdef WLAN_FEATURE_11W
6063 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6064 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6065#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006066 hdd_info("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6068 return -EIO;
6069 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006070 hdd_err("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6072 return -EIO;
6073 }
6074 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6075 switch (pRoamProfile->negotiatedUCEncryptionType) {
6076 case eCSR_ENCRYPT_TYPE_NONE:
6077 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6078 break;
6079 case eCSR_ENCRYPT_TYPE_WEP40:
6080 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6081 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6082 break;
6083 case eCSR_ENCRYPT_TYPE_TKIP:
6084 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6085 break;
6086 case eCSR_ENCRYPT_TYPE_WEP104:
6087 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6088 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6089 break;
6090 case eCSR_ENCRYPT_TYPE_AES:
6091 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6092 break;
6093 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006094 hdd_notice("called with unknown auth type %d",
6095 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096 return -EIO;
6097 }
6098 }
6099
6100 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6101 switch (pRoamProfile->negotiatedMCEncryptionType) {
6102 case eCSR_ENCRYPT_TYPE_NONE:
6103 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6104 break;
6105 case eCSR_ENCRYPT_TYPE_WEP40:
6106 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6107 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6108 break;
6109 case eCSR_ENCRYPT_TYPE_TKIP:
6110 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6111 break;
6112 case eCSR_ENCRYPT_TYPE_WEP104:
6113 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6114 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6115 break;
6116 case eCSR_ENCRYPT_TYPE_AES:
6117 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6118 break;
6119 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006120 hdd_info("called with unknown auth type %d",
6121 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006122 return -EIO;
6123 }
6124 }
6125
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006126 hdd_info("called with auth type %d",
6127 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128 EXIT();
6129 return 0;
6130}
6131
6132/**
6133 * iw_get_auth() - get auth callback function
6134 * @dev: Pointer to the net device.
6135 * @info: Pointer to the iw_request_info.
6136 * @wrqu: Pointer to the iwreq_data.
6137 * @extra: Pointer to the data.
6138 *
6139 * Return: 0 for success, error number on failure.
6140 */
6141int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6142 union iwreq_data *wrqu, char *extra)
6143{
6144 int ret;
6145
6146 cds_ssr_protect(__func__);
6147 ret = __iw_get_auth(dev, info, wrqu, extra);
6148 cds_ssr_unprotect(__func__);
6149
6150 return ret;
6151}
6152
6153/**
6154 * __iw_set_ap_address() - set ap address
6155 * @dev: pointer to the net device
6156 * @info: pointer to the iw request info
6157 * @wrqu: pointer to iwreq_data
6158 * @extra: pointer to the data
6159 *
6160 * This function updates the HDD global station context connection info
6161 * BSSID with the MAC address received from the wpa_supplicant.
6162 *
6163 * Return: 0 on success, error number otherwise
6164 */
6165static int __iw_set_ap_address(struct net_device *dev,
6166 struct iw_request_info *info,
6167 union iwreq_data *wrqu, char *extra)
6168{
6169
6170 hdd_adapter_t *adapter;
6171 hdd_context_t *hdd_ctx;
6172 hdd_station_ctx_t *pHddStaCtx =
6173 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6174 uint8_t *pMacAddress = NULL;
6175 int ret;
6176
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006177 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178
6179 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6180
6181 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6182 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306183 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184 return ret;
6185
6186 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006187 hdd_info(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306188 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306189 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006190 EXIT();
6191
6192 return 0;
6193}
6194
6195/**
6196 * iw_set_ap_address() - set ap addresses callback function
6197 * @dev: Pointer to the net device.
6198 * @info: Pointer to the iw_request_info.
6199 * @wrqu: Pointer to the iwreq_data.
6200 * @extra: Pointer to the data.
6201 *
6202 * Return: 0 for success, error number on failure.
6203 */
6204int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6205 union iwreq_data *wrqu, char *extra)
6206{
6207 int ret;
6208
6209 cds_ssr_protect(__func__);
6210 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6211 cds_ssr_unprotect(__func__);
6212
6213 return ret;
6214}
6215
6216/**
6217 * __iw_get_ap_address() - get ap address
6218 * @dev: pointer to the net device
6219 * @info: pointer to the iw request info
6220 * @wrqu: pointer to iwreq_data
6221 * @extra: pointer to the data
6222 *
6223 * This function returns currently associated BSSID.
6224 *
6225 * Return: 0 on success, error number otherwise
6226 */
6227static int __iw_get_ap_address(struct net_device *dev,
6228 struct iw_request_info *info,
6229 union iwreq_data *wrqu, char *extra)
6230{
6231 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6232 hdd_context_t *hdd_ctx;
6233 hdd_station_ctx_t *pHddStaCtx =
6234 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6235 int ret;
6236
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006237 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238
6239 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6240 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306241 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006242 return ret;
6243
6244 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6245 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306246 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006247 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306248 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249 } else {
6250 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6251 }
6252 EXIT();
6253 return 0;
6254}
6255
6256/**
6257 * iw_get_ap_address() - get ap addresses callback function
6258 * @dev: Pointer to the net device.
6259 * @info: Pointer to the iw_request_info.
6260 * @wrqu: Pointer to the iwreq_data.
6261 * @extra: Pointer to the data.
6262 *
6263 * Return: 0 for success, error number on failure.
6264 */
6265int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6266 union iwreq_data *wrqu, char *extra)
6267{
6268 int ret;
6269
6270 cds_ssr_protect(__func__);
6271 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6272 cds_ssr_unprotect(__func__);
6273
6274 return ret;
6275}