blob: b690dda8cfe3cab282c7b624465b158657f4aacf [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002 * Copyright (c) 2012-2016 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>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065
66/* These are needed to recognize WPA and RSN suite types */
67#define HDD_WPA_OUI_SIZE 4
68#define HDD_RSN_OUI_SIZE 4
69uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
70uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
71uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
72uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
73uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
74uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
75
76#ifdef FEATURE_WLAN_ESE
77/* CCKM */
78uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
79/* CCKM */
80uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
81#endif /* FEATURE_WLAN_ESE */
82
83/* group cipher */
84uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
85
86/* WEP-40 or RSN */
87uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
88
89/* TKIP or RSN-PSK */
90uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
91
92/* Reserved */
93uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
94
95/* AES-CCMP */
96uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
97
98/* WEP-104 */
99uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
100
101#ifdef WLAN_FEATURE_11W
102/* RSN-PSK-SHA256 */
103uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
104
105/* RSN-8021X-SHA256 */
106uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
107#endif
108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109/* Offset where the EID-Len-IE, start. */
110#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
111#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112
113#define BEACON_FRAME_IES_OFFSET 12
114#define HDD_PEER_AUTHORIZE_WAIT 10
115
116/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700117 * beacon_filter_table - table of IEs used for beacon filtering
118 */
119static const int beacon_filter_table[] = {
120 SIR_MAC_DS_PARAM_SET_EID,
121 SIR_MAC_ERP_INFO_EID,
122 SIR_MAC_EDCA_PARAM_SET_EID,
123 SIR_MAC_QOS_CAPABILITY_EID,
124 SIR_MAC_HT_INFO_EID,
125 SIR_MAC_VHT_OPMODE_EID,
126 SIR_MAC_VHT_OPERATION_EID,
127};
128
129/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130 * hdd_conn_set_authenticated() - set authentication state
131 * @pAdapter: pointer to the adapter
132 * @authState: authentication state
133 *
134 * This function updates the global HDD station context
135 * authentication state.
136 *
137 * Return: none
138 */
139static void
140hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
141{
142 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
143 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
144
145 /* save the new connection state */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700146 hdd_notice("Authenticated state Changed from oldState:%d to State:%d",
147 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148 pHddStaCtx->conn_info.uIsAuthenticated = authState;
149
150 /* Check is pending ROC request or not when auth state changed */
151 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
152}
153
154/**
155 * hdd_conn_set_connection_state() - set connection state
156 * @pAdapter: pointer to the adapter
157 * @connState: connection state
158 *
159 * This function updates the global HDD station context connection state.
160 *
161 * Return: none
162 */
163void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
164 eConnectionState connState)
165{
166 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
167 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
168
169 /* save the new connection state */
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530170 hdd_info("%pS Changed connectionState Changed from oldState:%d to State:%d",
171 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
172 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173 pHddStaCtx->conn_info.connState = connState;
174
175 /* Check is pending ROC request or not when connection state changed */
176 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
177}
178
179/**
180 * hdd_conn_get_connection_state() - get connection state
181 * @pAdapter: pointer to the adapter
182 * @pConnState: pointer to connection state
183 *
184 * This function updates the global HDD station context connection state.
185 *
186 * Return: true if (Infra Associated or IBSS Connected)
187 * and sets output parameter pConnState;
188 * false otherwise
189 */
190static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
191 eConnectionState *pConnState)
192{
193 bool fConnected = false;
194 eConnectionState connState;
195
196 /* get the connection state. */
197 connState = pHddStaCtx->conn_info.connState;
198
199 if (eConnectionState_Associated == connState ||
200 eConnectionState_IbssConnected == connState ||
201 eConnectionState_IbssDisconnected == connState) {
202 fConnected = true;
203 }
204
205 if (pConnState)
206 *pConnState = connState;
207
208 return fConnected;
209}
210
211/**
212 * hdd_is_connecting() - Function to check connection progress
213 * @hdd_sta_ctx: pointer to global HDD Station context
214 *
215 * Return: true if connecting, false otherwise
216 */
217bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
218{
219 return hdd_sta_ctx->conn_info.connState ==
220 eConnectionState_Connecting;
221}
222
223/**
224 * hdd_conn_is_connected() - Function to check connection status
225 * @pHddStaCtx: pointer to global HDD Station context
226 *
227 * Return: false if any errors encountered, true otherwise
228 */
229bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
230{
231 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
232}
233
234/**
235 * hdd_conn_get_connected_band() - get current connection radio band
236 * @pHddStaCtx: pointer to global HDD Station context
237 *
238 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
239 * eCSR_BAND_ALL if not connected
240 */
241eCsrBand hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
242{
243 uint8_t staChannel = 0;
244
245 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
246 staChannel = pHddStaCtx->conn_info.operationChannel;
247
248 if (staChannel > 0 && staChannel < 14)
249 return eCSR_BAND_24;
250 else if (staChannel >= 36 && staChannel <= 184)
251 return eCSR_BAND_5G;
252 else /* If station is not connected return as eCSR_BAND_ALL */
253 return eCSR_BAND_ALL;
254}
255
256/**
257 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
258 * @pHddStaCtx: pointer to global HDD Station context
259 * @pConnectedCipherAlgo: pointer to connected cipher algo
260 *
261 * Return: false if any errors encountered, true otherwise
262 */
263static inline bool
264hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
265 eCsrEncryptionType *pConnectedCipherAlgo)
266{
267 bool fConnected = false;
268
269 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
270
271 if (pConnectedCipherAlgo)
272 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
273
274 return fConnected;
275}
276
277/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700278 * hdd_remove_beacon_filter() - remove beacon filter
279 * @adapter: Pointer to the hdd adapter
280 *
281 * Return: 0 on success and errno on failure
282 */
283static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
284{
285 QDF_STATUS status;
286 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
287
288 status = sme_remove_beacon_filter(hdd_ctx->hHal,
289 adapter->sessionId);
290 if (!QDF_IS_STATUS_SUCCESS(status)) {
291 hdd_err("sme_remove_beacon_filter() failed");
292 return -EFAULT;
293 }
294
295 return 0;
296}
297
298/**
299 * hdd_add_beacon_filter() - add beacon filter
300 * @adapter: Pointer to the hdd adapter
301 *
302 * Return: 0 on success and errno on failure
303 */
304static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
305{
306 int i;
307 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
308 QDF_STATUS status;
309 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
310
311 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530312 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700313 (unsigned long int *)ie_map);
314
315 status = sme_add_beacon_filter(hdd_ctx->hHal,
316 adapter->sessionId, ie_map);
317 if (!QDF_IS_STATUS_SUCCESS(status)) {
318 hdd_err("sme_add_beacon_filter() failed");
319 return -EFAULT;
320 }
321 return 0;
322}
323
324/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530325 * hdd_copy_vht_caps()- copy vht caps info from roam info to
326 * hdd station context.
327 * @hdd_sta_ctx: pointer to hdd station context
328 * @roam_info: pointer to roam info
329 *
330 * Return: None
331 */
332static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
333 tCsrRoamInfo *roam_info)
334{
335 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
336 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
337 uint32_t i, temp_ht_cap;
338
339 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
340
341 if (roam_ht_cap->advCodingCap)
342 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
343 if (roam_ht_cap->supportedChannelWidthSet)
344 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
345 temp_ht_cap = roam_ht_cap->mimoPowerSave &
346 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
347 if (temp_ht_cap)
348 hdd_ht_cap->cap_info |=
349 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
350 if (roam_ht_cap->greenField)
351 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
352 if (roam_ht_cap->shortGI20MHz)
353 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
354 if (roam_ht_cap->shortGI40MHz)
355 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
356 if (roam_ht_cap->txSTBC)
357 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
358 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
359 IEEE80211_HT_CAP_RX_STBC_SHIFT);
360 if (temp_ht_cap)
361 hdd_ht_cap->cap_info |=
362 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
363 if (roam_ht_cap->delayedBA)
364 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
365 if (roam_ht_cap->maximalAMSDUsize)
366 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
367 if (roam_ht_cap->dsssCckMode40MHz)
368 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
369 if (roam_ht_cap->psmp)
370 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
371 if (roam_ht_cap->stbcControlFrame)
372 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
373 if (roam_ht_cap->lsigTXOPProtection)
374 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
375
376 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
377 if (roam_ht_cap->maxRxAMPDUFactor)
378 hdd_ht_cap->ampdu_params_info |=
379 IEEE80211_HT_AMPDU_PARM_FACTOR;
380 temp_ht_cap = roam_ht_cap->mpduDensity &
381 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
382 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
383 if (temp_ht_cap)
384 hdd_ht_cap->ampdu_params_info |=
385 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
386
387 /* 802.11n HT extended capabilities masks */
388 if (roam_ht_cap->pco)
389 hdd_ht_cap->extended_ht_cap_info |=
390 IEEE80211_HT_EXT_CAP_PCO;
391 temp_ht_cap = roam_ht_cap->transitionTime &
392 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
393 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
394 if (temp_ht_cap)
395 hdd_ht_cap->extended_ht_cap_info |=
396 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
397 temp_ht_cap = roam_ht_cap->mcsFeedback &
398 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
399 if (temp_ht_cap)
400 hdd_ht_cap->extended_ht_cap_info |=
401 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
402
403 /* tx_bf_cap_info capabilities */
404 if (roam_ht_cap->txBF)
405 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
406 if (roam_ht_cap->rxStaggeredSounding)
407 hdd_ht_cap->tx_BF_cap_info |=
408 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
409 if (roam_ht_cap->txStaggeredSounding)
410 hdd_ht_cap->tx_BF_cap_info |=
411 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
412 if (roam_ht_cap->rxZLF)
413 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
414 if (roam_ht_cap->txZLF)
415 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
416 if (roam_ht_cap->implicitTxBF)
417 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
418 temp_ht_cap = roam_ht_cap->calibration &
419 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
420 if (temp_ht_cap)
421 hdd_ht_cap->tx_BF_cap_info |=
422 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
423 if (roam_ht_cap->explicitCSITxBF)
424 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
425 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
426 hdd_ht_cap->tx_BF_cap_info |=
427 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
428 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
429 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
430 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
431 if (temp_ht_cap)
432 hdd_ht_cap->tx_BF_cap_info |=
433 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
434 temp_ht_cap =
435 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
436 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
437 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
438 if (temp_ht_cap)
439 hdd_ht_cap->tx_BF_cap_info |=
440 temp_ht_cap <<
441 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
442 temp_ht_cap =
443 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
444 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
445 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
446 if (temp_ht_cap)
447 hdd_ht_cap->tx_BF_cap_info |=
448 temp_ht_cap <<
449 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
450 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
451 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
452 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
453 if (temp_ht_cap)
454 hdd_ht_cap->tx_BF_cap_info |=
455 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
456 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
457 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
458 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
459 if (temp_ht_cap)
460 hdd_ht_cap->tx_BF_cap_info |=
461 temp_ht_cap <<
462 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
463 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
464 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
465 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
466 if (temp_ht_cap)
467 hdd_ht_cap->tx_BF_cap_info |=
468 temp_ht_cap <<
469 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
470
471 /* antenna selection */
472 if (roam_ht_cap->antennaSelection)
473 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
474 if (roam_ht_cap->explicitCSIFeedbackTx)
475 hdd_ht_cap->antenna_selection_info |=
476 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
477 if (roam_ht_cap->antennaIndicesFeedbackTx)
478 hdd_ht_cap->antenna_selection_info |=
479 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
480 if (roam_ht_cap->explicitCSIFeedback)
481 hdd_ht_cap->antenna_selection_info |=
482 ANTENNA_SEL_INFO_EXP_CSI_FB;
483 if (roam_ht_cap->antennaIndicesFeedback)
484 hdd_ht_cap->antenna_selection_info |=
485 ANTENNA_SEL_INFO_ANT_ID_FB;
486 if (roam_ht_cap->rxAS)
487 hdd_ht_cap->antenna_selection_info |=
488 ANTENNA_SEL_INFO_RX_AS;
489 if (roam_ht_cap->txSoundingPPDUs)
490 hdd_ht_cap->antenna_selection_info |=
491 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
492
493 /* mcs data rate */
494 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
495 hdd_ht_cap->mcs.rx_mask[i] =
496 roam_ht_cap->supportedMCSSet[i];
497 hdd_ht_cap->mcs.rx_highest =
498 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
499 ((short) (roam_ht_cap->supportedMCSSet[10]));
500 hdd_ht_cap->mcs.tx_params =
501 roam_ht_cap->supportedMCSSet[12];
502}
503
504#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
505#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
506#define VHT_CAP_RXSTBC_MASK_SHIFT 8
507#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
508#define VHT_CAP_BEAMFORMEE_STS_MASK \
509 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
510#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
511#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
512 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
513#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
514#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
515 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
516#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
517
518/**
519 * hdd_copy_ht_caps()- copy ht caps info from roam info to
520 * hdd station context.
521 * @hdd_sta_ctx: pointer to hdd station context
522 * @roam_info: pointer to roam info
523 *
524 * Return: None
525 */
526static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
527 tCsrRoamInfo *roam_info)
528{
529 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
530 struct ieee80211_vht_cap *hdd_vht_cap =
531 &hdd_sta_ctx->conn_info.vht_caps;
532 uint32_t temp_vht_cap;
533
534 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
535
536 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
537 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
538 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
539 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
540 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
541 if (temp_vht_cap)
542 if (roam_vht_cap->supportedChannelWidthSet &
543 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
544 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
545 hdd_vht_cap->vht_cap_info |=
546 temp_vht_cap <<
547 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
548 if (roam_vht_cap->supportedChannelWidthSet &
549 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
550 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
551 hdd_vht_cap->vht_cap_info |=
552 temp_vht_cap <<
553 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
554 if (roam_vht_cap->ldpcCodingCap)
555 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
556 if (roam_vht_cap->shortGI80MHz)
557 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
558 if (roam_vht_cap->shortGI160and80plus80MHz)
559 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
560 if (roam_vht_cap->txSTBC)
561 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
562 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
563 VHT_CAP_RXSTBC_MASK_SHIFT);
564 if (temp_vht_cap)
565 hdd_vht_cap->vht_cap_info |=
566 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
567 if (roam_vht_cap->suBeamFormerCap)
568 hdd_vht_cap->vht_cap_info |=
569 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
570 if (roam_vht_cap->suBeamformeeCap)
571 hdd_vht_cap->vht_cap_info |=
572 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
573 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
574 (VHT_CAP_BEAMFORMEE_STS_MASK);
575 if (temp_vht_cap)
576 hdd_vht_cap->vht_cap_info |=
577 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
578 temp_vht_cap = roam_vht_cap->numSoundingDim &
579 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
580 if (temp_vht_cap)
581 hdd_vht_cap->vht_cap_info |=
582 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
583 if (roam_vht_cap->muBeamformerCap)
584 hdd_vht_cap->vht_cap_info |=
585 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
586 if (roam_vht_cap->muBeamformeeCap)
587 hdd_vht_cap->vht_cap_info |=
588 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
589 if (roam_vht_cap->vhtTXOPPS)
590 hdd_vht_cap->vht_cap_info |=
591 IEEE80211_VHT_CAP_VHT_TXOP_PS;
592 if (roam_vht_cap->htcVHTCap)
593 hdd_vht_cap->vht_cap_info |=
594 IEEE80211_VHT_CAP_HTC_VHT;
595 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
596 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
597 if (temp_vht_cap)
598 hdd_vht_cap->vht_cap_info |=
599 temp_vht_cap <<
600 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
601 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
602 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
603 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
604 if (temp_vht_cap)
605 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
606 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
607 if (roam_vht_cap->rxAntPattern)
608 hdd_vht_cap->vht_cap_info |=
609 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
610 if (roam_vht_cap->txAntPattern)
611 hdd_vht_cap->vht_cap_info |=
612 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
613 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
614 hdd_vht_cap->supp_mcs.rx_highest =
615 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
616 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
617 hdd_vht_cap->supp_mcs.tx_highest =
618 ((uint16_t)roam_vht_cap->txSupDataRate);
619}
620
621/* ht param */
622#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
623#define HT_PARAM_SERVICE_INT_GRAN 0xe0
624#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
625
626/* operatinon mode */
627#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
628
629/* stbc_param */
630#define HT_STBC_PARAM_MCS 0x007f
631
632/**
633 * hdd_copy_ht_operation()- copy HT operation element from roam info to
634 * hdd station context.
635 * @hdd_sta_ctx: pointer to hdd station context
636 * @roam_info: pointer to roam info
637 *
638 * Return: None
639 */
640static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
641 tCsrRoamInfo *roam_info)
642{
643 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
644 struct ieee80211_ht_operation *hdd_ht_ops =
645 &hdd_sta_ctx->conn_info.ht_operation;
646 uint32_t i, temp_ht_ops;
647
648 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
649
650 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
651
652 /* HT_PARAMS */
653 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
654 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
655 if (temp_ht_ops)
656 hdd_ht_ops->ht_param |= temp_ht_ops;
657 else
658 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
659 if (roam_ht_ops->recommendedTxWidthSet)
660 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
661 if (roam_ht_ops->rifsMode)
662 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
663 if (roam_ht_ops->controlledAccessOnly)
664 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
665 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
666 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
667 if (temp_ht_ops)
668 hdd_ht_ops->ht_param |= temp_ht_ops <<
669 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
670
671 /* operation mode */
672 temp_ht_ops = roam_ht_ops->opMode &
673 IEEE80211_HT_OP_MODE_PROTECTION;
674 switch (temp_ht_ops) {
675 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
676 hdd_ht_ops->operation_mode |=
677 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
678 break;
679 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
680 hdd_ht_ops->operation_mode |=
681 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
682 break;
683 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
684 hdd_ht_ops->operation_mode |=
685 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
686 break;
687 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
688 default:
689 hdd_ht_ops->operation_mode |=
690 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
691 }
692 if (roam_ht_ops->nonGFDevicesPresent)
693 hdd_ht_ops->operation_mode |=
694 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
695 if (roam_ht_ops->transmitBurstLimit)
696 hdd_ht_ops->operation_mode |=
697 HT_OP_MODE_TX_BURST_LIMIT;
698 if (roam_ht_ops->obssNonHTStaPresent)
699 hdd_ht_ops->operation_mode |=
700 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
701
702 /* stbc_param */
703 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
704 HT_STBC_PARAM_MCS;
705 if (temp_ht_ops)
706 hdd_ht_ops->stbc_param |= temp_ht_ops;
707 if (roam_ht_ops->dualCTSProtection)
708 hdd_ht_ops->stbc_param |=
709 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
710 if (roam_ht_ops->secondaryBeacon)
711 hdd_ht_ops->stbc_param |=
712 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
713 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
714 hdd_ht_ops->stbc_param |=
715 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
716 if (roam_ht_ops->pcoActive)
717 hdd_ht_ops->stbc_param |=
718 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
719 if (roam_ht_ops->pcoPhase)
720 hdd_ht_ops->stbc_param |=
721 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
722
723 /* basic MCs set */
724 for (i = 0; i < 16; ++i)
725 hdd_ht_ops->basic_set[i] =
726 roam_ht_ops->basicMCSSet[i];
727}
728
729/**
730 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
731 * hdd station context.
732 * @hdd_sta_ctx: pointer to hdd station context
733 * @roam_info: pointer to roam info
734 *
735 * Return: None
736 */
737static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
738 tCsrRoamInfo *roam_info)
739{
740 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
741 struct ieee80211_vht_operation *hdd_vht_ops =
742 &hdd_sta_ctx->conn_info.vht_operation;
743
744 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
745
746 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
747 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
748 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
749 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
750}
751
752
753/**
754 * hdd_save_bss_info() - save connection info in hdd sta ctx
755 * @adapter: Pointer to adapter
756 * @roam_info: pointer to roam info
757 *
758 * Return: None
759 */
760static void hdd_save_bss_info(hdd_adapter_t *adapter,
761 tCsrRoamInfo *roam_info)
762{
763 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
764
765 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
766 hdd_sta_ctx->conn_info.operationChannel);
767 if (roam_info->vht_caps.present) {
768 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
769 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
770 } else {
771 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
772 }
773 if (roam_info->ht_caps.present) {
774 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
775 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
776 } else {
777 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
778 }
779 if (roam_info->reassoc)
780 hdd_sta_ctx->conn_info.roam_count++;
781 if (roam_info->hs20vendor_ie.present) {
782 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
783 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
784 &roam_info->hs20vendor_ie,
785 sizeof(roam_info->hs20vendor_ie));
786 } else {
787 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
788 }
789 if (roam_info->ht_operation.present) {
790 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
791 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
792 } else {
793 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
794 }
795 if (roam_info->vht_operation.present) {
796 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
797 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
798 } else {
799 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
800 }
801}
802
803/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 * hdd_conn_save_connect_info() - save current connection information
805 * @pAdapter: pointer to adapter
806 * @pRoamInfo: pointer to roam info
807 * @eBssType: bss type
808 *
809 * Return: none
810 */
811static void
812hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
813 eCsrRoamBssType eBssType)
814{
815 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
816 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
817
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530818 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819
820 if (pRoamInfo) {
821 /* Save the BSSID for the connection */
822 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530823 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530824 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 &pRoamInfo->bssid);
826
827 /*
828 * Save the Station ID for this station from
829 * the 'Roam Info'. For IBSS mode, staId is
830 * assigned in NEW_PEER_IND. For reassoc,
831 * the staID doesn't change and it may be invalid
832 * in this structure so no change here.
833 */
834 if (!pRoamInfo->fReassocReq) {
835 pHddStaCtx->conn_info.staId[0] =
836 pRoamInfo->staId;
837 }
838 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530839 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840 &pRoamInfo->bssid);
841 } else {
842 /*
843 * can't happen. We need a valid IBSS or Infra setting
844 * in the BSSDescription or we can't function.
845 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530846 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 }
848
849 /* notify WMM */
850 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
851
852 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530853 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 } else {
855 /* Get Multicast Encryption Type */
856 encryptType =
857 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
858 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
859 /* Get Unicast Encryption Type */
860 encryptType =
861 pRoamInfo->u.pConnectedProfile->EncryptionType;
862 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
863
864 pHddStaCtx->conn_info.authType =
865 pRoamInfo->u.pConnectedProfile->AuthType;
866
867 pHddStaCtx->conn_info.operationChannel =
868 pRoamInfo->u.pConnectedProfile->operationChannel;
869
870 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530871 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 &pRoamInfo->u.pConnectedProfile->SSID,
873 sizeof(tSirMacSSid));
874
875 /* Save dot11mode in which STA associated to AP */
876 pHddStaCtx->conn_info.dot11Mode =
877 pRoamInfo->u.pConnectedProfile->dot11Mode;
878
879 pHddStaCtx->conn_info.proxyARPService =
880 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530881
882 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
883
884 pHddStaCtx->conn_info.rate_flags =
885 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530887 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889}
890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891/**
892 * hdd_send_ft_assoc_response() - send fast transition assoc response
893 * @dev: pointer to net device
894 * @pAdapter: pointer to adapter
895 * @pCsrRoamInfo: pointer to roam info
896 *
897 * Send the 11R key information to the supplicant. Only then can the supplicant
898 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
899 * for the same purpose.)
900 *
901 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
902 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
903 * This is the Assoc Response.
904 *
905 * Return: none
906 */
907static void
908hdd_send_ft_assoc_response(struct net_device *dev,
909 hdd_adapter_t *pAdapter,
910 tCsrRoamInfo *pCsrRoamInfo)
911{
912 union iwreq_data wrqu;
913 char *buff;
914 unsigned int len = 0;
915 u8 *pFTAssocRsp = NULL;
916
917 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700918 hdd_err("pCsrRoamInfo->nAssocRspLength=%d",
919 (int)pCsrRoamInfo->nAssocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 return;
921 }
922
923 pFTAssocRsp =
924 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
925 pCsrRoamInfo->nAssocReqLength);
926 if (pFTAssocRsp == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700927 hdd_err("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 return;
929 }
930 /* pFTAssocRsp needs to point to the IEs */
931 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700932 hdd_notice("AssocRsp is now at %02x%02x",
933 (unsigned int)pFTAssocRsp[0],
934 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935
936 /* We need to send the IEs to the supplicant. */
937 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
938 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700939 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940 return;
941 }
942 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
943 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
944 wrqu.data.length = len;
945 memset(buff, 0, IW_GENERIC_IE_MAX);
946 memcpy(buff, pFTAssocRsp, len);
947 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
948
949 kfree(buff);
950}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952/**
953 * hdd_send_ft_event() - send fast transition event
954 * @pAdapter: pointer to adapter
955 *
956 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
957 * FT events to the supplicant. At the reception of Auth2 we send the RIC
958 * followed by the auth response IEs to the supplicant.
959 * Once both are received in the supplicant, an FT event is generated
960 * to the supplicant.
961 *
962 * Return: none
963 */
964static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
965{
966 uint16_t auth_resp_len = 0;
967 uint32_t ric_ies_length = 0;
968 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
969
970#if defined(KERNEL_SUPPORT_11R_CFG80211)
971 struct cfg80211_ft_event_params ftEvent;
972 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
973 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
974 struct net_device *dev = pAdapter->dev;
975#else
976 char *buff;
977 union iwreq_data wrqu;
978 uint16_t str_len;
979#endif
980
981#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530982 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
983 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984
985 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
986 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
987 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700988 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 }
990
991 ftEvent.ric_ies = ricIe;
992 ftEvent.ric_ies_len = ric_ies_length;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700993 hdd_notice("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994
995 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
996 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
997 &auth_resp_len);
998
999 if (auth_resp_len == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001000 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 return;
1002 }
1003
1004 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1005
1006 ftEvent.target_ap = ftIe;
1007
Anurag Chouhan6d760662016-02-20 16:05:43 +05301008 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1009 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001011 hdd_notice("ftEvent.ies_len %zu", ftEvent.ies_len);
1012 hdd_notice("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1013 hdd_notice("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 ftEvent.target_ap[0], ftEvent.target_ap[1],
1015 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1016 ftEvent.target_ap[5]);
1017
1018 (void)cfg80211_ft_event(dev, &ftEvent);
1019
1020#else
1021 /* We need to send the IEs to the supplicant */
1022 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
1023 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001024 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 return;
1026 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301027 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028
1029 /* Sme needs to send the RIC IEs first */
1030 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1031 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1032 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1033 &ric_ies_length);
1034 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001035 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 } else {
1037 wrqu.data.length = str_len + ric_ies_length;
1038 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1039 }
1040
1041 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301042 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1044 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1045 (u8 *) &buff[str_len],
1046 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1047
1048 if (auth_resp_len == 0) {
1049 kfree(buff);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001050 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 return;
1052 }
1053
1054 wrqu.data.length = str_len + auth_resp_len;
1055 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1056
1057 kfree(buff);
1058#endif
1059}
1060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061#ifdef FEATURE_WLAN_ESE
1062/**
1063 * hdd_send_new_ap_channel_info() - send new ap channel info
1064 * @dev: pointer to net device
1065 * @pAdapter: pointer to adapter
1066 * @pCsrRoamInfo: pointer to roam info
1067 *
1068 * Send the ESE required "new AP Channel info" to the supplicant.
1069 * (This keeps the supplicant "up to date" on the current channel.)
1070 *
1071 * The current (new AP) channel information is passed in.
1072 *
1073 * Return: none
1074 */
1075static void
1076hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1077 tCsrRoamInfo *pCsrRoamInfo)
1078{
1079 union iwreq_data wrqu;
1080 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1081
1082 if (descriptor == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001083 hdd_err("pCsrRoamInfo->pBssDesc(%p)", descriptor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 return;
1085 }
1086 /*
1087 * Send the Channel event, the supplicant needs this to generate
1088 * the Adjacent AP report.
1089 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001090 hdd_warn("Sending up an SIOCGIWFREQ, channelId(%d)",
1091 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 memset(&wrqu, '\0', sizeof(wrqu));
1093 wrqu.freq.m = descriptor->channelId;
1094 wrqu.freq.e = 0;
1095 wrqu.freq.i = 0;
1096 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1097}
1098
1099#endif /* FEATURE_WLAN_ESE */
1100
1101/**
1102 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1103 * @pAdapter: pointer to adapter
1104 * @pCsrRoamInfo: pointer to roam info
1105 *
1106 * Return: none
1107 */
1108static void
1109hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1110 tCsrRoamInfo *pCsrRoamInfo)
1111{
1112 union iwreq_data wrqu;
1113 u8 *pBeaconIes;
1114 u8 currentLen = 0;
1115 char *buff;
1116 int totalIeLen = 0, currentOffset = 0, strLen;
1117
1118 memset(&wrqu, '\0', sizeof(wrqu));
1119
1120 if (0 == pCsrRoamInfo->nBeaconLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001121 hdd_warn("pCsrRoamInfo->nBeaconFrameLength = 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122 return;
1123 }
1124 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1125 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001126 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127 return;
1128 }
1129 /* pBeaconIes needs to point to the IEs */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001130 hdd_notice("Beacon IEs is now at %02x%02x",
1131 (unsigned int)pBeaconIes[0],
1132 (unsigned int)pBeaconIes[1]);
1133 hdd_notice("Beacon IEs length = %d",
1134 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135
1136 /* We need to send the IEs to the supplicant. */
1137 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
1138 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001139 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 return;
1141 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301142 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143
1144 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1145 currentLen = strLen + 1;
1146
1147 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1148 do {
1149 /*
1150 * If the beacon size exceeds max CUSTOM event size, break it
1151 * into chunks of CUSTOM event max size and send it to
1152 * supplicant. Changes are done in supplicant to handle this.
1153 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301154 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301156 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301157 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 currentLen);
1159 currentOffset += currentLen;
1160 totalIeLen -= currentLen;
1161 wrqu.data.length = strLen + 1 + currentLen;
1162 if (totalIeLen)
1163 buff[strLen] = 1; /* more chunks pending */
1164 else
1165 buff[strLen] = 0; /* last chunk */
1166
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001167 hdd_notice("Beacon IEs length to supplicant = %d",
1168 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1170 } while (totalIeLen > 0);
1171
1172 kfree(buff);
1173}
1174
1175/**
1176 * hdd_send_association_event() - send association event
1177 * @dev: pointer to net device
1178 * @pCsrRoamInfo: pointer to roam info
1179 *
1180 * Return: none
1181 */
1182static void hdd_send_association_event(struct net_device *dev,
1183 tCsrRoamInfo *pCsrRoamInfo)
1184{
1185 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1186 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1187 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1188 union iwreq_data wrqu;
1189 int we_event;
1190 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301191 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001193 /* Added to find the auth type on the fly at run time */
1194 /* rather than with cfg to see if FT is enabled */
1195 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1196 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197
1198 memset(&wrqu, '\0', sizeof(wrqu));
1199 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1200 we_event = SIOCGIWAP;
1201#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1202 if (NULL != pCsrRoamInfo)
1203 if (pCsrRoamInfo->roamSynchInProgress)
1204 /* change logging before release */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001205 hdd_info("LFR3:hdd_send_association_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206#endif
1207 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Abhishek Singh1c676222016-05-09 14:20:28 +05301208 tSirSmeChanInfo chan_info;
1209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 if (!pCsrRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001211 hdd_err("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 return;
1213 }
1214
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001215 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
1216 cds_incr_active_session(pAdapter->device_mode,
1217 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1219 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1220
1221#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001222 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 if (global_p2p_connection_status ==
1224 P2P_CLIENT_CONNECTING_STATE_1) {
1225 global_p2p_connection_status =
1226 P2P_CLIENT_CONNECTED_STATE_1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001227 hdd_err("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228 } else if (global_p2p_connection_status ==
1229 P2P_CLIENT_CONNECTING_STATE_2) {
1230 global_p2p_connection_status =
1231 P2P_CLIENT_COMPLETED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001232 hdd_err("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 }
1234 }
1235#endif
1236 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1237 MAC_ADDRESS_STR "\n",
1238 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1239 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1240 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1241
1242 /*
1243 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1244 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001245 * fFTEnable is true.
1246 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248 if ((pRoamProfile->AuthType.authType[0] ==
1249 eCSR_AUTH_TYPE_FT_RSN_PSK)
1250 || (pRoamProfile->AuthType.authType[0] ==
1251 eCSR_AUTH_TYPE_FT_RSN)
1252#ifdef FEATURE_WLAN_ESE
1253 || (pRoamProfile->AuthType.authType[0] ==
1254 eCSR_AUTH_TYPE_CCKM_RSN)
1255 || (pRoamProfile->AuthType.authType[0] ==
1256 eCSR_AUTH_TYPE_CCKM_WPA)
1257#endif
1258 ) {
1259 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1260 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301261 qdf_copy_macaddr(&peerMacAddr,
1262 &pHddStaCtx->conn_info.bssId);
1263 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1264 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1265 chan_info.info = pCsrRoamInfo->chan_info.info;
1266 chan_info.band_center_freq1 =
1267 pCsrRoamInfo->chan_info.band_center_freq1;
1268 chan_info.band_center_freq2 =
1269 pCsrRoamInfo->chan_info.band_center_freq2;
1270 chan_info.reg_info_1 =
1271 pCsrRoamInfo->chan_info.reg_info_1;
1272 chan_info.reg_info_2 =
1273 pCsrRoamInfo->chan_info.reg_info_2;
1274 /* send peer status indication to oem app */
1275 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
1276 ePeerConnected,
1277 pCsrRoamInfo->
1278 timingMeasCap,
1279 pAdapter->sessionId,
1280 &chan_info,
1281 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001282 /* Update tdls module about connection event */
1283 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001284
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001286#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 /* start timer in sta/p2p_cli */
1288 spin_lock_bh(&pHddCtx->bus_bw_lock);
1289 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1290 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001291 cdp_get_intra_bss_fwd_pkts_count(
1292 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301293 &pAdapter->prev_fwd_tx_packets,
1294 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1296 hdd_start_bus_bw_compute_timer(pAdapter);
1297#endif
1298#endif
1299 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1300 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001301 cds_update_connection_info(pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
1303 ETH_ALEN);
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301304 hdd_err("wlan: new IBSS connection to " MAC_ADDRESS_STR,
1305 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 } else { /* Not Associated */
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301307 hdd_err("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301309 cds_decr_session_set_pcl(pAdapter->device_mode,
1310 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 wlan_hdd_enable_roaming(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312
1313#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1314 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1315#endif
1316
Abhishek Singh1c676222016-05-09 14:20:28 +05301317 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1318 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301319 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 &pHddStaCtx->conn_info.bssId);
1321
1322 /* send peer status indication to oem app */
1323 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301324 ePeerDisconnected, 0,
1325 pAdapter->sessionId,
1326 NULL,
1327 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 }
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001329 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001330 /* Update tdls module about the disconnection event */
1331 wlan_hdd_tdls_notify_disconnect(pAdapter);
1332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333#ifdef MSM_PLATFORM
1334 /* stop timer in sta/p2p_cli */
1335 spin_lock_bh(&pHddCtx->bus_bw_lock);
1336 pAdapter->prev_tx_packets = 0;
1337 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301338 pAdapter->prev_fwd_tx_packets = 0;
1339 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1341 hdd_stop_bus_bw_compute_timer(pAdapter);
1342#endif
1343 }
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001344 cds_dump_concurrency_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 /* Send SCC/MCC Switching event to IPA */
1346 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1347
1348 msg = NULL;
1349 /*During the WLAN uninitialization,supplicant is stopped before the
1350 driver so not sending the status of the connection to supplicant */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001351 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 wireless_send_event(dev, we_event, &wrqu, msg);
1353#ifdef FEATURE_WLAN_ESE
1354 if (eConnectionState_Associated ==
1355 pHddStaCtx->conn_info.connState) {
1356 if ((pRoamProfile->AuthType.authType[0] ==
1357 eCSR_AUTH_TYPE_CCKM_RSN) ||
1358 (pRoamProfile->AuthType.authType[0] ==
1359 eCSR_AUTH_TYPE_CCKM_WPA))
1360 hdd_send_new_ap_channel_info(dev, pAdapter,
1361 pCsrRoamInfo);
1362 }
1363#endif
1364 }
1365}
1366
1367/**
1368 * hdd_conn_remove_connect_info() - remove connection info
1369 * @pHddStaCtx: pointer to global HDD station context
1370 * @pCsrRoamInfo: pointer to roam info
1371 *
1372 * Return: none
1373 */
1374static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1375{
1376 /* Remove staId, bssId and peerMacAddress */
1377 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301378 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1379 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301380 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 /* Clear all security settings */
1383 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1384 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1385 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1386
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301387 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1388 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 pHddStaCtx->conn_info.proxyARPService = 0;
1391
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301392 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393}
1394
1395/**
1396 * hdd_roam_deregister_sta() - deregister station
1397 * @pAdapter: pointer to adapter
1398 * @staId: station identifier
1399 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301400 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 */
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07001402QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301404 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1406
1407 if (eConnectionState_IbssDisconnected ==
1408 pHddStaCtx->conn_info.connState) {
1409 /*
1410 * Do not set the carrier off when the last peer leaves.
1411 * We will set the carrier off while stopping the IBSS.
1412 */
1413 }
1414
Leo Changfdb45c32016-10-28 11:09:23 -07001415 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
1416 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301417 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001418 hdd_err("cdp_peer_clear() failed for staID %d. Status(%d) [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301419 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301421 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422}
1423
1424/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301425 * hdd_print_bss_info() - print bss info
1426 * @hdd_sta_ctx: pointer to hdd station context
1427 *
1428 * Return: None
1429 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001430static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301431{
1432 uint32_t *cap_info;
1433
1434 hdd_info("WIFI DATA LOGGER");
1435 hdd_info("channel: %d",
1436 hdd_sta_ctx->conn_info.freq);
1437 hdd_info("dot11mode: %d",
1438 hdd_sta_ctx->conn_info.dot11Mode);
1439 hdd_info("AKM: %d",
1440 hdd_sta_ctx->conn_info.authType);
1441 hdd_info("ssid: %.*s",
1442 hdd_sta_ctx->conn_info.SSID.SSID.length,
1443 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1444 hdd_info("roam count: %d",
1445 hdd_sta_ctx->conn_info.roam_count);
1446 hdd_info("ant_info: %d",
1447 hdd_sta_ctx->conn_info.txrate.nss);
1448 hdd_info("datarate legacy %d",
1449 hdd_sta_ctx->conn_info.txrate.legacy);
1450 hdd_info("datarate mcs: %d",
1451 hdd_sta_ctx->conn_info.txrate.mcs);
1452 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1453 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1454 hdd_info("ht caps: %x", *cap_info);
1455 }
1456 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1457 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1458 hdd_info("vht caps: %x", *cap_info);
1459 }
1460 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1461 hdd_info("hs20 info: %x",
1462 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1463 hdd_info("signal: %d",
1464 hdd_sta_ctx->conn_info.signal);
1465 hdd_info("noise: %d",
1466 hdd_sta_ctx->conn_info.noise);
1467}
1468
1469/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 * hdd_dis_connect_handler() - disconnect event handler
1471 * @pAdapter: pointer to adapter
1472 * @pRoamInfo: pointer to roam info
1473 * @roamId: roam identifier
1474 * @roamStatus: roam status
1475 * @roamResult: roam result
1476 *
1477 * This function handles disconnect event:
1478 * 1. Disable transmit queues;
1479 * 2. Clean up internal connection states and data structures;
1480 * 3. Send disconnect indication to supplicant.
1481 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301482 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301484static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 tCsrRoamInfo *pRoamInfo,
1486 uint32_t roamId,
1487 eRoamCmdStatus roamStatus,
1488 eCsrRoamResult roamResult)
1489{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301490 QDF_STATUS status = QDF_STATUS_SUCCESS;
1491 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 struct net_device *dev = pAdapter->dev;
1493 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1494 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1495 uint8_t sta_id;
1496 bool sendDisconInd = true;
1497
1498 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001499 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301500 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 }
1502 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001503 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER,
1505 WLAN_CONTROL_PATH);
1506
1507 if (hdd_ipa_is_enabled(pHddCtx))
1508 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001509 HDD_IPA_STA_DISCONNECT,
1510 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511
1512#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1513 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1514#endif
1515
Nirav Shah1da77682016-05-03 20:16:39 +05301516 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1517 pAdapter->sessionId,
1518 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519
1520 /* HDD has initiated disconnect, do not send disconnect indication
1521 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301522 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523 * to cfg80211_disconnected.
1524 */
1525 if ((eConnectionState_Disconnecting ==
1526 pHddStaCtx->conn_info.connState) ||
1527 (eConnectionState_NotConnected ==
1528 pHddStaCtx->conn_info.connState)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001529 hdd_notice("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 sendDisconInd = false;
1531 }
1532
1533 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1534 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 hdd_conn_set_connection_state(pAdapter,
1536 eConnectionState_Disconnecting);
1537 }
1538
1539 hdd_clear_roam_profile_ie(pAdapter);
1540 hdd_wmm_init(pAdapter);
1541
1542 /* indicate 'disconnect' status to wpa_supplicant... */
1543 hdd_send_association_event(dev, pRoamInfo);
1544 /* indicate disconnected event to nl80211 */
1545 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1546 /*
1547 * Only send indication to kernel if not initiated
1548 * by kernel
1549 */
1550 if (sendDisconInd) {
1551 /*
1552 * To avoid wpa_supplicant sending "HANGED" CMD
1553 * to ICS UI.
1554 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001555 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1556 if (pRoamInfo->reasonCode ==
1557 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1558 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301559 wlan_hdd_cfg80211_indicate_disconnect(
1560 dev, false,
1561 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001562 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301563 wlan_hdd_cfg80211_indicate_disconnect(
1564 dev, false,
1565 WLAN_REASON_UNSPECIFIED
1566 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001567 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568
1569 hdd_info("sent disconnected event to nl80211, rssi: %d",
1570 pAdapter->rssi);
1571 }
1572 /*
1573 * During the WLAN uninitialization,supplicant is stopped
1574 * before the driver so not sending the status of the
1575 * connection to supplicant.
1576 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001577 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001579 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 if (global_p2p_connection_status ==
1581 P2P_CLIENT_CONNECTED_STATE_1) {
1582 global_p2p_connection_status =
1583 P2P_CLIENT_DISCONNECTED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001584 hdd_err("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 } else if (global_p2p_connection_status ==
1586 P2P_CLIENT_COMPLETED_STATE) {
1587 global_p2p_connection_status =
1588 P2P_NOT_ACTIVE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001589 hdd_err("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 }
1591 }
1592#endif
1593
1594 }
1595 }
1596
1597 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001599 if (hdd_remove_beacon_filter(pAdapter) != 0)
1600 hdd_err("hdd_remove_beacon_filter() failed");
1601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301603 uint8_t i;
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001604 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301606 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301607 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]",
1608 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301609 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 }
1611 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301612 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001613 for (i = 0; i < MAX_PEERS; i++) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301614 if (0 == pHddStaCtx->conn_info.staId[i])
1615 continue;
1616 sta_id = pHddStaCtx->conn_info.staId[i];
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001617 hdd_info("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301618 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301619 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001620 hdd_err("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301621 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301622 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301623 }
1624 /* set the staid and peer mac as 0, all other
1625 * reset are done in hdd_connRemoveConnectInfo.
1626 */
1627 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301628 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301629 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301630 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1631 pHddCtx->sta_to_adapter[sta_id] = NULL;
1632 }
1633 } else {
1634 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhc9941602016-08-09 16:06:22 +05301635
1636 /* clear scan cache for Link Lost */
1637 if (pRoamInfo && !pRoamInfo->reasonCode &&
1638 (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult)) {
1639 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1640 pHddStaCtx->conn_info.bssId.bytes);
1641 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1642 pHddStaCtx->conn_info.bssId.bytes);
1643 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301644 /* We should clear all sta register with TL,
1645 * for now, only one.
1646 */
1647 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301648 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001649 hdd_err("hdd_roam_deregister_sta() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301650 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301651 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301652 }
1653 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 /* Clear saved connection information in HDD */
1656 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
1658#ifdef WLAN_FEATURE_GTK_OFFLOAD
Krunal Sonibe766b02016-03-10 13:00:44 -08001659 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1660 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1662 sizeof(tSirGtkOffloadParams));
1663 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
1664 }
1665#endif
1666
1667#ifdef FEATURE_WLAN_TDLS
1668 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1669 wlan_hdd_tdls_disconnection_callback(pAdapter);
1670#endif
1671
Krunal Sonibe766b02016-03-10 13:00:44 -08001672 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1673 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1675 (pAdapter),
1676 pAdapter->sessionId);
1677 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301678 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 /* Unblock anyone waiting for disconnect to complete */
1680 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301681 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 return status;
1683}
1684
1685/**
1686 * hdd_set_peer_authorized_event() - set peer_authorized_event
1687 * @vdev_id: vdevid
1688 *
1689 * Return: None
1690 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001691static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301693 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 hdd_adapter_t *adapter = NULL;
1695
1696 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1697 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001698 hdd_err("Invalid vdev_id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 }
1700 complete(&adapter->sta_authorized_event);
1701}
1702
1703/**
1704 * hdd_change_peer_state() - change peer state
1705 * @pAdapter: HDD adapter
1706 * @sta_state: peer state
1707 * @roam_synch_in_progress: roam synch in progress
1708 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301709 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301711QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 uint8_t sta_id,
1713 enum ol_txrx_peer_state sta_state,
1714 bool roam_synch_in_progress)
1715{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301716 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001717 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001718 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1719 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1720 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721
1722 if (!pdev) {
1723 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301724 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 }
1726
1727 if (sta_id >= WLAN_MAX_STA_COUNT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001728 hdd_err("Invalid sta id :%d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301729 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 }
1731
Leo Changfdb45c32016-10-28 11:09:23 -07001732 peer = cdp_peer_find_by_local_id(soc, pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301734 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735
Leo Changfdb45c32016-10-28 11:09:23 -07001736 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001737 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001738 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001739 return QDF_STATUS_E_FAULT;
1740 }
1741
Leo Changfdb45c32016-10-28 11:09:23 -07001742 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301743 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001744 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301745 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 }
1747#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1748 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301749 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750#endif
1751
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001752 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1754 /* make sure event is reset */
1755 INIT_COMPLETION(pAdapter->sta_authorized_event);
1756#endif
1757
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001758 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 hdd_set_peer_authorized_event,
1760 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301761 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001762 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301763 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 }
1765
Krunal Sonibe766b02016-03-10 13:00:44 -08001766 if (pAdapter->device_mode == QDF_STA_MODE ||
1767 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001769 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 unsigned long rc;
1771
1772 /* wait for event from firmware to set the event */
1773 rc = wait_for_completion_timeout(
1774 &pAdapter->sta_authorized_event,
1775 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
1776 if (!rc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001777 hdd_notice("timeout waiting for sta_authorized_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 }
Leo Changfdb45c32016-10-28 11:09:23 -07001779 vdev = cdp_peer_get_vdev(soc, peer);
1780 cdp_fc_vdev_unpause(soc, vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001781 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782#endif
1783 }
1784 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301785 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786}
1787
1788/**
1789 * hdd_roam_register_sta() - register station
1790 * @pAdapter: pointer to adapter
1791 * @pRoamInfo: pointer to roam info
1792 * @staId: station identifier
1793 * @pPeerMacAddress: peer MAC address
1794 * @pBssDesc: pointer to BSS description
1795 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301796 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001798QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 tCsrRoamInfo *pRoamInfo,
1800 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301801 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 tSirBssDescription *pBssDesc)
1803{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 struct ol_txrx_desc_type staDesc = { 0 };
1806 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001807 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001808 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1809 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810
1811 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301812 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813
1814 /* Get the Station ID from the one saved during the association */
1815 staDesc.sta_id = staId;
1816
1817 /* set the QoS field appropriately */
1818 if (hdd_wmm_is_active(pAdapter))
1819 staDesc.is_qos_enabled = 1;
1820 else
1821 staDesc.is_qos_enabled = 0;
1822
1823#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001824 hdd_notice("WAPI STA Registered: %d",
1825 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 if (pAdapter->wapi_info.fIsWapiSta)
1827 staDesc.is_wapi_supported = 1;
1828 else
1829 staDesc.is_wapi_supported = 0;
1830#endif /* FEATURE_WLAN_WAPI */
1831
Dhanashri Atre50141c52016-04-07 13:15:29 -07001832 /* Register the vdev transmit and receive functions */
1833 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1834 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001835
1836 pAdapter->txrx_vdev = cdp_get_vdev_from_vdev_id(soc, pdev,
1837 pAdapter->sessionId);
1838 if (!pAdapter->txrx_vdev) {
1839 hdd_err("%s find vdev fail", __func__);
1840 return QDF_STATUS_E_FAILURE;
1841 }
1842
1843 txrx_ops.tx.tx = NULL;
1844 cdp_vdev_register(soc, pAdapter->txrx_vdev, pAdapter, &txrx_ops);
1845 if (!txrx_ops.tx.tx) {
1846 hdd_err("%s vdev register fail", __func__);
1847 return QDF_STATUS_E_FAILURE;
1848 }
1849
Dhanashri Atre50141c52016-04-07 13:15:29 -07001850 pAdapter->tx_fn = txrx_ops.tx.tx;
Leo Changfdb45c32016-10-28 11:09:23 -07001851 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301852 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001853 hdd_warn("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001854 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301855 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 }
1857
1858 if (!pRoamInfo->fAuthRequired) {
1859 /*
1860 * Connections that do not need Upper layer auth, transition
1861 * TLSHIM directly to 'Authenticated' state
1862 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301863 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001865 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1867 pRoamInfo->roamSynchInProgress
1868#else
1869 false
1870#endif
1871 );
1872
1873 hdd_conn_set_authenticated(pAdapter, true);
1874 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001875 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301877 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001879 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1881 pRoamInfo->roamSynchInProgress
1882#else
1883 false
1884#endif
1885 );
1886 hdd_conn_set_authenticated(pAdapter, false);
1887 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301888 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889}
1890
1891/**
1892 * hdd_send_re_assoc_event() - send reassoc event
1893 * @dev: pointer to net device
1894 * @pAdapter: pointer to adapter
1895 * @pCsrRoamInfo: pointer to roam info
1896 * @reqRsnIe: pointer to RSN Information element
1897 * @reqRsnLength: length of RSN IE
1898 *
1899 * Return: none
1900 */
1901static void hdd_send_re_assoc_event(struct net_device *dev,
1902 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
1903 uint8_t *reqRsnIe, uint32_t reqRsnLength)
1904{
1905 unsigned int len = 0;
1906 u8 *pFTAssocRsp = NULL;
1907 uint8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Naveen Rawat14298b92015-11-25 16:27:41 -08001908 uint8_t *assoc_req_ies = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909 uint32_t rspRsnLength = 0;
1910 struct ieee80211_channel *chan;
1911 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1912 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1913 uint8_t *buf_ptr, ssid_ie_len;
1914 struct cfg80211_bss *bss = NULL;
1915 uint8_t *final_req_ie = NULL;
1916 tCsrRoamConnectedProfile roam_profile;
1917 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1918
Jeff Johnsonfdb73432016-10-11 08:07:27 -07001919 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
1920
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001922 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001923 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 }
1925
Naveen Rawat14298b92015-11-25 16:27:41 -08001926 if (!assoc_req_ies) {
1927 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001928 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001929 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001931 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 goto done;
1933 }
1934
1935 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001936 hdd_err("Invalid assoc response length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 goto done;
1938 }
1939
1940 pFTAssocRsp =
1941 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1942 pCsrRoamInfo->nAssocReqLength);
1943 if (pFTAssocRsp == NULL)
1944 goto done;
1945
1946 /* pFTAssocRsp needs to point to the IEs */
1947 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001948 hdd_info("AssocRsp is now at %02x%02x",
1949 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950
1951 /*
1952 * Active session count is decremented upon disconnection, but during
1953 * roaming, there is no disconnect indication and hence active session
1954 * count is not decremented.
1955 * After roaming is completed, active session count is incremented
1956 * as a part of connect indication but effectively after roaming the
1957 * active session count should still be the same and hence upon
1958 * successful reassoc decrement the active session count here.
1959 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001960 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301961 cds_decr_session_set_pcl(pAdapter->device_mode,
1962 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963
1964 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
1965 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1966 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301967 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
1968 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969
1970 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1971 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
1973 &roam_profile);
1974 bss = cfg80211_get_bss(pAdapter->wdev.wiphy, chan,
1975 pCsrRoamInfo->bssid.bytes,
1976 &roam_profile.SSID.ssId[0], roam_profile.SSID.length,
Ryan Hsu535d16a2016-01-18 16:45:12 -08001977#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
Ryan Hsu535d16a2016-01-18 16:45:12 -08001979#else
1980 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
1981#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982
1983 if (bss == NULL)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001984 hdd_err("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 buf_ptr = buf_ssid_ie;
1986 *buf_ptr = SIR_MAC_SSID_EID;
1987 buf_ptr++;
1988 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
1989 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301990 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 roam_profile.SSID.length);
1992 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08001993 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301994 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08001995 buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 final_req_ie = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
1997 if (final_req_ie == NULL)
1998 goto done;
1999 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302000 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302002 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2003 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2004 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08002006 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302007 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002008 final_req_ie, (ssid_ie_len + reqRsnLength));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 cfg80211_roamed_bss(dev, bss,
2010 final_req_ie, (ssid_ie_len + reqRsnLength),
2011 rspRsnIe, rspRsnLength, GFP_KERNEL);
2012
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302013 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002014 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2015 pCsrRoamInfo->nAssocReqLength);
2016
2017 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302018 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002019 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2020
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002021 wlan_hdd_send_roam_auth_event(pHddCtx, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002022 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2023 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002024 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002026 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 if (final_req_ie)
2028 kfree(final_req_ie);
2029 kfree(rspRsnIe);
Naveen Rawat14298b92015-11-25 16:27:41 -08002030 kfree(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031}
2032
2033/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302034 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002035 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302036 *
2037 * Return: roam sync status if roaming offloaded else false
2038 */
2039#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002040bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302041{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002042 if (roaminfo)
2043 return roaminfo->roamSynchInProgress;
2044 else
2045 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302046}
2047#endif
2048
2049
2050/**
2051 * hdd_change_sta_state_authenticated()-
2052 * This function changes STA state to authenticated
2053 * @adapter: pointer to the adapter structure.
2054 * @roaminfo: pointer to the RoamInfo structure.
2055 *
2056 * This is called from hdd_RoamSetKeyCompleteHandler
2057 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2058 *
2059 * Return: 0 on success and errno on failure
2060 */
2061static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2062 tCsrRoamInfo *roaminfo)
2063{
2064 int ret;
Dustin Brownf660fb42016-09-09 12:04:00 -07002065 uint32_t timeout;
Govind Singhedc5cda2015-10-23 17:11:35 +05302066 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2067
Dustin Brownf660fb42016-09-09 12:04:00 -07002068 timeout = hddstactx->hdd_ReassocScenario ?
2069 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
2070 AUTO_DEFERRED_PS_ENTRY_TIMER_DEFAULT_VALUE;
2071
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002072 hdd_info("Changing TL state to AUTHENTICATED for StaId= %d",
2073 hddstactx->conn_info.staId[0]);
Govind Singhedc5cda2015-10-23 17:11:35 +05302074
2075 /* Connections that do not need Upper layer authentication,
2076 * transition TL to 'Authenticated' state after the keys are set
2077 */
2078 ret = hdd_change_peer_state(adapter,
2079 hddstactx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002080 OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302081 hdd_is_roam_sync_in_progress(roaminfo));
2082 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08002083 if ((QDF_STA_MODE == adapter->device_mode) ||
2084 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302085 sme_ps_enable_auto_ps_timer(
2086 WLAN_HDD_GET_HAL_CTX(adapter),
2087 adapter->sessionId,
Dustin Brownf660fb42016-09-09 12:04:00 -07002088 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302089 }
2090
2091 return ret;
2092}
2093
2094/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 * hdd_roam_set_key_complete_handler() - Update the security parameters
2096 * @pAdapter: pointer to adapter
2097 * @pRoamInfo: pointer to roam info
2098 * @roamId: roam id
2099 * @roamStatus: roam status
2100 * @roamResult: roam result
2101 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302102 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302104static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 tCsrRoamInfo *pRoamInfo,
2106 uint32_t roamId,
2107 eRoamCmdStatus roamStatus,
2108 eCsrRoamResult roamResult)
2109{
2110 eCsrEncryptionType connectedCipherAlgo;
2111 bool fConnected = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302112 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302114 tHalHandle hal_ctx = WLAN_HDD_GET_HAL_CTX(pAdapter);
2115 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
2116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 ENTER();
2118
2119 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002120 hdd_info("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302121 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 }
2123 /*
2124 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2125 * then go to 'authenticated'. For all other authentication types
2126 * (those that do not require upper layer authentication) we can put TL
2127 * directly into 'authenticated' state.
2128 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002129 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 MAC_ADDRESS_STR, roamStatus, roamResult,
2131 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2132
2133 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2134 &connectedCipherAlgo);
2135 if (fConnected) {
Krunal Sonibe766b02016-03-10 13:00:44 -08002136 if (QDF_IBSS_MODE == pAdapter->device_mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 uint8_t staId;
2138
Anurag Chouhanc5548422016-02-24 18:33:27 +05302139 if (qdf_is_macaddr_broadcast(&pRoamInfo->peerMac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 pHddStaCtx->roam_info.roamingState =
2141 HDD_ROAM_STATE_NONE;
2142 } else {
Deepak Dhamdhere5872c8c2016-06-02 15:51:47 -07002143 qdf_status = hdd_get_peer_sta_id(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 pHddStaCtx,
2145 &pRoamInfo->peerMac,
2146 &staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302147 if (QDF_STATUS_SUCCESS == qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002148 hdd_info("WLAN TL STA Ptk Installed for STAID=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 staId);
2150 pHddStaCtx->roam_info.roamingState =
2151 HDD_ROAM_STATE_NONE;
2152 }
2153 }
2154 } else {
2155 /*
2156 * TODO: Considering getting a state machine in
Govind Singhedc5cda2015-10-23 17:11:35 +05302157 * HDD later.This routine is invoked twice.
2158 * 1)set PTK 2)set GTK.The following if
2159 * statement will be TRUE when setting GTK.
2160 * At this time we don't handle the state in detail.
2161 * Related CR: 174048 - TL not in authenticated state
2162 */
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302163 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302164 pHddStaCtx->conn_info.gtk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302165 /*
2166 * PTK exchange happens in preauthentication
2167 * itself if key_mgmt is FT-PSK, ptk_installed
2168 * was false as there is no set PTK after
2169 * roaming. STA TL state moves to authenticated
2170 * only if ptk_installed is true. So, make
2171 * ptk_installed to true in case of 11R roaming.
2172 */
2173 if (csr_neighbor_roam_is11r_assoc(mac_ctx,
2174 pAdapter->sessionId))
2175 pHddStaCtx->conn_info.ptk_installed =
2176 true;
2177 } else {
Govind Singhedc5cda2015-10-23 17:11:35 +05302178 pHddStaCtx->conn_info.ptk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302179 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302180
2181 /* In WPA case move STA to authenticated when
2182 * ptk is installed.Earlier in WEP case STA
2183 * was moved to AUTHENTICATED prior to setting
2184 * the unicast key and it was resulting in sending
2185 * few un-encrypted packet. Now in WEP case
2186 * STA state will be moved to AUTHENTICATED
2187 * after we set the unicast and broadcast key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 */
Govind Singhedc5cda2015-10-23 17:11:35 +05302189 if ((pHddStaCtx->conn_info.ucEncryptionType ==
2190 eCSR_ENCRYPT_TYPE_WEP40) ||
2191 (pHddStaCtx->conn_info.ucEncryptionType ==
2192 eCSR_ENCRYPT_TYPE_WEP104) ||
2193 (pHddStaCtx->conn_info.ucEncryptionType ==
2194 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2195 (pHddStaCtx->conn_info.ucEncryptionType ==
2196 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2197 if (pHddStaCtx->conn_info.gtk_installed &&
2198 pHddStaCtx->conn_info.ptk_installed)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302199 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302200 hdd_change_sta_state_authenticated(pAdapter,
2201 pRoamInfo);
2202 } else if (pHddStaCtx->conn_info.ptk_installed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302203 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302204 hdd_change_sta_state_authenticated(pAdapter,
2205 pRoamInfo);
2206 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207
Govind Singhedc5cda2015-10-23 17:11:35 +05302208 if (pHddStaCtx->conn_info.gtk_installed &&
2209 pHddStaCtx->conn_info.ptk_installed) {
2210 pHddStaCtx->conn_info.gtk_installed = false;
2211 pHddStaCtx->conn_info.ptk_installed = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 }
2213
2214 pHddStaCtx->roam_info.roamingState =
Govind Singhedc5cda2015-10-23 17:11:35 +05302215 HDD_ROAM_STATE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 }
2217 } else {
2218 /*
2219 * possible disassoc after issuing set key and waiting
2220 * set key complete.
2221 */
2222 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2223 }
2224
2225 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302226 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227}
2228
2229/**
2230 * hdd_perform_roam_set_key_complete() - perform set key complete
2231 * @pAdapter: pointer to adapter
2232 *
2233 * Return: none
2234 */
2235void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2236{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302237 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2239 tCsrRoamInfo roamInfo;
2240 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302241 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302242 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302243 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302244 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302246 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 hdd_roam_set_key_complete_handler(pAdapter,
2248 &roamInfo,
2249 pHddStaCtx->roam_info.roamId,
2250 pHddStaCtx->roam_info.roamStatus,
2251 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302252 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002253 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254
2255 pHddStaCtx->roam_info.deferKeyComplete = false;
2256}
2257
2258/**
2259 * hdd_association_completion_handler() - association completion handler
2260 * @pAdapter: pointer to adapter
2261 * @pRoamInfo: pointer to roam info
2262 * @roamId: roam id
2263 * @roamStatus: roam status
2264 * @roamResult: roam result
2265 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302266 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302268static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 tCsrRoamInfo *pRoamInfo,
2270 uint32_t roamId,
2271 eRoamCmdStatus roamStatus,
2272 eCsrRoamResult roamResult)
2273{
2274 struct net_device *dev = pAdapter->dev;
2275 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2276 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302277 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2279 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 bool hddDisconInProgress = false;
2282 unsigned long rc;
2283
2284 if (!pHddCtx) {
2285 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302286 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 }
2288
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302289 /* validate config */
2290 if (!pHddCtx->config) {
2291 hdd_err("config is NULL");
2292 return QDF_STATUS_E_NULL_VALUE;
2293 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 /* HDD has initiated disconnect, do not send connect result indication
2295 * to kernel as it will be handled by __cfg80211_disconnect.
2296 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302297 if (((eConnectionState_Disconnecting ==
2298 pHddStaCtx->conn_info.connState) ||
2299 (eConnectionState_NotConnected ==
2300 pHddStaCtx->conn_info.connState)) &&
2301 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2302 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002303 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 hddDisconInProgress = true;
2305 }
2306
2307 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2308 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002309 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302310 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311 }
2312 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 hdd_conn_set_connection_state(pAdapter,
2314 eConnectionState_Associated);
2315 }
2316 /* Save the connection info from CSR... */
2317 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2318 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002319
2320 if (hdd_add_beacon_filter(pAdapter) != 0)
2321 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322#ifdef FEATURE_WLAN_WAPI
2323 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2324 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2325 || pRoamInfo->u.pConnectedProfile->AuthType ==
2326 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2327 pAdapter->wapi_info.fIsWapiSta = 1;
2328 } else {
2329 pAdapter->wapi_info.fIsWapiSta = 0;
2330 }
2331#endif /* FEATURE_WLAN_WAPI */
2332
2333 /* Indicate 'connect' status to user space */
2334 hdd_send_association_event(dev, pRoamInfo);
2335
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002336 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 if (pHddCtx->miracast_value)
2338 cds_set_mas(pAdapter, pHddCtx->miracast_value);
2339 }
2340
2341 /* Initialize the Linkup event completion variable */
2342 INIT_COMPLETION(pAdapter->linkup_event_var);
2343
2344 /*
2345 * Sometimes Switching ON the Carrier is taking time to activate
2346 * the device properly. Before allowing any packet to go up to
2347 * the application, device activation has to be ensured for
2348 * proper queue mapping by the kernel. we have registered net
2349 * device notifier for device change notification. With this we
2350 * will come to know that the device is getting
2351 * activated properly.
2352 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002354 /*
2355 * Enable Linkup Event Servicing which allows the net
2356 * device notifier to set the linkup event variable.
2357 */
2358 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002360 /* Switch on the Carrier to activate the device */
2361 wlan_hdd_netif_queue_control(pAdapter,
2362 WLAN_NETIF_CARRIER_ON,
2363 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002365 /*
2366 * Wait for the Link to up to ensure all the queues
2367 * are set properly by the kernel.
2368 */
2369 rc = wait_for_completion_timeout(
2370 &pAdapter->linkup_event_var,
2371 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2372 );
2373 if (!rc)
2374 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002376 /*
2377 * Disable Linkup Event Servicing - no more service
2378 * required from the net device notifier call.
2379 */
2380 pAdapter->isLinkUpSvcNeeded = false;
2381 } else {
2382 pHddStaCtx->ft_carrier_on = false;
2383 ft_carrier_on = true;
2384 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002385 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2386 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2387 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002388 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389
2390 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2391
2392 if (hdd_ipa_is_enabled(pHddCtx))
2393 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002394 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 pRoamInfo->bssid.bytes);
2396
2397#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2398 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2399#endif
2400
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302401 hdd_info("check for SAP restart");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002402 cds_check_concurrent_intf_and_restart_sap(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403
Nirav Shah1da77682016-05-03 20:16:39 +05302404 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2405 pAdapter->sessionId,
2406 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 /*
2409 * For reassoc, the station is already registered, all we need
2410 * is to change the state of the STA in TL.
2411 * If authentication is required (WPA/WPA2/DWEP), change TL to
2412 * CONNECTED instead of AUTHENTICATED.
2413 */
2414 if (!pRoamInfo->fReassocReq) {
2415 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 u8 *pFTAssocRsp = NULL;
2417 unsigned int assocRsplen = 0;
2418 u8 *pFTAssocReq = NULL;
2419 unsigned int assocReqlen = 0;
2420 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2422 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2423
2424 /* add bss_id to cfg80211 data base */
2425 bss =
2426 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2427 pRoamInfo);
2428 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302429 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 wlan_hdd_netif_queue_control(pAdapter,
2431 WLAN_NETIF_CARRIER_OFF,
2432 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302433 if (!hddDisconInProgress) {
2434 /*
2435 * Here driver was not able to add bss
2436 * in cfg80211 database this can happen
2437 * if connected channel is not valid,
2438 * i.e reg domain was changed during
2439 * connection. Queue disconnect for the
2440 * session if disconnect is not in
2441 * progress.
2442 */
2443 hdd_err("Disconnecting...");
2444 sme_roam_disconnect(
2445 WLAN_HDD_GET_HAL_CTX(pAdapter),
2446 pAdapter->sessionId,
2447 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2448 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302449 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2452 eCSR_AUTH_TYPE_FT_RSN
2453 || pRoamInfo->u.pConnectedProfile->AuthType ==
2454 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2455
2456 /* Association Response */
2457 pFTAssocRsp =
2458 (u8 *) (pRoamInfo->pbFrames +
2459 pRoamInfo->nBeaconLength +
2460 pRoamInfo->nAssocReqLength);
2461 if (pFTAssocRsp != NULL) {
2462 /*
2463 * pFTAssocRsp needs to point to the IEs
2464 */
2465 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002466 hdd_info("AssocRsp is now at %02x%02x",
2467 (unsigned int)pFTAssocRsp[0],
2468 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 assocRsplen =
2470 pRoamInfo->nAssocRspLength -
2471 FT_ASSOC_RSP_IES_OFFSET;
2472 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002473 hdd_err("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 assocRsplen = 0;
2475 }
2476
2477 /* Association Request */
2478 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2479 pRoamInfo->nBeaconLength);
2480 if (pFTAssocReq != NULL) {
2481 if (!ft_carrier_on) {
2482 /*
2483 * pFTAssocReq needs to point to
2484 * the IEs
2485 */
2486 pFTAssocReq +=
2487 FT_ASSOC_REQ_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002488 hdd_info("pFTAssocReq is now at %02x%02x",
2489 (unsigned int)
2490 pFTAssocReq[0],
2491 (unsigned int)
2492 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 assocReqlen =
2494 pRoamInfo->nAssocReqLength -
2495 FT_ASSOC_REQ_IES_OFFSET;
2496 } else {
2497 /*
2498 * This should contain only the
2499 * FTIEs
2500 */
2501 assocReqlen =
2502 pRoamInfo->nAssocReqLength;
2503 }
2504 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002505 hdd_err("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506 assocReqlen = 0;
2507 }
2508
2509 if (ft_carrier_on) {
2510 if (!hddDisconInProgress) {
2511 /*
2512 * After roaming is completed,
2513 * active session count is
2514 * incremented as a part of
2515 * connect indication but
2516 * effectively the active
2517 * session count should still
2518 * be the same and hence upon
2519 * successful reassoc
2520 * decrement the active session
2521 * count here.
2522 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002523 if (!hdd_is_roam_sync_in_progress
2524 (pRoamInfo))
2525 cds_decr_session_set_pcl
2526 (pAdapter->device_mode,
2527 pAdapter->sessionId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002528 hdd_info("ft_carrier_on is %d, sending roamed indication",
2529 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530 chan =
2531 ieee80211_get_channel
2532 (pAdapter->wdev.wiphy,
2533 (int)pRoamInfo->pBssDesc->
2534 channelId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002535 hdd_info(
2536 "assocReqlen %d assocRsplen %d",
2537 assocReqlen,
2538 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002539
2540 hdd_notice(
2541 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302542 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302543 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302544 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002545 pFTAssocReq,
2546 assocReqlen);
2547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548 cfg80211_roamed(dev, chan,
2549 pRoamInfo->
2550 bssid.bytes,
2551 pFTAssocReq,
2552 assocReqlen,
2553 pFTAssocRsp,
2554 assocRsplen,
2555 GFP_KERNEL);
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002556 wlan_hdd_send_roam_auth_event(
2557 pHddCtx,
2558 pRoamInfo->bssid.bytes,
2559 pFTAssocReq,
2560 assocReqlen,
2561 pFTAssocRsp,
2562 assocRsplen,
2563 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 }
2565 if (sme_get_ftptk_state
2566 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2567 pAdapter->sessionId)) {
2568 sme_set_ftptk_state
2569 (WLAN_HDD_GET_HAL_CTX
2570 (pAdapter),
2571 pAdapter->sessionId,
2572 false);
2573 pRoamInfo->fAuthRequired =
2574 false;
2575
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302576 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 roam_info.bssid,
2578 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302579 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302580 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 roam_info.peerMac,
2582 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302583 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 pHddStaCtx->roam_info.roamId =
2585 roamId;
2586 pHddStaCtx->roam_info.
2587 roamStatus = roamStatus;
2588 pHddStaCtx->roam_info.
2589 deferKeyComplete = true;
2590 }
2591 } else if (!hddDisconInProgress) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002592 hdd_info("ft_carrier_on is %d, sending connect indication",
2593 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302594 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 pRoamInfo->
2596 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302597 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 pFTAssocReq,
2599 assocReqlen,
2600 pFTAssocRsp,
2601 assocRsplen,
2602 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302603 GFP_KERNEL,
2604 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002606 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 /*
2608 * wpa supplicant expecting WPA/RSN IE in
2609 * connect result.
2610 */
2611 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2612 (pAdapter),
2613 pAdapter->sessionId,
2614 &reqRsnLength,
2615 reqRsnIe);
2616
2617 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2618 (pAdapter),
2619 pAdapter->sessionId,
2620 &rspRsnLength,
2621 rspRsnIe);
2622 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 if (ft_carrier_on)
2624 hdd_send_re_assoc_event(dev,
2625 pAdapter,
2626 pRoamInfo,
2627 reqRsnIe,
2628 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002629 else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002630 hdd_info("sending connect indication to nl80211:for bssid "
2631 MAC_ADDRESS_STR
2632 " result:%d and Status:%d",
2633 MAC_ADDR_ARRAY
2634 (pRoamInfo->bssid.bytes),
2635 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636
2637 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302638 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 pRoamInfo->
2640 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302641 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 reqRsnIe,
2643 reqRsnLength,
2644 rspRsnIe,
2645 rspRsnLength,
2646 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302647 GFP_KERNEL,
2648 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 }
2650 }
2651 }
2652 if (!hddDisconInProgress) {
2653 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 bss);
2656
2657 /*
2658 * Perform any WMM-related association
2659 * processing.
2660 */
2661 hdd_wmm_assoc(pAdapter, pRoamInfo,
2662 eCSR_BSS_TYPE_INFRASTRUCTURE);
2663
2664 /*
2665 * Start the Queue - Start tx queues before
2666 * hdd_roam_register_sta, since
2667 * hdd_roam_register_sta will flush any cached
2668 * data frames immediately.
2669 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002670 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 wlan_hdd_netif_queue_control(pAdapter,
2672 WLAN_WAKE_ALL_NETIF_QUEUE,
2673 WLAN_CONTROL_PATH);
2674
2675 /*
2676 * Register the Station with TL after associated
2677 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302678 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 pRoamInfo,
2680 pHddStaCtx->
2681 conn_info.
2682 staId[0],
2683 NULL,
2684 pRoamInfo->
2685 pBssDesc);
2686 }
2687 } else {
2688 /*
2689 * wpa supplicant expecting WPA/RSN IE in connect result
2690 * in case of reassociation also need to indicate it to
2691 * supplicant.
2692 */
2693 csr_roam_get_wpa_rsn_req_ie(
2694 WLAN_HDD_GET_HAL_CTX(pAdapter),
2695 pAdapter->sessionId,
2696 &reqRsnLength, reqRsnIe);
2697
2698 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2699 reqRsnIe, reqRsnLength);
2700 /* Reassoc successfully */
2701 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302702 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 hdd_change_peer_state(pAdapter,
2704 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002705 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2707 pRoamInfo->roamSynchInProgress
2708#else
2709 false
2710#endif
2711 );
2712 hdd_conn_set_authenticated(pAdapter, false);
2713 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002714 hdd_info("staId: %d Changing TL state to AUTHENTICATED",
2715 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302716 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 hdd_change_peer_state(pAdapter,
2718 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002719 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2721 pRoamInfo->roamSynchInProgress
2722#else
2723 false
2724#endif
2725 );
2726 hdd_conn_set_authenticated(pAdapter, true);
2727 }
2728
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302729 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 /*
2731 * Perform any WMM-related association
2732 * processing
2733 */
2734 hdd_wmm_assoc(pAdapter, pRoamInfo,
2735 eCSR_BSS_TYPE_INFRASTRUCTURE);
2736 }
2737
2738 /* Start the tx queues */
2739#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2740 if (pRoamInfo->roamSynchInProgress)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002741 hdd_info("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002743 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 wlan_hdd_netif_queue_control(pAdapter,
2745 WLAN_WAKE_ALL_NETIF_QUEUE,
2746 WLAN_CONTROL_PATH);
2747 }
2748
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302749#ifdef FEATURE_WLAN_TDLS
2750 wlan_hdd_tdls_connection_callback(pAdapter);
2751#endif
2752
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302753 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002754 hdd_err("STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302755 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 }
2757#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302758 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 sizeof(pAdapter->hdd_stats.hddPmfStats));
2760#endif
2761 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302762 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 hdd_wext_state_t *pWextState =
2764 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2765 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302766 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2767 " result:%d and Status:%d",
2768 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2769 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302771 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2772 " result:%d and Status:%d",
2773 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2774 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302775
2776 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2777 (pRoamInfo &&
2778 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2779 pRoamInfo->statusCode) ||
2780 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2781 pRoamInfo->statusCode) ||
2782 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2783 pRoamInfo->statusCode)))) {
2784 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2785 pRoamInfo ?
2786 pRoamInfo->bssid.bytes :
2787 pWextState->req_bssId.bytes);
2788 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2789 pRoamInfo ?
2790 pRoamInfo->bssid.bytes :
2791 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05302792 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05302793 }
2794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 /*
2796 * CR465478: Only send up a connection failure result when CSR
2797 * has completed operation - with a ASSOCIATION_FAILURE status.
2798 */
2799 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2800 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302801 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002802 hdd_err("send connect failure to nl80211: for bssid "
2803 MAC_ADDRESS_STR
2804 " result:%d and Status:%d reasoncode %d",
2805 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2806 roamResult, roamStatus,
2807 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302808 pHddStaCtx->conn_info.assoc_status_code =
2809 pRoamInfo->statusCode;
2810 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002812 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 MAC_ADDRESS_STR
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002814 " result:%d and Status:%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2816 roamResult, roamStatus);
2817
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 /* inform association failure event to nl80211 */
2819 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
2820 roamResult) {
2821 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302822 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302824 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302826 GFP_KERNEL,
2827 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302829 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302831 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002832 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302833 GFP_KERNEL,
2834 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 } else {
2836 if (pRoamInfo) {
2837 eCsrAuthType authType =
2838 pWextState->roamProfile.AuthType.
2839 authType[0];
Abhishek Singhac2be142015-12-03 16:16:25 +05302840 eCsrEncryptionType encryption_type =
2841 pWextState->roamProfile.
2842 EncryptionType.encryptionType[0];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 bool isWep =
Abhishek Singhac2be142015-12-03 16:16:25 +05302844 (((authType ==
2845 eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 (authType ==
Abhishek Singhac2be142015-12-03 16:16:25 +05302847 eCSR_AUTH_TYPE_SHARED_KEY)) &&
2848 ((encryption_type ==
2849 eCSR_ENCRYPT_TYPE_WEP40) ||
2850 (encryption_type ==
2851 eCSR_ENCRYPT_TYPE_WEP104) ||
2852 (encryption_type ==
2853 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2854 (encryption_type ==
2855 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 /*
2857 * In case of OPEN-WEP or SHARED-WEP
2858 * authentication, send exact protocol
2859 * reason code. This enables user
2860 * applications to reconnect the station
2861 * with correct configuration.
2862 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302863 hdd_connect_result(dev,
2864 pRoamInfo->bssid.bytes,
2865 NULL, NULL, 0, NULL, 0,
Abhishek Singhac2be142015-12-03 16:16:25 +05302866 (isWep &&
2867 pRoamInfo->reasonCode) ?
2868 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302870 GFP_KERNEL,
2871 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 } else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302873 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302875 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302877 GFP_KERNEL,
2878 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 }
Abhishek Singhac2be142015-12-03 16:16:25 +05302880 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002881 } else if ((eCSR_ROAM_CANCELLED == roamStatus
2882 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05302883 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002884 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05302885 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002886 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302887 GFP_KERNEL,
2888 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 }
2890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 /*
2892 * Set connection state to eConnectionState_NotConnected only
2893 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002894 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002896 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
2897 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 hdd_conn_set_connection_state(pAdapter,
2900 eConnectionState_NotConnected);
2901 }
2902 hdd_wmm_init(pAdapter);
2903
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002904 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 wlan_hdd_netif_queue_control(pAdapter,
2906 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2907 WLAN_CONTROL_PATH);
2908 }
2909
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302910 if (QDF_STATUS_SUCCESS != cds_check_and_restart_sap(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 roamResult, pHddStaCtx))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302912 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913
Govind Singh24db1ed2015-12-18 15:54:59 +05302914 if (NULL != pRoamInfo && NULL != pRoamInfo->pBssDesc) {
2915 cds_force_sap_on_scc(roamResult,
2916 pRoamInfo->pBssDesc->channelId);
2917 } else {
2918 hdd_err("pRoamInfo profile is not set properly");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302919 return QDF_STATUS_E_FAILURE;
Govind Singh24db1ed2015-12-18 15:54:59 +05302920 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302922 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923}
2924
2925/**
2926 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
2927 * @pAdapter: pointer to adapter
2928 * @pRoamInfo: pointer to roam info
2929 * @roamId: roam id
2930 * @roamStatus: roam status
2931 * @roamResult: roam result
2932 *
2933 * Here we update the status of the Ibss when we receive information that we
2934 * have started/joined an ibss session.
2935 *
2936 * Return: none
2937 */
2938static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
2939 tCsrRoamInfo *pRoamInfo,
2940 uint32_t roamId,
2941 eRoamCmdStatus roamStatus,
2942 eCsrRoamResult roamResult)
2943{
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002944 hdd_info("%s: id %d, status %d, result %d",
2945 pAdapter->dev->name, roamId,
2946 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947
2948 switch (roamResult) {
2949 /* both IBSS Started and IBSS Join should come in here. */
2950 case eCSR_ROAM_RESULT_IBSS_STARTED:
2951 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
2952 case eCSR_ROAM_RESULT_IBSS_COALESCED:
2953 {
2954 hdd_context_t *pHddCtx =
2955 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302956 hdd_station_ctx_t *hdd_sta_ctx =
2957 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302958 struct qdf_mac_addr broadcastMacAddr =
2959 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960
2961 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302962 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 return;
2964 }
2965
2966 /* When IBSS Started comes from CSR, we need to move
2967 * connection state to IBSS Disconnected (meaning no peers
2968 * are in the IBSS).
2969 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 hdd_conn_set_connection_state(pAdapter,
2971 eConnectionState_IbssDisconnected);
2972 /* notify wmm */
2973 hdd_wmm_connect(pAdapter, pRoamInfo,
2974 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302975
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07002976 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302977
2978 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 pAdapter;
2980 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302981 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 &broadcastMacAddr,
2983 pRoamInfo->pBssDesc);
2984
2985 if (pRoamInfo->pBssDesc) {
2986 struct cfg80211_bss *bss;
2987#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
2988 struct ieee80211_channel *chan;
2989 int chan_no;
2990 unsigned int freq;
2991#endif
2992 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002993 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
2994 pAdapter->dev->name,
2995 MAC_ADDR_ARRAY(
2996 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997
2998 /* we must first give cfg80211 the BSS information */
2999 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3000 pRoamInfo);
3001 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003002 hdd_err("%s: unable to create IBSS entry",
3003 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 return;
3005 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003006 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 wlan_hdd_netif_queue_control(pAdapter,
3008 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3009 WLAN_CONTROL_PATH);
3010
3011#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3012 chan_no = pRoamInfo->pBssDesc->channelId;
3013
3014 if (chan_no <= 14)
3015 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003016 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 else
3018 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003019 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020
3021 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3022
3023 if (chan)
3024 cfg80211_ibss_joined(pAdapter->dev,
3025 bss->bssid, chan,
3026 GFP_KERNEL);
3027 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003028 hdd_err("%s: chanId: %d, can't find channel",
3029 pAdapter->dev->name,
3030 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031#else
3032 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3033 GFP_KERNEL);
3034#endif
3035 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 bss);
3038 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003039 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003040 cds_incr_active_session(pAdapter->device_mode,
Krunal Soni2c68f232015-10-26 20:52:51 -07003041 pAdapter->sessionId);
3042 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3043 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003044 cds_update_connection_info(pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003045 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 break;
3047 }
3048
3049 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3050 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003051 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 break;
3053 }
3054
3055 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003056 hdd_err("%s: unexpected result %d",
3057 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 break;
3059 }
3060
3061 return;
3062}
3063
3064/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003065 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3066 * @sta_ctx: pointer to hdd station context
3067 * @sta_id: station ID
3068 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 *
3070 * This information is passed to iwconfig later. The peer that joined
3071 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003072
3073 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003075bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3076 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003078 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003080 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3081 if (0 == sta_ctx->conn_info.staId[idx]) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003082 hdd_info("adding peer: %pM, sta_id: %d, at idx: %d",
3083 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003084 sta_ctx->conn_info.staId[idx] = sta_id;
3085 qdf_copy_macaddr(
3086 &sta_ctx->conn_info.peerMacAddress[idx],
3087 peer_mac_addr);
3088 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 }
3090 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003091 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092}
3093
3094/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003095 * hdd_delete_peer() - removes peer from hdd station context peer table
3096 * @sta_ctx: pointer to hdd station context
3097 * @sta_id: station ID
3098 *
3099 * Return: None
3100 */
3101void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3102{
3103 int i;
3104
3105 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3106 if (sta_id == sta_ctx->conn_info.staId[i]) {
3107 sta_ctx->conn_info.staId[i] = 0;
3108 return;
3109 }
3110 }
3111
3112 hdd_err(FL("sta_id %d is not present in peer table"), sta_id);
3113}
3114
3115/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3117 * @pAdapter: pointer to adapter
3118 * @staId: station id
3119 *
3120 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003121 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 * false otherwise.
3123 */
3124static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3125{
3126 bool fSuccess = false;
3127 int idx = 0;
3128 uint8_t valid_idx = 0;
3129 uint8_t del_idx = 0;
3130 uint8_t empty_slots = 0;
3131 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3132
Naveen Rawatc45d1622016-07-05 12:20:09 -07003133 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3135 pHddStaCtx->conn_info.staId[idx] = 0;
3136
Anurag Chouhanc5548422016-02-24 18:33:27 +05303137 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 peerMacAddress[idx]);
3139
3140 fSuccess = true;
3141
3142 /*
3143 * Note the deleted Index, if its 0 we need special
3144 * handling.
3145 */
3146 del_idx = idx;
3147
3148 empty_slots++;
3149 } else {
3150 if (pHddStaCtx->conn_info.staId[idx] != 0) {
3151 valid_idx = idx;
3152 } else {
3153 /* Found an empty slot */
3154 empty_slots++;
3155 }
3156 }
3157 }
3158
Naveen Rawatc45d1622016-07-05 12:20:09 -07003159 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 /* Last peer departed, set the IBSS state appropriately */
3161 pHddStaCtx->conn_info.connState =
3162 eConnectionState_IbssDisconnected;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003163 hdd_err("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 }
3165 /* Find next active staId, to have a valid sta trigger for TL. */
3166 if (fSuccess == true) {
3167 if (del_idx == 0) {
3168 if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
3169 pHddStaCtx->conn_info.staId[0] =
3170 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303171 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 peerMacAddress[0],
3173 &pHddStaCtx->conn_info.
3174 peerMacAddress[valid_idx]);
3175
3176 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303177 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 peerMacAddress[valid_idx]);
3179 }
3180 }
3181 }
3182 return fSuccess;
3183}
3184
3185/**
3186 * roam_ibss_connect_handler() - IBSS connection handler
3187 * @pAdapter: pointer to adapter
3188 * @pRoamInfo: pointer to roam info
3189 *
3190 * We update the status of the IBSS to connected in this function.
3191 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303192 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303194static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 tCsrRoamInfo *pRoamInfo)
3196{
3197 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 /*
3199 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3200 * a partner stations).
3201 */
3202 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3203
3204 /* Save the connection info from CSR... */
3205 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3206
3207 /* Send the bssid address to the wext. */
3208 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3209 /* add bss_id to cfg80211 data base */
3210 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3211 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003212 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303214 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 }
3216 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 bss);
3219
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303220 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221}
3222
3223/**
3224 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3225 * @pAdapter: pointer to adapter
3226 * @pRoamInfo: pointer to roam info
3227 * @roamId: roam id
3228 * @roamStatus: roam status
3229 * @roamResult: roam result
3230 *
3231 * This function indicates the Mic failure to the supplicant
3232 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303233 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303235static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3237 tCsrRoamInfo *pRoamInfo,
3238 uint32_t roamId,
3239 eRoamCmdStatus roamStatus,
3240 eCsrRoamResult roamResult)
3241{
3242 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3243
3244 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3245 TKIP_COUNTER_MEASURE_STOPED ==
3246 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3247 struct iw_michaelmicfailure msg;
3248 union iwreq_data wreq;
3249 memset(&msg, '\0', sizeof(msg));
3250 msg.src_addr.sa_family = ARPHRD_ETHER;
3251 memcpy(msg.src_addr.sa_data,
3252 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3253 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003254 hdd_info("MIC MAC " MAC_ADDRESS_STR,
3255 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256
3257 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3258 msg.flags = IW_MICFAILURE_GROUP;
3259 else
3260 msg.flags = IW_MICFAILURE_PAIRWISE;
3261 memset(&wreq, 0, sizeof(wreq));
3262 wreq.data.length = sizeof(msg);
3263 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3264 (char *)&msg);
3265 /* inform mic failure to nl80211 */
3266 cfg80211_michael_mic_failure(pAdapter->dev,
3267 pRoamInfo->u.pMICFailureInfo->
3268 taMacAddr,
3269 ((pRoamInfo->u.pMICFailureInfo->
3270 multicast ==
3271 eSIR_TRUE) ?
3272 NL80211_KEYTYPE_GROUP :
3273 NL80211_KEYTYPE_PAIRWISE),
3274 pRoamInfo->u.pMICFailureInfo->
3275 keyId,
3276 pRoamInfo->u.pMICFailureInfo->TSC,
3277 GFP_KERNEL);
3278
3279 }
3280
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303281 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282}
3283
3284/**
3285 * roam_roam_connect_status_update_handler() - IBSS connect status update
3286 * @pAdapter: pointer to adapter
3287 * @pRoamInfo: pointer to roam info
3288 * @roamId: roam id
3289 * @roamStatus: roam status
3290 * @roamResult: roam result
3291 *
3292 * The Ibss connection status is updated regularly here in this function.
3293 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303294 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303296static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3298 tCsrRoamInfo *pRoamInfo,
3299 uint32_t roamId,
3300 eRoamCmdStatus roamStatus,
3301 eCsrRoamResult roamResult)
3302{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303303 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304
3305 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3306 switch (roamResult) {
3307 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3308 {
3309 hdd_station_ctx_t *pHddStaCtx =
3310 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003311 struct station_info *stainfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303313 hdd_err("IBSS New Peer indication from SME "
3314 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3315 MAC_ADDRESS_STR " and stationID= %d",
3316 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3317 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3318 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003320 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3322 pRoamInfo->staId,
3323 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003324 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 break;
3326 }
3327
3328 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3329
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303331 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 pRoamInfo,
3333 pRoamInfo->staId,
3334 &pRoamInfo->peerMac,
3335 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303336 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003337 hdd_err("Cannot register STA with TL for IBSS. Failed with qdf_status = %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303338 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 }
3340 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003341 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3342 if (stainfo == NULL) {
3343 hdd_err("memory allocation for station_info failed");
3344 return QDF_STATUS_E_NOMEM;
3345 }
3346 stainfo->filled = 0;
3347 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348
3349 cfg80211_new_sta(pAdapter->dev,
3350 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003351 stainfo, GFP_KERNEL);
3352 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353
3354 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
3355 pHddStaCtx->ibss_enc_key.encType
3356 || eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
3357 pHddStaCtx->ibss_enc_key.encType
3358 || eCSR_ENCRYPT_TYPE_TKIP ==
3359 pHddStaCtx->ibss_enc_key.encType
3360 || eCSR_ENCRYPT_TYPE_AES ==
3361 pHddStaCtx->ibss_enc_key.encType) {
3362 pHddStaCtx->ibss_enc_key.keyDirection =
3363 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303364 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 &pRoamInfo->peerMac);
3366
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003367 hdd_info("New peer joined set PTK encType=%d",
3368 pHddStaCtx->ibss_enc_key.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3372 (pAdapter),
3373 pAdapter->sessionId,
3374 &pHddStaCtx->ibss_enc_key,
3375 &roamId);
3376
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303377 if (QDF_STATUS_SUCCESS != qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003378 hdd_err("sme_roam_set_key failed, status=%d",
3379 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303380 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 }
3382 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003383 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 wlan_hdd_netif_queue_control(pAdapter,
3385 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3386 WLAN_CONTROL_PATH);
3387 break;
3388 }
3389
3390 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3391 {
3392
3393 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3394
3395 break;
3396 }
3397 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3398 {
3399 hdd_station_ctx_t *pHddStaCtx =
3400 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3401
3402 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003403 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303405 hdd_err("IBSS Peer Departed from SME "
3406 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3407 MAC_ADDRESS_STR " and stationID= %d",
3408 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3409 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3410 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411
3412 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3413
3414 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3415 pHddStaCtx->ibss_sta_generation++;
3416
3417 cfg80211_del_sta(pAdapter->dev,
3418 (const u8 *)&pRoamInfo->peerMac.bytes,
3419 GFP_KERNEL);
3420 break;
3421 }
3422 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3423 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003424 hdd_info("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003426 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 wlan_hdd_netif_queue_control(pAdapter,
3428 WLAN_NETIF_TX_DISABLE_N_CARRIER,
3429 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 hdd_conn_set_connection_state(pAdapter,
3431 eConnectionState_NotConnected);
3432
3433 /* Send the bssid address to the wext. */
3434 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3435 break;
3436 }
3437 default:
3438 break;
3439
3440 }
3441
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303442 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443}
3444
3445#ifdef FEATURE_WLAN_TDLS
3446/**
3447 * hdd_roam_register_tdlssta() - register new TDLS station
3448 * @pAdapter: pointer to adapter
3449 * @peerMac: pointer to peer MAC address
3450 * @staId: station identifier
3451 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303452 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 *
3454 * Construct the staDesc and register with TL the new STA.
3455 * This is called as part of ADD_STA in the TDLS setup.
3456 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303457 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303459QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303461 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303463 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003465 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003466 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3467 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468
3469 /*
3470 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3471 * be peer MAC, here we are working on direct Link
3472 */
3473 staDesc.sta_id = staId;
3474
3475 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303476 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477
Dhanashri Atre50141c52016-04-07 13:15:29 -07003478 /* Register the vdev transmit and receive functions */
3479 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3480 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003481 cdp_vdev_register(soc,
3482 cdp_get_vdev_from_vdev_id(soc, pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003483 pAdapter, &txrx_ops);
3484 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485
3486 /* Register the Station with TL... */
Leo Changfdb45c32016-10-28 11:09:23 -07003487 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303488 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003489 hdd_err("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303490 qdf_status, qdf_status);
3491 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 }
3493
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303494 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495}
3496
3497/**
3498 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3499 * @pAdapter: pointer to adapter
3500 * @staId: station identifier
3501 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303502 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303504static QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 uint8_t staId)
3506{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303507 QDF_STATUS qdf_status;
Leo Changfdb45c32016-10-28 11:09:23 -07003508 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
3509 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303510 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003511 hdd_warn("cdp_peer_clear() failed for staID %d. Status=%d [0x%08X]",
3512 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303514 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515}
3516
3517/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003518 * hdd_tdls_connection_tracker_update() - update connection tracker state
3519 * @adapter: pointer to adapter
3520 * @roam_info: pointer to roam info
3521 * @hdd_tdls_ctx: tdls context
3522 *
3523 * Return: QDF_STATUS enumeration
3524 */
3525static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3526 tCsrRoamInfo *roam_info,
3527 tdlsCtx_t *hdd_tdls_ctx)
3528{
3529 hddTdlsPeer_t *curr_peer;
3530 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3531
3532 curr_peer = wlan_hdd_tdls_find_peer(adapter,
3533 roam_info->peerMac.bytes, true);
3534
3535 if (!curr_peer) {
3536 hdd_err("curr_peer is null");
3537 return QDF_STATUS_E_FAILURE;
3538 }
3539
3540 mutex_lock(&hdd_ctx->tdls_lock);
3541
3542 if (eTDLS_LINK_CONNECTED ==
3543 curr_peer->link_status) {
3544 hdd_err("Received CONNECTION_TRACKER_NOTIFICATION "
3545 MAC_ADDRESS_STR
3546 " staId: %d, reason: %d",
3547 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3548 roam_info->staId,
3549 roam_info->reasonCode);
3550
3551 if (roam_info->reasonCode ==
3552 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3553 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003554 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3555 roam_info->reasonCode ==
3556 eWMI_TDLS_SCAN_STARTED_EVENT)
3557 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003558 else if (roam_info->reasonCode ==
3559 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3560 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003561 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3562 roam_info->reasonCode ==
3563 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3564 hdd_ctx->enable_tdls_connection_tracker = true;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003565
3566 } else {
3567 hdd_err("TDLS not connected, ignore notification, reason: %d",
3568 roam_info->reasonCode);
3569 }
3570
3571 mutex_unlock(&hdd_ctx->tdls_lock);
3572
3573 return QDF_STATUS_SUCCESS;
3574}
3575
3576
3577
3578
3579/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3581 * @pAdapter: pointer to adapter
3582 * @pRoamInfo: pointer to roam info
3583 * @roamId: roam id
3584 * @roamStatus: roam status
3585 * @roamResult: roam result
3586 *
3587 * HDD interface between SME and TL to ensure TDLS client registration with
3588 * TL in case of new TDLS client is added and deregistration at the time
3589 * TDLS client is deleted.
3590 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303591 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303593static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3595 tCsrRoamInfo *pRoamInfo,
3596 uint32_t roamId,
3597 eRoamCmdStatus roamStatus,
3598 eCsrRoamResult roamResult)
3599{
3600 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3601 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
3602 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303603 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 uint8_t staIdx;
3605 hddTdlsPeer_t *curr_peer;
3606 uint32_t reason;
3607
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003608 hdd_info("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 roamResult ==
3610 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3611 ==
3612 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3613 roamResult ==
3614 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3615 : roamResult ==
3616 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3617 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3618 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3619 roamResult ==
3620 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3621 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3622 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3623 : roamResult ==
3624 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3625 : roamResult ==
3626 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3627 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3628 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3629
3630 if (!pHddTdlsCtx) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003631 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
3632 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 return status;
3634 }
3635
3636 switch (roamResult) {
3637 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3638 {
3639 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003640 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303642 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 } else {
3645 /*
3646 * Check if there is available index for this new TDLS
3647 * STA.
3648 */
3649 for (staIdx = 0;
3650 staIdx < pHddCtx->max_num_tdls_sta;
3651 staIdx++) {
3652 if (0 ==
3653 pHddCtx->tdlsConnInfo[staIdx].
3654 staId) {
3655 pHddCtx->tdlsConnInfo[staIdx].
3656 sessionId =
3657 pRoamInfo->sessionId;
3658 pHddCtx->tdlsConnInfo[staIdx].
3659 staId = pRoamInfo->staId;
3660
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003661 hdd_warn("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003663 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664 staIdx,
3665 pHddCtx->
3666 tdlsConnInfo[staIdx].
3667 staId,
3668 MAC_ADDR_ARRAY
3669 (pRoamInfo->peerMac.bytes));
3670
Anurag Chouhanc5548422016-02-24 18:33:27 +05303671 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003672 tdlsConnInfo
3673 [staIdx].
3674 peerMac,
3675 &pRoamInfo->
3676 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303677 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678 break;
3679 }
3680 }
3681 if (staIdx < pHddCtx->max_num_tdls_sta) {
3682 if (-1 ==
3683 wlan_hdd_tdls_set_sta_id(pAdapter,
3684 pRoamInfo->
3685 peerMac.bytes,
3686 pRoamInfo->
3687 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003688 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303689 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 }
3691
3692 (WLAN_HDD_GET_CTX(pAdapter))->
3693 sta_to_adapter[pRoamInfo->staId] =
3694 pAdapter;
3695 /*
3696 * store the ucast signature,
3697 * if required for further reference.
3698 */
3699
3700 wlan_hdd_tdls_set_signature(pAdapter,
3701 pRoamInfo->
3702 peerMac.bytes,
3703 pRoamInfo->
3704 ucastSig);
3705 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303706 status = QDF_STATUS_E_FAILURE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003707 hdd_err("no available slot in conn_info. staId %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708 pRoamInfo->staId);
3709 }
3710 pAdapter->tdlsAddStaStatus = status;
3711 }
3712 complete(&pAdapter->tdls_add_station_comp);
3713 break;
3714 }
3715 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3716 {
3717 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003718 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 pRoamInfo->statusCode);
3720 }
3721 /* store the ucast signature which will be used later when
3722 * registering to TL
3723 */
3724 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3725 complete(&pAdapter->tdls_add_station_comp);
3726 break;
3727 }
3728 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3729 {
3730 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003731 hdd_err("Link Establish Request failed. status(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732 pRoamInfo->statusCode);
3733 }
3734 complete(&pAdapter->tdls_link_establish_req_comp);
3735 break;
3736 }
3737 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3738 {
3739 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3740 staIdx++) {
3741 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3742 pRoamInfo->sessionId)
3743 && pRoamInfo->staId ==
3744 pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003745 hdd_warn("HDD: del STA IDX = %x",
3746 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747
3748 curr_peer =
3749 wlan_hdd_tdls_find_peer(pAdapter,
3750 pRoamInfo->
3751 peerMac.bytes,
3752 true);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303753 if (NULL != curr_peer) {
3754 hdd_info("Current status for peer " MAC_ADDRESS_STR " is %d",
3755 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3756 curr_peer->link_status);
3757 if (TDLS_IS_CONNECTED(curr_peer)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758 hdd_roam_deregister_tdlssta
3759 (pAdapter,
3760 pRoamInfo->staId);
3761 wlan_hdd_tdls_decrement_peer_count
3762 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303763 } else if (eTDLS_LINK_CONNECTING ==
3764 curr_peer->link_status) {
3765 hdd_roam_deregister_tdlssta
3766 (pAdapter,
3767 pRoamInfo->staId);
3768 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003769 }
3770 wlan_hdd_tdls_reset_peer(pAdapter,
3771 pRoamInfo->
3772 peerMac.bytes);
3773
3774 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3775 pHddCtx->tdlsConnInfo[staIdx].
3776 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303777 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 tdlsConnInfo[staIdx].
3779 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303780 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 break;
3783 }
3784 }
3785 complete(&pAdapter->tdls_del_station_comp);
3786 }
3787 break;
3788 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3789 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003790 hdd_err("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 pRoamInfo->reasonCode);
3792
3793 curr_peer =
3794 wlan_hdd_tdls_find_peer(pAdapter,
3795 pRoamInfo->peerMac.bytes, true);
3796 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
3797 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303798 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3799 curr_peer->peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303800 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 break;
3802 }
3803 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3804 {
3805 /* 0 staIdx is assigned to AP we dont want to touch that */
3806 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3807 staIdx++) {
3808 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3809 pRoamInfo->sessionId)
3810 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003811 hdd_warn("hdd_tdlsStatusUpdate: staIdx %d "
3812 MAC_ADDRESS_STR,
3813 pHddCtx->tdlsConnInfo[staIdx].
3814 staId,
3815 MAC_ADDR_ARRAY(pHddCtx->
3816 tdlsConnInfo
3817 [staIdx].
3818 peerMac.
3819 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 wlan_hdd_tdls_reset_peer(pAdapter,
3821 pHddCtx->
3822 tdlsConnInfo
3823 [staIdx].
3824 peerMac.bytes);
3825 hdd_roam_deregister_tdlssta(pAdapter,
3826 pHddCtx->
3827 tdlsConnInfo
3828 [staIdx].
3829 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303830 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831 sizeof
3832 (smeTdlsPeerStateParams));
3833 smeTdlsPeerStateParams.vdevId =
3834 pHddCtx->tdlsConnInfo[staIdx].
3835 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303836 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837 peerMacAddr,
3838 &pHddCtx->
3839 tdlsConnInfo[staIdx].
3840 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303841 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003842 smeTdlsPeerStateParams.peerState =
3843 eSME_TDLS_PEER_STATE_TEARDOWN;
3844
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003845 hdd_info("calling sme_update_tdls_peer_state for staIdx %d "
3846 MAC_ADDRESS_STR,
3847 pHddCtx->tdlsConnInfo[staIdx].
3848 staId,
3849 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 tdlsConnInfo
3851 [staIdx].
3852 peerMac.
3853 bytes));
3854 status =
3855 sme_update_tdls_peer_state(
3856 pHddCtx->hHal,
3857 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303858 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003859 hdd_err("sme_update_tdls_peer_state failed for "
3860 MAC_ADDRESS_STR,
3861 MAC_ADDR_ARRAY
3862 (pHddCtx->
3863 tdlsConnInfo[staIdx].
3864 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865 }
3866 wlan_hdd_tdls_decrement_peer_count
3867 (pAdapter);
3868
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303869 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 tdlsConnInfo[staIdx].
3871 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303872 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3874 pHddCtx->tdlsConnInfo[staIdx].
3875 sessionId = 255;
3876
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303877 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878 }
3879 }
3880 break;
3881 }
3882 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
3883 {
3884 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07003885 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
3886 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303887 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 break;
3889 }
3890
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07003891 if (pHddCtx->tdls_nss_switch_in_progress) {
3892 hdd_err("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
3893 status = QDF_STATUS_SUCCESS;
3894 break;
3895 }
3896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 curr_peer =
3898 wlan_hdd_tdls_get_peer(pAdapter,
Kabilan Kannan36090ce2016-05-03 19:28:44 -07003899 pRoamInfo->peerMac.bytes,
3900 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303902 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303903 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904 } else {
3905 if (eTDLS_LINK_CONNECTED ==
3906 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003907 hdd_err("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 } else {
3909 /*
3910 * If external control is enabled then initiate
3911 * TDLS only if forced peer is set otherwise
3912 * ignore should Discover trigger from fw.
3913 */
3914 if (pHddCtx->config->
3915 fTDLSExternalControl
3916 && (false ==
3917 curr_peer->isForcedPeer)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003918 hdd_info("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303919 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920 break;
3921 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003922 hdd_info("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923 pHddCtx->config->
3924 fTDLSExternalControl,
3925 curr_peer->isForcedPeer,
3926 pRoamInfo->reasonCode);
3927 }
3928 wlan_hdd_tdls_pre_setup_init_work
3929 (pHddTdlsCtx, curr_peer);
3930 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303931 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003932 }
3933 break;
3934 }
3935
3936 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
3937 {
3938 curr_peer =
3939 wlan_hdd_tdls_find_peer(pAdapter,
3940 pRoamInfo->peerMac.bytes, true);
3941 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303942 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303943 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 } else {
3945 if (eTDLS_LINK_CONNECTED ==
3946 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003947 hdd_err("Received SHOULD_TEARDOWN for peer "
3948 MAC_ADDRESS_STR
3949 " staId: %d, reason: %d",
3950 MAC_ADDR_ARRAY(pRoamInfo->
3951 peerMac.bytes),
3952 pRoamInfo->staId,
3953 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954
3955 if (pRoamInfo->reasonCode ==
3956 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
3957 pRoamInfo->reasonCode ==
3958 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
3959 pRoamInfo->reasonCode ==
3960 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
3961 pRoamInfo->reasonCode ==
3962 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
3963 reason =
3964 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
3965 } else
3966 reason =
3967 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
3968
3969 wlan_hdd_tdls_indicate_teardown
3970 (pHddTdlsCtx->pAdapter, curr_peer,
3971 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303972 hdd_send_wlan_tdls_teardown_event(
3973 eTDLS_TEARDOWN_BSS_DISCONNECT,
3974 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003976 hdd_err("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
3977 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303979 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 }
3981 break;
3982 }
3983
3984 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
3985 {
3986 curr_peer =
3987 wlan_hdd_tdls_find_peer(pAdapter,
3988 pRoamInfo->peerMac.bytes, true);
3989 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303990 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303991 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 } else {
3993 if (eTDLS_LINK_CONNECTED ==
3994 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003995 hdd_err("Received SHOULD_PEER_DISCONNECTED for peer "
3996 MAC_ADDRESS_STR
3997 " staId: %d, reason: %d",
3998 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3999 pRoamInfo->staId,
4000 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001
4002 if (pRoamInfo->reasonCode ==
4003 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4004 pRoamInfo->reasonCode ==
4005 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4006 pRoamInfo->reasonCode ==
4007 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4008 pRoamInfo->reasonCode ==
4009 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4010 reason =
4011 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4012 } else
4013 reason =
4014 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4015
4016 wlan_hdd_tdls_indicate_teardown
4017 (pHddTdlsCtx->pAdapter, curr_peer,
4018 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304019 hdd_send_wlan_tdls_teardown_event(
4020 eTDLS_TEARDOWN_BSS_DISCONNECT,
4021 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004023 hdd_err("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
4024 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304026 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 }
4028 break;
4029 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004030
4031 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
4032 status = hdd_tdls_connection_tracker_update(pAdapter,
4033 pRoamInfo,
4034 pHddTdlsCtx);
4035 break;
4036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 default:
4038 {
4039 break;
4040 }
4041 }
4042
4043 return status;
4044}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004045#else
4046
4047static inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
4048 uint8_t staId)
4049{
4050 return QDF_STATUS_SUCCESS;
4051}
4052
4053static inline QDF_STATUS
4054hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4055 tCsrRoamInfo *pRoamInfo,
4056 uint32_t roamId,
4057 eRoamCmdStatus roamStatus,
4058 eCsrRoamResult roamResult)
4059{
4060 return QDF_STATUS_SUCCESS;
4061}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062#endif
4063
4064#ifdef WLAN_FEATURE_11W
4065/**
4066 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4067 * @pAdapter: pointer to the adapter
4068 * @nFrameLength: Length of the unprotected frame being passed
4069 * @pbFrames: Pointer to the frame buffer
4070 * @frameType: 802.11 frame type
4071 *
4072 * This function forwards the unprotected management frame to the supplicant.
4073 *
4074 * Return: nothing
4075 */
4076static void
4077hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4078 uint8_t *pbFrames, uint8_t frameType)
4079{
4080 uint8_t type = 0;
4081 uint8_t subType = 0;
4082
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004083 hdd_info("Frame Type = %d Frame Length = %d",
4084 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085
4086 /* Sanity Checks */
4087 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004088 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 return;
4090 }
4091
4092 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004093 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 return;
4095 }
4096
4097 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004098 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 return;
4100 }
4101
4102 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004103 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 return;
4105 }
4106
4107 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004108 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 return;
4110 }
4111
4112 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4113 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4114
4115 /* Get pAdapter from Destination mac address of the frame */
4116 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4117#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4118 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4119 nFrameLength);
4120#else
4121 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4122 nFrameLength);
4123#endif
4124 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4125 } else if (type == SIR_MAC_MGMT_FRAME &&
4126 subType == SIR_MAC_MGMT_DEAUTH) {
4127#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4128 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4129 nFrameLength);
4130#else
4131 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4132 nFrameLength);
4133#endif
4134 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4135 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004136 hdd_err("Frame type %d and subtype %d are not valid",
4137 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 return;
4139 }
4140}
4141#endif
4142
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004143#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144/**
4145 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4146 * @pAdapter: pointer to adapter
4147 * @tid: traffic identifier
4148 * @state: state
4149 * @measInterval: measurement interval
4150 *
4151 * This function sends traffic stream metrics IE information to
4152 * the supplicant via wireless event.
4153 *
4154 * Return: none
4155 */
4156static void
4157hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4158 uint8_t state, uint16_t measInterval)
4159{
4160 union iwreq_data wrqu;
4161 char buf[IW_CUSTOM_MAX + 1];
4162 int nBytes = 0;
4163
4164 if (NULL == pAdapter)
4165 return;
4166
4167 /* create the event */
4168 memset(&wrqu, '\0', sizeof(wrqu));
4169 memset(buf, '\0', sizeof(buf));
4170
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004171 hdd_info("TSM Ind tid(%d) state(%d) MeasInt(%d)",
4172 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173
4174 nBytes =
4175 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4176 measInterval);
4177
4178 wrqu.data.pointer = buf;
4179 wrqu.data.length = nBytes;
4180 /* send the event */
4181 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4182}
4183
4184/**
4185 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4186 * @pAdapter: pointer to adapter
4187 * @pRoamInfo: pointer to roam info
4188 *
4189 * This function sends cckm preauth indication to the supplicant
4190 * via wireless custom event.
4191 *
4192 * Return: none
4193 */
4194static void
4195hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4196{
4197 union iwreq_data wrqu;
4198 char buf[IW_CUSTOM_MAX + 1];
4199 char *pos = buf;
4200 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4201
4202 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4203 return;
4204
4205 /* create the event */
4206 memset(&wrqu, '\0', sizeof(wrqu));
4207 memset(buf, '\0', sizeof(buf));
4208
4209 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004210 hdd_info("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
4211 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4212 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213
4214 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4215 pos += nBytes;
4216 freeBytes -= nBytes;
4217
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304218 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304219 pos += QDF_MAC_ADDR_SIZE;
4220 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221
4222 nBytes = snprintf(pos, freeBytes, " %u:%u",
4223 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4224 freeBytes -= nBytes;
4225
4226 wrqu.data.pointer = buf;
4227 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4228
4229 /* send the event */
4230 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4231}
4232
4233/**
4234 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4235 * @pAdapter: pointer to adapter
4236 * @pRoamInfo: pointer to roam info
4237 *
4238 * Return: none
4239 */
4240static void
4241hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4242 tCsrRoamInfo *pRoamInfo)
4243{
4244 union iwreq_data wrqu;
4245 char buf[IW_CUSTOM_MAX + 1];
4246 int nBytes = 0;
4247
4248 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4249 return;
4250
4251 /* create the event */
4252 memset(&wrqu, '\0', sizeof(wrqu));
4253 memset(buf, '\0', sizeof(buf));
4254
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004255 hdd_info("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256
4257 nBytes =
4258 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4259 pRoamInfo->tsmRoamDelay);
4260
4261 wrqu.data.pointer = buf;
4262 wrqu.data.length = nBytes;
4263
4264 /* send the event */
4265 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4266}
4267
4268/**
4269 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4270 * @pAdapter: pointer to adapter
4271 * @measurementToken: measurement token
4272 * @flag: flag
4273 * @numBss: number of bss
4274 *
4275 * If the measurement is none and no scan results found,
4276 * indicate the supplicant about measurement done.
4277 *
4278 * Return: none
4279 */
4280void
4281hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4282 const uint16_t measurementToken,
4283 const bool flag, const uint8_t numBss)
4284{
4285 union iwreq_data wrqu;
4286 char buf[IW_CUSTOM_MAX];
4287 char *pos = buf;
4288 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4289
4290 memset(&wrqu, '\0', sizeof(wrqu));
4291 memset(buf, '\0', sizeof(buf));
4292
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004293 hdd_info("CCXBCNREP=%d %d %d", measurementToken,
4294 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295
4296 nBytes =
4297 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4298 flag, numBss);
4299
4300 wrqu.data.pointer = buf;
4301 wrqu.data.length = nBytes;
4302 /* send the event */
4303 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4304}
4305
4306/**
4307 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4308 * @pAdapter: pointer to adapter
4309 * @pRoamInfo: pointer to roam info
4310 *
4311 * If the measurement is none and no scan results found,
4312 * indicate the supplicant about measurement done.
4313 *
4314 * Return: none
4315 */
4316static void
4317hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4318 const tCsrRoamInfo *pRoamInfo)
4319{
4320 union iwreq_data wrqu;
4321 char buf[IW_CUSTOM_MAX];
4322 char *pos = buf;
4323 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4324 uint8_t i = 0, len = 0;
4325 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4326 uint8_t lastSent = 0, sendBss = 0;
4327 int bcnRepFieldSize =
4328 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4329 bcnReportFields);
4330 uint8_t ieLenByte = 1;
4331 /*
4332 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4333 */
4334#define ESEBCNREPHEADER_LEN (18)
4335
4336 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4337 return;
4338
4339 /*
4340 * Custom event can pass maximum of 256 bytes of data,
4341 * based on the IE len we need to identify how many BSS info can
4342 * be filled in to custom event data.
4343 */
4344 /*
4345 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4346 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4347 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4348 */
4349
4350 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4351 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004352 hdd_info("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 /* If the measurement is none and no scan results found,
4354 indicate the supplicant about measurement done */
4355 hdd_indicate_ese_bcn_report_no_results(
4356 pAdapter,
4357 pRoamInfo->pEseBcnReportRsp->
4358 measurementToken,
4359 pRoamInfo->pEseBcnReportRsp->flag,
4360 pRoamInfo->pEseBcnReportRsp->numBss);
4361 } else {
4362 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4363 memset(&wrqu, '\0', sizeof(wrqu));
4364 memset(buf, '\0', sizeof(buf));
4365 tot_bcn_ieLen = 0;
4366 sendBss = 0;
4367 pos = buf;
4368 freeBytes = IW_CUSTOM_MAX;
4369
4370 for (i = lastSent;
4371 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4372 len =
4373 bcnRepFieldSize + ieLenByte +
4374 pRoamInfo->pEseBcnReportRsp->
4375 bcnRepBssInfo[i].ieLen;
4376 if ((len + tot_bcn_ieLen) >
4377 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4378 break;
4379 }
4380 tot_bcn_ieLen += len;
4381 sendBss++;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004382 hdd_info("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
4383 i, bcnRepFieldSize, 1,
4384 pRoamInfo->pEseBcnReportRsp->
4385 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 }
4387
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004388 hdd_info("Sending %d BSS Info", sendBss);
4389 hdd_info("CCXBCNREP=%d %d %d %d",
4390 pRoamInfo->pEseBcnReportRsp->measurementToken,
4391 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4392 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393
4394 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4395 pRoamInfo->pEseBcnReportRsp->
4396 measurementToken,
4397 pRoamInfo->pEseBcnReportRsp->flag,
4398 sendBss);
4399 pos += nBytes;
4400 freeBytes -= nBytes;
4401
4402 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304403 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 sizeof(tot_bcn_ieLen));
4405 pos += sizeof(tot_bcn_ieLen);
4406 freeBytes -= sizeof(tot_bcn_ieLen);
4407
4408 for (i = 0; i < sendBss; i++) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004409 hdd_info("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4411 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4412 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4413 pRoamInfo->pEseBcnReportRsp->
4414 bcnRepBssInfo[i +
4415 lastSent].bcnReportFields.
4416 ChanNum,
4417 pRoamInfo->pEseBcnReportRsp->
4418 bcnRepBssInfo[i +
4419 lastSent].bcnReportFields.
4420 Spare,
4421 pRoamInfo->pEseBcnReportRsp->
4422 bcnRepBssInfo[i +
4423 lastSent].bcnReportFields.
4424 MeasDuration,
4425 pRoamInfo->pEseBcnReportRsp->
4426 bcnRepBssInfo[i +
4427 lastSent].bcnReportFields.
4428 PhyType,
4429 pRoamInfo->pEseBcnReportRsp->
4430 bcnRepBssInfo[i +
4431 lastSent].bcnReportFields.
4432 RecvSigPower,
4433 pRoamInfo->pEseBcnReportRsp->
4434 bcnRepBssInfo[i +
4435 lastSent].bcnReportFields.
4436 ParentTsf,
4437 pRoamInfo->pEseBcnReportRsp->
4438 bcnRepBssInfo[i +
4439 lastSent].bcnReportFields.
4440 TargetTsf[0],
4441 pRoamInfo->pEseBcnReportRsp->
4442 bcnRepBssInfo[i +
4443 lastSent].bcnReportFields.
4444 TargetTsf[1],
4445 pRoamInfo->pEseBcnReportRsp->
4446 bcnRepBssInfo[i +
4447 lastSent].bcnReportFields.
4448 BcnInterval,
4449 pRoamInfo->pEseBcnReportRsp->
4450 bcnRepBssInfo[i +
4451 lastSent].bcnReportFields.
4452 CapabilityInfo,
4453 pRoamInfo->pEseBcnReportRsp->
4454 bcnRepBssInfo[i +
4455 lastSent].bcnReportFields.
4456 Bssid[0],
4457 pRoamInfo->pEseBcnReportRsp->
4458 bcnRepBssInfo[i +
4459 lastSent].bcnReportFields.
4460 Bssid[1],
4461 pRoamInfo->pEseBcnReportRsp->
4462 bcnRepBssInfo[i +
4463 lastSent].bcnReportFields.
4464 Bssid[2],
4465 pRoamInfo->pEseBcnReportRsp->
4466 bcnRepBssInfo[i +
4467 lastSent].bcnReportFields.
4468 Bssid[3],
4469 pRoamInfo->pEseBcnReportRsp->
4470 bcnRepBssInfo[i +
4471 lastSent].bcnReportFields.
4472 Bssid[4],
4473 pRoamInfo->pEseBcnReportRsp->
4474 bcnRepBssInfo[i +
4475 lastSent].bcnReportFields.
4476 Bssid[5]);
4477
4478 /* bcn report fields are copied */
4479 len =
4480 sizeof(pRoamInfo->pEseBcnReportRsp->
4481 bcnRepBssInfo[i +
4482 lastSent].
4483 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304484 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 (char *)&pRoamInfo->
4486 pEseBcnReportRsp->bcnRepBssInfo[i +
4487 lastSent].
4488 bcnReportFields, len);
4489 pos += len;
4490 freeBytes -= len;
4491
4492 /* Add 1 byte of ie len */
4493 len =
4494 pRoamInfo->pEseBcnReportRsp->
4495 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304496 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 pos += sizeof(len);
4498 freeBytes -= sizeof(len);
4499
4500 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304501 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 (char *)pRoamInfo->
4503 pEseBcnReportRsp->bcnRepBssInfo[i +
4504 lastSent].
4505 pBuf, len);
4506 pos += len;
4507 freeBytes -= len;
4508 }
4509
4510 wrqu.data.pointer = buf;
4511 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4512
4513 /* send the event */
4514 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4515 buf);
4516 lastSent += sendBss;
4517 }
4518 }
4519}
4520
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004521#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522
4523/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304524 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4525 * @pHddStaCtx: Station Context
4526 *
4527 * API to check if the connection authentication type is 8021x_sha256.
4528 *
4529 * Return: bool
4530 */
4531#ifdef WLAN_FEATURE_11W
4532static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4533{
4534 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4535 pHddStaCtx->conn_info.authType;
4536}
4537#else
4538static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4539{
4540 return false;
4541}
4542#endif
4543
4544/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 * hdd_sme_roam_callback() - hdd sme roam callback
4546 * @pContext: pointer to adapter context
4547 * @pRoamInfo: pointer to roam info
4548 * @roamId: roam id
4549 * @roamStatus: roam status
4550 * @roamResult: roam result
4551 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304552 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304554QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4556 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4557{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304558 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4560 hdd_wext_state_t *pWextState = NULL;
4561 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304562 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 hdd_context_t *pHddCtx = NULL;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05304564 struct hdd_chan_change_params chan_change;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304565 struct cfg80211_bss *bss_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004567 hdd_info("CSR Callback: status= %d result= %d roamID=%d",
4568 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569
4570 /* Sanity check */
4571 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004572 hdd_alert("invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304573 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 }
4575
4576 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4577 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4578
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304579 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304580 pAdapter->sessionId, roamStatus));
4581
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582 switch (roamStatus) {
4583 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304584 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4585 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004586 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 break;
4588
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 /*
4590 * We did pre-auth,then we attempted a 11r or ese reassoc.
4591 * reassoc failed due to failure, timeout, reject from ap
4592 * in any case tell the OS, our carrier is off and mark
4593 * interface down.
4594 */
4595 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004596 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4597 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304598 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4600 roamStatus, roamResult);
4601 /*
4602 * Check if Mcast/Bcast Filters are set, if yes
4603 * clear the filters here.
4604 */
4605 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set ==
4606 true) {
4607 (WLAN_HDD_GET_CTX(pAdapter))->
4608 hdd_mcastbcast_filter_set = false;
4609 }
4610 pHddStaCtx->ft_carrier_on = false;
4611 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004612 hdd_info("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
4613 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 break;
4615
4616 case eCSR_ROAM_FT_START:
4617 /*
4618 * When we roam for ESE and 11r, we dont want the OS to be
4619 * informed that the link is down. So mark the link ready for
4620 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4621 * be received. Where in we will not mark the link down
4622 * Also we want to stop tx at this point when we will be
4623 * doing disassoc at this time. This saves 30-60 msec
4624 * after reassoc.
4625 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004626 hdd_info("Disabling queues");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004627 hdd_info("Roam Synch Ind: NAPI Serialize ON");
4628 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004629 wlan_hdd_netif_queue_control(pAdapter,
4630 WLAN_NETIF_TX_DISABLE,
4631 WLAN_CONTROL_PATH);
4632 status = hdd_roam_deregister_sta(pAdapter,
4633 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304634 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304635 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 pHddStaCtx->ft_carrier_on = true;
4637 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004638 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4639 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004641 case eCSR_ROAM_NAPI_OFF:
4642 hdd_info("After Roam Synch Comp: NAPI Serialize OFF");
4643 hdd_napi_serialize(0);
4644 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004647 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 wlan_hdd_netif_queue_control(pAdapter,
4649 WLAN_NETIF_TX_DISABLE,
4650 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 wlan_hdd_netif_queue_control(pAdapter,
4653 WLAN_NETIF_CARRIER_OFF,
4654 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 break;
4657 case eCSR_ROAM_LOSTLINK:
4658 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004659 hdd_info("Roaming started due to connection lost");
4660 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661 wlan_hdd_netif_queue_control(pAdapter,
4662 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4663 WLAN_CONTROL_PATH);
4664 break;
4665 }
4666 case eCSR_ROAM_DISASSOCIATED:
4667 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004668 hdd_info("****eCSR_ROAM_DISASSOCIATED****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304669 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4671 roamStatus, roamResult);
4672 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4674 if (pHddCtx->hdd_mcastbcast_filter_set == true) {
4675 hdd_conf_mcastbcast_filter(pHddCtx, false);
4676
4677 if (true ==
4678 pHddCtx->sus_res_mcastbcast_filter_valid) {
4679 pHddCtx->configuredMcastBcastFilter =
4680 pHddCtx->sus_res_mcastbcast_filter;
4681 pHddCtx->
4682 sus_res_mcastbcast_filter_valid =
4683 false;
4684 }
4685
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004686 hdd_info("offload: disassociation happening, restoring configuredMcastBcastFilter");
4687 hdd_info("McastBcastFilter = %d",
4688 pHddCtx->configuredMcastBcastFilter);
4689 hdd_info("offload: already called mcastbcast filter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 (WLAN_HDD_GET_CTX(pAdapter))->
4691 hdd_mcastbcast_filter_set = false;
4692 }
4693 /* Call to clear any MC Addr List filter applied after
4694 * successful connection.
4695 */
4696 wlan_hdd_set_mc_addr_list(pAdapter, false);
4697 }
4698 break;
4699 case eCSR_ROAM_IBSS_LEAVE:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004700 hdd_info("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304701 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4703 roamStatus, roamResult);
4704 break;
4705 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004706 hdd_info("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 /*
4708 * To Do - address probable memory leak with WEP encryption upon
4709 * successful association.
4710 */
4711 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4712 /* Clear saved connection information in HDD */
4713 hdd_conn_remove_connect_info(
4714 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4715 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304716 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 hdd_association_completion_handler(pAdapter, pRoamInfo,
4718 roamId, roamStatus,
4719 roamResult);
4720#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4721 if (pRoamInfo)
4722 pRoamInfo->roamSynchInProgress = false;
4723#endif
4724 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004725 case eCSR_ROAM_CANCELLED:
4726 hdd_info("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304728 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 pRoamInfo,
4730 roamId,
4731 roamStatus,
4732 roamResult);
4733 break;
4734 case eCSR_ROAM_IBSS_IND:
4735 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4736 roamStatus, roamResult);
4737 break;
4738
4739 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304740 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 roam_roam_connect_status_update_handler(pAdapter,
4742 pRoamInfo,
4743 roamId,
4744 roamStatus,
4745 roamResult);
4746 break;
4747
4748 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304749 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004750 hdd_roam_mic_error_indication_handler(pAdapter,
4751 pRoamInfo,
4752 roamId,
4753 roamStatus,
4754 roamResult);
4755 break;
4756
4757 case eCSR_ROAM_SET_KEY_COMPLETE:
4758 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304759 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4761 roamId, roamStatus,
4762 roamResult);
4763 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4764 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004765 hdd_info("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 pHddStaCtx->hdd_ReassocScenario,
4767 pAdapter->sessionId);
4768 }
4769 }
4770#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4771 if (pRoamInfo != NULL)
4772 pRoamInfo->roamSynchInProgress = false;
4773#endif
4774 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004775
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776 case eCSR_ROAM_FT_RESPONSE:
4777 hdd_send_ft_event(pAdapter);
4778 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004779
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004780 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304781 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4782 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304784 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 wlan_hdd_cfg80211_pmksa_candidate_notify(
4786 pAdapter, pRoamInfo, 1, false);
4787 }
4788 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789
4790#ifdef FEATURE_WLAN_LFR_METRICS
4791 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4792 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304793 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4795 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304796 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797 }
4798 break;
4799 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4800 /*
4801 * This event will notify pre-auth completion in case of success
4802 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304803 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004804 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4805 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304806 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 }
4808 break;
4809 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4810 /*
4811 * This event will notify pre-auth completion incase of failure.
4812 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304813 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4815 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304816 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817 }
4818 break;
4819 case eCSR_ROAM_HANDOVER_SUCCESS:
4820 /* This event is to notify handover success.
4821 It will be only invoked on success */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304822 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4824 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304825 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004826 }
4827 break;
4828#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 case eCSR_ROAM_REMAIN_CHAN_READY:
4830 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4831 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832#ifdef FEATURE_WLAN_TDLS
4833 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304834 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4836 roamId,
4837 roamStatus,
4838 roamResult);
4839 break;
4840 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4841 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4842 pRoamInfo->reasonCode);
4843 break;
4844#endif
4845#ifdef WLAN_FEATURE_11W
4846 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4847 hdd_indicate_unprot_mgmt_frame(pAdapter,
4848 pRoamInfo->nFrameLength,
4849 pRoamInfo->pbFrames,
4850 pRoamInfo->frameType);
4851 break;
4852#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004853#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004854 case eCSR_ROAM_TSM_IE_IND:
4855 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
4856 pRoamInfo->tsmIe.state,
4857 pRoamInfo->tsmIe.msmt_interval);
4858 break;
4859
4860 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4861 {
4862 if (eCSR_AUTH_TYPE_CCKM_WPA ==
4863 pHddStaCtx->conn_info.authType
4864 || eCSR_AUTH_TYPE_CCKM_RSN ==
4865 pHddStaCtx->conn_info.authType) {
4866 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
4867 }
4868 break;
4869 }
4870
4871 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4872 {
4873 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
4874 break;
4875 }
4876
4877 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4878 {
4879 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
4880 break;
4881 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004882#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304883 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4884 hdd_info("channel switch for session:%d to channel:%d",
4885 pAdapter->sessionId, pRoamInfo->chan_info.chan_id);
4886
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05304887 chan_change.chan = pRoamInfo->chan_info.chan_id;
4888 chan_change.chan_params.ch_width =
4889 pRoamInfo->chan_info.ch_width;
4890 chan_change.chan_params.sec_ch_offset =
4891 pRoamInfo->chan_info.sec_ch_offset;
4892 chan_change.chan_params.center_freq_seg0 =
4893 pRoamInfo->chan_info.band_center_freq1;
4894 chan_change.chan_params.center_freq_seg1 =
4895 pRoamInfo->chan_info.band_center_freq2;
4896
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304897 status = hdd_chan_change_notify(pAdapter, pAdapter->dev,
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05304898 chan_change);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304899 if (QDF_IS_STATUS_ERROR(status))
4900 hdd_err("channel change notification failed");
4901
4902 status = cds_set_hw_mode_on_channel_switch(pAdapter->sessionId);
4903 if (QDF_IS_STATUS_ERROR(status))
4904 hdd_info("set hw mode change not done");
4905 break;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304906 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4907 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
4908 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
4909 pAdapter, pRoamInfo->pBssDesc);
4910 if (NULL == bss_status)
4911 hdd_info("UPDATE_SCAN_RESULT returned NULL");
4912 else
4913 cfg80211_put_bss(
4914#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4915 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4916#endif
4917 bss_status);
4918 }
4919 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004920 case eCSR_ROAM_NDP_STATUS_UPDATE:
4921 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
4922 roamResult);
4923 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004924 case eCSR_ROAM_START:
4925 hdd_info("Process ROAM_START from firmware");
4926 wlan_hdd_netif_queue_control(pAdapter,
4927 WLAN_NETIF_TX_DISABLE,
4928 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004929 hdd_napi_serialize(1);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004930 cds_set_connection_in_progress(true);
4931 cds_restart_opportunistic_timer(true);
4932 break;
4933 case eCSR_ROAM_ABORT:
4934 hdd_info("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004935 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004936 wlan_hdd_netif_queue_control(pAdapter,
4937 WLAN_WAKE_ALL_NETIF_QUEUE,
4938 WLAN_CONTROL_PATH);
4939 cds_set_connection_in_progress(false);
4940 break;
4941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 default:
4943 break;
4944 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304945 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946}
4947
4948/**
4949 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4950 * @auth_suite: auth suite
4951 *
4952 * Return: eCsrAuthType enumeration
4953 */
4954eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4955{
4956 eCsrAuthType auth_type;
4957 /* is the auth type supported? */
4958 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4959 auth_type = eCSR_AUTH_TYPE_RSN;
4960 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
4961 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004962 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963 /* Check for 11r FT Authentication with PSK */
4964 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
4965 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
4966 /* Check for 11R FT Authentication with 802.1X */
4967 auth_type = eCSR_AUTH_TYPE_FT_RSN;
4968 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969#ifdef FEATURE_WLAN_ESE
4970 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
4971 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4972 } else
4973#endif /* FEATURE_WLAN_ESE */
4974#ifdef WLAN_FEATURE_11W
4975 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
4976 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4977 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
4978 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4979 } else
4980#endif
4981 {
4982 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4983 }
4984 return auth_type;
4985}
4986
4987/**
4988 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
4989 * @auth_suite: auth suite
4990 *
4991 * Return: eCsrAuthType enumeration
4992 */
4993eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
4994{
4995 eCsrAuthType auth_type;
4996 /* is the auth type supported? */
4997 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
4998 auth_type = eCSR_AUTH_TYPE_WPA;
4999 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5000 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5001 } else
5002#ifdef FEATURE_WLAN_ESE
5003 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5004 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5005 } else
5006#endif /* FEATURE_WLAN_ESE */
5007 {
5008 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5009 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005010 hdd_info("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011 return auth_type;
5012}
5013
5014/**
5015 * hdd_translate_rsn_to_csr_encryption_type() -
5016 * Translate RSN to CSR encryption type
5017 * @cipher_suite: cipher suite
5018 *
5019 * Return: eCsrEncryptionType enumeration
5020 */
5021eCsrEncryptionType
5022hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5023{
5024 eCsrEncryptionType cipher_type;
5025
5026 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5027 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5028 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5029 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5030 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5031 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5032 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5033 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5034 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5035 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5036 else
5037 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5038
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005039 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040 return cipher_type;
5041}
5042
5043/**
5044 * hdd_translate_wpa_to_csr_encryption_type() -
5045 * Translate WPA to CSR encryption type
5046 * @cipher_suite: cipher suite
5047 *
5048 * Return: eCsrEncryptionType enumeration
5049 */
5050eCsrEncryptionType
5051hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5052{
5053 eCsrEncryptionType cipher_type;
5054
5055 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5056 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5057 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5058 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5059 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5060 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5061 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5062 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5063 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5064 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5065 else
5066 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5067
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005068 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 return cipher_type;
5070}
5071
5072/**
5073 * hdd_process_genie() - process gen ie
5074 * @pAdapter: pointer to adapter
5075 * @bssid: pointer to mac address
5076 * @pEncryptType: pointer to encryption type
5077 * @mcEncryptType: pointer to multicast encryption type
5078 * @pAuthType: pointer to auth type
5079 *
5080 * Return: 0 on success, error number otherwise
5081 */
5082static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5083 u8 *bssid,
5084 eCsrEncryptionType *pEncryptType,
5085 eCsrEncryptionType *mcEncryptType,
5086 eCsrAuthType *pAuthType,
5087#ifdef WLAN_FEATURE_11W
5088 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5089#endif
5090 uint16_t gen_ie_len, uint8_t *gen_ie)
5091{
5092 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305093 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094 tDot11fIERSN dot11RSNIE;
5095 tDot11fIEWPA dot11WPAIE;
5096 uint32_t i;
5097 uint8_t *pRsnIe;
5098 uint16_t RSNIeLen;
5099 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5100 bool updatePMKCache = false;
5101
5102 /*
5103 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5104 * setting present flag to 0.
5105 */
5106 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5107 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5108
5109 /* Type check */
5110 if (gen_ie[0] == DOT11F_EID_RSN) {
5111 /* Validity checks */
5112 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5113 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005114 hdd_err("Invalid DOT11F RSN IE length :%d",
5115 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005116 return -EINVAL;
5117 }
5118 /* Skip past the EID byte and length byte */
5119 pRsnIe = gen_ie + 2;
5120 RSNIeLen = gen_ie_len - 2;
5121 /* Unpack the RSN IE */
5122 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
5123 pRsnIe, RSNIeLen, &dot11RSNIE);
5124 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005125 hdd_info("pairwise cipher suite count: %d",
5126 dot11RSNIE.pwise_cipher_suite_count);
5127 hdd_info("authentication suite count: %d",
5128 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 /*Here we have followed the apple base code,
5130 but probably I suspect we can do something different */
5131 /* dot11RSNIE.akm_suite_count */
5132 /* Just translate the FIRST one */
5133 *pAuthType =
5134 hdd_translate_rsn_to_csr_auth_type(
5135 dot11RSNIE.akm_suites[0]);
5136 /* dot11RSNIE.pwise_cipher_suite_count */
5137 *pEncryptType =
5138 hdd_translate_rsn_to_csr_encryption_type(
5139 dot11RSNIE.pwise_cipher_suites[0]);
5140 /* dot11RSNIE.gp_cipher_suite_count */
5141 *mcEncryptType =
5142 hdd_translate_rsn_to_csr_encryption_type(
5143 dot11RSNIE.gp_cipher_suite);
5144#ifdef WLAN_FEATURE_11W
5145 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5146 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5147#endif
5148 /* Set the PMKSA ID Cache for this interface */
5149 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5150 if (is_zero_ether_addr(bssid)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005151 hdd_err("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005152 break;
5153 }
5154 updatePMKCache = true;
5155 /*
5156 * For right now, I assume setASSOCIATE() has passed
5157 * in the bssid.
5158 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305159 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305160 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305161 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5163 }
5164
5165 if (updatePMKCache) {
5166 /*
5167 * Calling csr_roam_set_pmkid_cache to configure the
5168 * PMKIDs into the cache.
5169 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005170 hdd_info("Calling sme_roam_set_pmkid_cache with cache entry %d.",
5171 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 /* Finally set the PMKSA ID Cache in CSR */
5173 result =
5174 sme_roam_set_pmkid_cache(halHandle,
5175 pAdapter->sessionId,
5176 PMKIDCache,
5177 dot11RSNIE.pmkid_count,
5178 false);
5179 }
5180 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5181 /* Validity checks */
5182 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5183 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005184 hdd_err("Invalid DOT11F WPA IE length :%d",
5185 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005186 return -EINVAL;
5187 }
5188 /* Skip past the EID and length byte - and four byte WiFi OUI */
5189 pRsnIe = gen_ie + 2 + 4;
5190 RSNIeLen = gen_ie_len - (2 + 4);
5191 /* Unpack the WPA IE */
5192 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
5193 pRsnIe, RSNIeLen, &dot11WPAIE);
5194 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005195 hdd_info("WPA unicast cipher suite count: %d",
5196 dot11WPAIE.unicast_cipher_count);
5197 hdd_info("WPA authentication suite count: %d",
5198 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199 /* dot11WPAIE.auth_suite_count */
5200 /* Just translate the FIRST one */
5201 *pAuthType =
5202 hdd_translate_wpa_to_csr_auth_type(
5203 dot11WPAIE.auth_suites[0]);
5204 /* dot11WPAIE.unicast_cipher_count */
5205 *pEncryptType =
5206 hdd_translate_wpa_to_csr_encryption_type(
5207 dot11WPAIE.unicast_ciphers[0]);
5208 /* dot11WPAIE.unicast_cipher_count */
5209 *mcEncryptType =
5210 hdd_translate_wpa_to_csr_encryption_type(
5211 dot11WPAIE.multicast_cipher);
5212 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005213 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005214 return -EINVAL;
5215 }
5216 return 0;
5217}
5218
5219/**
5220 * hdd_set_genie_to_csr() - set genie to csr
5221 * @pAdapter: pointer to adapter
5222 * @RSNAuthType: pointer to auth type
5223 *
5224 * Return: 0 on success, error number otherwise
5225 */
5226int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5227{
5228 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5229 uint32_t status = 0;
5230 eCsrEncryptionType RSNEncryptType;
5231 eCsrEncryptionType mcRSNEncryptType;
5232#ifdef WLAN_FEATURE_11W
5233 uint8_t RSNMfpRequired = 0;
5234 uint8_t RSNMfpCapable = 0;
5235#endif
5236 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5237 /* MAC address of assoc peer */
5238 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305239 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240 pWextState->roamProfile.BSSIDs.bssid,
5241 sizeof(bssid));
5242 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5243 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5244 /* continue */
5245 } else {
5246 return 0;
5247 }
5248 /* The actual processing may eventually be more extensive than this. */
5249 /* Right now, just consume any PMKIDs that are sent in by the app. */
5250 status = hdd_process_genie(pAdapter, bssid,
5251 &RSNEncryptType,
5252 &mcRSNEncryptType, RSNAuthType,
5253#ifdef WLAN_FEATURE_11W
5254 &RSNMfpRequired, &RSNMfpCapable,
5255#endif
5256 pWextState->WPARSNIE[1] + 2,
5257 pWextState->WPARSNIE);
5258 if (status == 0) {
5259 /*
5260 * Now copy over all the security attributes
5261 * you have parsed out.
5262 */
5263 pWextState->roamProfile.EncryptionType.numEntries = 1;
5264 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5265
5266 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5267 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5268 mcRSNEncryptType;
5269
Krunal Sonibe766b02016-03-10 13:00:44 -08005270 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005271 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5272 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5273 /*
5274 * For wpa none supplicant sends the WPA IE with unicast
5275 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5276 * multicast cipher as either AES/TKIP based on group
5277 * cipher configuration mentioned in the
5278 * wpa_supplicant.conf.
5279 */
5280
5281 /* Set the unicast cipher same as multicast cipher */
5282 pWextState->roamProfile.EncryptionType.encryptionType[0]
5283 = mcRSNEncryptType;
5284 }
5285#ifdef WLAN_FEATURE_11W
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005286 hdd_info("RSNMfpRequired = %d, RSNMfpCapable = %d",
5287 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005288 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5289 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5290#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005291 hdd_info("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
5292 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 }
5294 return 0;
5295}
5296
5297/**
5298 * hdd_set_csr_auth_type() - set csr auth type
5299 * @pAdapter: pointer to adapter
5300 * @RSNAuthType: auth type
5301 *
5302 * Return: 0 on success, error number otherwise
5303 */
5304int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5305{
5306 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5307 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5308 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309
5310 pRoamProfile->AuthType.numEntries = 1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005311 hdd_info("pHddStaCtx->conn_info.authType = %d",
5312 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313
5314 switch (pHddStaCtx->conn_info.authType) {
5315 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5316#ifdef FEATURE_WLAN_ESE
5317 case eCSR_AUTH_TYPE_CCKM_WPA:
5318 case eCSR_AUTH_TYPE_CCKM_RSN:
5319#endif
5320 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5321
5322 pRoamProfile->AuthType.authType[0] =
5323 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5324 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5325
5326#ifdef FEATURE_WLAN_ESE
5327 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5328 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5329 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005330 hdd_info("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331 pRoamProfile->AuthType.authType[0] =
5332 eCSR_AUTH_TYPE_CCKM_WPA;
5333 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005334 hdd_info("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335 pRoamProfile->AuthType.authType[0] =
5336 eCSR_AUTH_TYPE_CCKM_WPA;
5337 } else
5338#endif
5339 if ((pWextState->
5340 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5341 == IW_AUTH_KEY_MGMT_802_1X) {
5342 pRoamProfile->AuthType.authType[0] =
5343 eCSR_AUTH_TYPE_WPA;
5344 } else
5345 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5346 == IW_AUTH_KEY_MGMT_PSK) {
5347 pRoamProfile->AuthType.authType[0] =
5348 eCSR_AUTH_TYPE_WPA_PSK;
5349 } else {
5350 pRoamProfile->AuthType.authType[0] =
5351 eCSR_AUTH_TYPE_WPA_NONE;
5352 }
5353 }
5354 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5355#ifdef FEATURE_WLAN_ESE
5356 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5357 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5358 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005359 hdd_info("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360 pRoamProfile->AuthType.authType[0] =
5361 eCSR_AUTH_TYPE_CCKM_RSN;
5362 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005363 hdd_info("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005364 pRoamProfile->AuthType.authType[0] =
5365 eCSR_AUTH_TYPE_CCKM_RSN;
5366 } else
5367#endif
5368
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5370 ((pWextState->
5371 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5372 == IW_AUTH_KEY_MGMT_802_1X)) {
5373 pRoamProfile->AuthType.authType[0] =
5374 eCSR_AUTH_TYPE_FT_RSN;
5375 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5376 &&
5377 ((pWextState->
5378 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5379 == IW_AUTH_KEY_MGMT_PSK)) {
5380 pRoamProfile->AuthType.authType[0] =
5381 eCSR_AUTH_TYPE_FT_RSN_PSK;
5382 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383
5384#ifdef WLAN_FEATURE_11W
5385 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5386 pRoamProfile->AuthType.authType[0] =
5387 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5388 } else if (RSNAuthType ==
5389 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5390 pRoamProfile->AuthType.authType[0] =
5391 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5392 } else
5393#endif
5394
5395 if ((pWextState->
5396 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5397 == IW_AUTH_KEY_MGMT_802_1X) {
5398 pRoamProfile->AuthType.authType[0] =
5399 eCSR_AUTH_TYPE_RSN;
5400 } else
5401 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5402 == IW_AUTH_KEY_MGMT_PSK) {
5403 pRoamProfile->AuthType.authType[0] =
5404 eCSR_AUTH_TYPE_RSN_PSK;
5405 } else {
5406 pRoamProfile->AuthType.authType[0] =
5407 eCSR_AUTH_TYPE_UNKNOWN;
5408 }
5409 }
5410 break;
5411
5412 case eCSR_AUTH_TYPE_SHARED_KEY:
5413
5414 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5415 break;
5416 default:
5417
5418#ifdef FEATURE_WLAN_ESE
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005419 hdd_info("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005420#endif /* FEATURE_WLAN_ESE */
5421 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5422 break;
5423 }
5424
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005425 hdd_info("Set roam Authtype to %d",
5426 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 return 0;
5429}
5430
5431/**
5432 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5433 * to the CSR roam profile.
5434 *
5435 * @dev: Pointer to the net device.
5436 * @info: Pointer to the iw_request_info.
5437 * @wrqu: Pointer to the iwreq_data.
5438 * @extra: Pointer to the data.
5439 *
5440 * Return: 0 for success, error number on failure
5441 */
5442static int __iw_set_essid(struct net_device *dev,
5443 struct iw_request_info *info,
5444 union iwreq_data *wrqu, char *extra)
5445{
5446 unsigned long rc;
5447 uint32_t status = 0;
5448 hdd_wext_state_t *pWextState;
5449 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5450 hdd_context_t *hdd_ctx;
5451 uint32_t roamId;
5452 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453 eCsrAuthType RSNAuthType;
5454 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5455 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5456 int ret;
5457
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005458 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005459
5460 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5461 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305462 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 return ret;
5464
Krunal Sonibe766b02016-03-10 13:00:44 -08005465 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005466 pAdapter->device_mode != QDF_IBSS_MODE &&
5467 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005468 hdd_warn("device mode %s(%d) is not allowed",
5469 hdd_device_mode_to_string(pAdapter->device_mode),
5470 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005471 return -EINVAL;
5472 }
5473
5474 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5475
5476 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005477 hdd_info("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 return -EBUSY;
5479 }
5480 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5481 return -EINVAL;
5482
5483 pRoamProfile = &pWextState->roamProfile;
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005484 if (hdd_conn_is_connected(pHddStaCtx) ||
5485 (pAdapter->device_mode == QDF_IBSS_MODE)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305486 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487
5488 /* Need to issue a disconnect to CSR. */
5489 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305490 qdf_status = sme_roam_disconnect(hHal, pAdapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5492
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305493 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 rc = wait_for_completion_timeout(&pAdapter->
5495 disconnect_comp_var,
5496 msecs_to_jiffies
5497 (WLAN_WAIT_TIME_DISCONNECT));
5498 if (!rc)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005499 hdd_err("Disconnect event timed out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500 }
5501 }
5502
5503 /*
5504 * when cfg80211 defined, wpa_supplicant wext driver uses
5505 * zero-length, null-string ssid for force disconnection.
5506 * after disconnection (if previously connected) and cleaning ssid,
5507 * driver MUST return success.
5508 */
5509 if (0 == wrqu->essid.length)
5510 return 0;
5511
5512 status = hdd_wmm_get_uapsd_mask(pAdapter,
5513 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305514 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 pWextState->roamProfile.uapsd_mask = 0;
5516
5517 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5518
5519 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5520 wrqu->essid.length;
5521
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305522 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305524 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005525 ssId), extra, wrqu->essid.length);
5526 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5527 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5528
5529 /* set gen ie */
5530 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5531
5532 /* set auth */
5533 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5534 }
5535#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005536 hdd_notice("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005537 if (pAdapter->wapi_info.nWapiMode) {
5538 switch (pAdapter->wapi_info.wapiAuthMode) {
5539 case WAPI_AUTH_MODE_PSK:
5540 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005541 hdd_notice("WAPI AUTH TYPE: PSK: %d",
5542 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543 pRoamProfile->AuthType.numEntries = 1;
5544 pRoamProfile->AuthType.authType[0] =
5545 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5546 break;
5547 }
5548 case WAPI_AUTH_MODE_CERT:
5549 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005550 hdd_notice("WAPI AUTH TYPE: CERT: %d",
5551 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 pRoamProfile->AuthType.numEntries = 1;
5553 pRoamProfile->AuthType.authType[0] =
5554 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5555 break;
5556 }
5557 } /* End of switch */
5558 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5559 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005560 hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 pRoamProfile->EncryptionType.numEntries = 1;
5562 pRoamProfile->EncryptionType.encryptionType[0] =
5563 eCSR_ENCRYPT_TYPE_WPI;
5564 pRoamProfile->mcEncryptionType.numEntries = 1;
5565 pRoamProfile->mcEncryptionType.encryptionType[0] =
5566 eCSR_ENCRYPT_TYPE_WPI;
5567 }
5568 }
5569#endif /* FEATURE_WLAN_WAPI */
5570 /* if previous genIE is not NULL, update AssocIE */
5571 if (0 != pWextState->genIE.length) {
5572 memset(&pWextState->assocAddIE, 0,
5573 sizeof(pWextState->assocAddIE));
5574 memcpy(pWextState->assocAddIE.addIEdata,
5575 pWextState->genIE.addIEdata, pWextState->genIE.length);
5576 pWextState->assocAddIE.length = pWextState->genIE.length;
5577 pWextState->roamProfile.pAddIEAssoc =
5578 pWextState->assocAddIE.addIEdata;
5579 pWextState->roamProfile.nAddIEAssocLength =
5580 pWextState->assocAddIE.length;
5581
5582 /* clear previous genIE after use it */
5583 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5584 }
5585
5586 /*
5587 * Assumes it is not WPS Association by default, except when
5588 * pAddIEAssoc has WPS IE.
5589 */
5590 pWextState->roamProfile.bWPSAssociation = false;
5591
5592 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5593 pWextState->roamProfile.
5594 nAddIEAssocLength))
5595 pWextState->roamProfile.bWPSAssociation = true;
5596
5597 /* Disable auto BMPS entry by PMC until DHCP is done */
5598 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5599 true);
5600
5601 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5602
5603 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005604 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005606 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5607 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005609
Agrawal Ashish6b015762016-05-05 11:22:18 +05305610 /*
5611 * Change conn_state to connecting before sme_roam_connect(),
5612 * because sme_roam_connect() has a direct path to call
5613 * hdd_sme_roam_callback(), which will change the conn_state
5614 * If direct path, conn_state will be accordingly changed to
5615 * NotConnected or Associated by either
5616 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5617 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5618 * Connecting state will remain until it is completed.
5619 *
5620 * If connection state is not changed,
5621 * connection state will remain in eConnectionState_NotConnected state.
5622 * In hdd_association_completion_handler, "hddDisconInProgress" is
5623 * set to true if conn state is eConnectionState_NotConnected.
5624 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5625 * informed of connect result indication which is an issue.
5626 */
5627 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305628 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305629 hdd_conn_set_connection_state(pAdapter,
5630 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 status = sme_roam_connect(hHal, pAdapter->sessionId,
5633 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305634 if ((QDF_STATUS_SUCCESS != status) &&
5635 (QDF_STA_MODE == pAdapter->device_mode ||
5636 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
5637 hdd_err("sme_roam_connect (session %d) failed with status %d. -> NotConnected",
5638 pAdapter->sessionId, status);
5639 /* change back to NotAssociated */
5640 hdd_conn_set_connection_state(pAdapter,
5641 eConnectionState_NotConnected);
5642 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 pRoamProfile->ChannelInfo.ChannelList = NULL;
5644 pRoamProfile->ChannelInfo.numOfChannels = 0;
5645
5646 EXIT();
5647 return status;
5648}
5649
5650/**
5651 * iw_set_essid() - set essid handler function
5652 * @dev: Pointer to the net device.
5653 * @info: Pointer to the iw_request_info.
5654 * @wrqu: Pointer to the iwreq_data.
5655 * @extra: Pointer to the data.
5656 *
5657 * Return: 0 for success, error number on failure
5658 */
5659int iw_set_essid(struct net_device *dev,
5660 struct iw_request_info *info,
5661 union iwreq_data *wrqu, char *extra)
5662{
5663 int ret;
5664
5665 cds_ssr_protect(__func__);
5666 ret = __iw_set_essid(dev, info, wrqu, extra);
5667 cds_ssr_unprotect(__func__);
5668
5669 return ret;
5670}
5671
5672/**
5673 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5674 * @dev: pointer to the net device
5675 * @info: pointer to the iw request info
5676 * @dwrq: pointer to iw_point
5677 * @extra: pointer to the data
5678 *
5679 * Return: 0 on success, error number otherwise
5680 */
5681static int __iw_get_essid(struct net_device *dev,
5682 struct iw_request_info *info,
5683 struct iw_point *dwrq, char *extra)
5684{
5685 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5686 hdd_context_t *hdd_ctx;
5687 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5688 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5689 int ret;
5690
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005691 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692
5693 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5694 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305695 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 return ret;
5697
5698 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5699 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5700 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5701 || pHddStaCtx->conn_info.connState ==
5702 eConnectionState_IbssDisconnected)
5703 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5704 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5705 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5706 dwrq->length);
5707 dwrq->flags = 1;
5708 } else {
5709 memset(extra, 0, dwrq->length);
5710 dwrq->length = 0;
5711 dwrq->flags = 0;
5712 }
5713 EXIT();
5714 return 0;
5715}
5716
5717/**
5718 * iw_get_essid() - get essid handler function
5719 * @dev: Pointer to the net device.
5720 * @info: Pointer to the iw_request_info.
5721 * @wrqu: Pointer to the iwreq_data.
5722 * @extra: Pointer to the data.
5723 *
5724 * Return: 0 for success, error number on failure
5725 */
5726int iw_get_essid(struct net_device *dev,
5727 struct iw_request_info *info,
5728 struct iw_point *wrqu, char *extra)
5729{
5730 int ret;
5731
5732 cds_ssr_protect(__func__);
5733 ret = __iw_get_essid(dev, info, wrqu, extra);
5734 cds_ssr_unprotect(__func__);
5735
5736 return ret;
5737}
5738
5739/**
5740 * __iw_set_auth() -
5741 * This function sets the auth type received from the wpa_supplicant
5742 * @dev: pointer to the net device
5743 * @info: pointer to the iw request info
5744 * @wrqu: pointer to iwreq_data
5745 * @extra: pointer to the data
5746 *
5747 * Return: 0 on success, error number otherwise
5748 */
5749static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5750 union iwreq_data *wrqu, char *extra)
5751{
5752 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5753 hdd_context_t *hdd_ctx;
5754 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5755 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5756 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5757 eCsrEncryptionType mcEncryptionType;
5758 eCsrEncryptionType ucEncryptionType;
5759 int ret;
5760
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005761 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762
5763 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5764 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305765 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005766 return ret;
5767
5768 switch (wrqu->param.flags & IW_AUTH_INDEX) {
5769 case IW_AUTH_WPA_VERSION:
5770 pWextState->wpaVersion = wrqu->param.value;
5771 break;
5772
5773 case IW_AUTH_CIPHER_PAIRWISE:
5774 {
5775 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5776 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5777 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5778 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5779 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5780 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5781 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5782 if ((IW_AUTH_KEY_MGMT_802_1X
5783 ==
5784 (pWextState->
5785 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5786 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5787 pHddStaCtx->conn_info.authType))
5788 /*Dynamic WEP key */
5789 ucEncryptionType =
5790 eCSR_ENCRYPT_TYPE_WEP40;
5791 else
5792 /*Static WEP key */
5793 ucEncryptionType =
5794 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5795 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5796 if ((IW_AUTH_KEY_MGMT_802_1X
5797 ==
5798 (pWextState->
5799 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5800 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5801 pHddStaCtx->conn_info.authType))
5802 /*Dynamic WEP key */
5803 ucEncryptionType =
5804 eCSR_ENCRYPT_TYPE_WEP104;
5805 else
5806 /*Static WEP key */
5807 ucEncryptionType =
5808 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5809 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005810 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
5811 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812 return -EINVAL;
5813 }
5814
5815 pRoamProfile->EncryptionType.numEntries = 1;
5816 pRoamProfile->EncryptionType.encryptionType[0] =
5817 ucEncryptionType;
5818 }
5819 break;
5820 case IW_AUTH_CIPHER_GROUP:
5821 {
5822 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5823 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5824 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5825 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5826 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5827 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5828 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5829 if ((IW_AUTH_KEY_MGMT_802_1X
5830 ==
5831 (pWextState->
5832 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5833 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5834 pHddStaCtx->conn_info.authType))
5835 mcEncryptionType =
5836 eCSR_ENCRYPT_TYPE_WEP40;
5837 else
5838 mcEncryptionType =
5839 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5840 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5841 /* Dynamic WEP keys won't work with shared keys */
5842 if ((IW_AUTH_KEY_MGMT_802_1X
5843 ==
5844 (pWextState->
5845 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5846 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5847 pHddStaCtx->conn_info.authType)) {
5848 mcEncryptionType =
5849 eCSR_ENCRYPT_TYPE_WEP104;
5850 } else {
5851 mcEncryptionType =
5852 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5853 }
5854 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005855 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 wrqu->param.value);
5857 return -EINVAL;
5858 }
5859
5860 pRoamProfile->mcEncryptionType.numEntries = 1;
5861 pRoamProfile->mcEncryptionType.encryptionType[0] =
5862 mcEncryptionType;
5863 }
5864 break;
5865
5866 case IW_AUTH_80211_AUTH_ALG:
5867 {
5868 /* Save the auth algo here and set auth type to SME Roam profile
5869 in the iw_set_ap_address */
5870 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
5871 pHddStaCtx->conn_info.authType =
5872 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5873
5874 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5875 pHddStaCtx->conn_info.authType =
5876 eCSR_AUTH_TYPE_SHARED_KEY;
5877
5878 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
5879 /*Not supported */
5880 pHddStaCtx->conn_info.authType =
5881 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5882 pWextState->roamProfile.AuthType.authType[0] =
5883 pHddStaCtx->conn_info.authType;
5884 }
5885 break;
5886
5887 case IW_AUTH_KEY_MGMT:
5888 {
5889#ifdef FEATURE_WLAN_ESE
5890#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5891 /*Check for CCKM AKM type */
5892 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005893 hdd_info("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005894 /* Set the CCKM bit in authKeyMgmt */
5895 /*
5896 * Right now, this breaks all ref to authKeyMgmt because
5897 * our code doesn't realize it is a "bitfield"
5898 */
5899 pWextState->authKeyMgmt |=
5900 IW_AUTH_KEY_MGMT_CCKM;
5901 /* Set the key management to 802.1X */
5902 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
5903 pWextState->isESEConnection = true;
5904 /*
5905 * This is test code. I need to actually KNOW whether
5906 * this is an RSN Assoc or WPA.
5907 */
5908 pWextState->collectedAuthType =
5909 eCSR_AUTH_TYPE_CCKM_RSN;
5910 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5911 /* Save the key management */
5912 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5913 pWextState->collectedAuthType =
5914 eCSR_AUTH_TYPE_RSN;
5915 } else
5916 if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5917 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE;
5918 /* Save the key management anyway */
5919 pWextState->authKeyMgmt = wrqu->param.value;
5920 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
5921 /* Save the key management */
5922 pWextState->authKeyMgmt |=
5923 IW_AUTH_KEY_MGMT_802_1X;
5924 pWextState->collectedAuthType =
5925 eCSR_AUTH_TYPE_RSN;
5926 }
5927#else
5928 /* Save the key management */
5929 pWextState->authKeyMgmt = wrqu->param.value;
5930#endif /* FEATURE_WLAN_ESE */
5931 }
5932 break;
5933
5934 case IW_AUTH_TKIP_COUNTERMEASURES:
5935 {
5936 if (wrqu->param.value) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005937 hdd_info("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 wrqu->param.value);
5939 pWextState->mTKIPCounterMeasures =
5940 TKIP_COUNTER_MEASURE_STARTED;
5941 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005942 hdd_info("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943 wrqu->param.value);
5944 pWextState->mTKIPCounterMeasures =
5945 TKIP_COUNTER_MEASURE_STOPED;
5946 }
5947 }
5948 break;
5949 case IW_AUTH_DROP_UNENCRYPTED:
5950 case IW_AUTH_WPA_ENABLED:
5951 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5952 case IW_AUTH_ROAMING_CONTROL:
5953 case IW_AUTH_PRIVACY_INVOKED:
5954
5955 default:
5956
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005957 hdd_warn("called with unsupported auth type %d",
5958 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005959 break;
5960 }
5961
5962 EXIT();
5963 return 0;
5964}
5965
5966/**
5967 * iw_set_auth() - set auth callback function
5968 * @dev: Pointer to the net device.
5969 * @info: Pointer to the iw_request_info.
5970 * @wrqu: Pointer to the iwreq_data.
5971 * @extra: Pointer to the data.
5972 *
5973 * Return: 0 for success, error number on failure.
5974 */
5975int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5976 union iwreq_data *wrqu, char *extra)
5977{
5978 int ret;
5979
5980 cds_ssr_protect(__func__);
5981 ret = __iw_set_auth(dev, info, wrqu, extra);
5982 cds_ssr_unprotect(__func__);
5983
5984 return ret;
5985}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986/**
5987 * __iw_get_auth() -
5988 * This function returns the auth type to the wpa_supplicant
5989 * @dev: pointer to the net device
5990 * @info: pointer to the iw request info
5991 * @wrqu: pointer to iwreq_data
5992 * @extra: pointer to the data
5993 *
5994 * Return: 0 on success, error number otherwise
5995 */
5996static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
5997 union iwreq_data *wrqu, char *extra)
5998{
5999 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6000 hdd_context_t *hdd_ctx;
6001 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6002 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6003 int ret;
6004
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006005 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006006
6007 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6008 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306009 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 return ret;
6011
6012 switch (pRoamProfile->negotiatedAuthType) {
6013 case eCSR_AUTH_TYPE_WPA_NONE:
6014 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6015 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6016 break;
6017 case eCSR_AUTH_TYPE_WPA:
6018 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6019 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6020 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023 case eCSR_AUTH_TYPE_RSN:
6024 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6025 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6026 break;
6027 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6028 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6029 break;
6030 case eCSR_AUTH_TYPE_SHARED_KEY:
6031 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6032 break;
6033 case eCSR_AUTH_TYPE_UNKNOWN:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006034 hdd_info("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6036 break;
6037 case eCSR_AUTH_TYPE_AUTOSWITCH:
6038 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6039 break;
6040 case eCSR_AUTH_TYPE_WPA_PSK:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006041 hdd_info("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006042 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6043 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 case eCSR_AUTH_TYPE_RSN_PSK:
6047#ifdef WLAN_FEATURE_11W
6048 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6049 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6050#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006051 hdd_info("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006052 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6053 return -EIO;
6054 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006055 hdd_err("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6057 return -EIO;
6058 }
6059 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6060 switch (pRoamProfile->negotiatedUCEncryptionType) {
6061 case eCSR_ENCRYPT_TYPE_NONE:
6062 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6063 break;
6064 case eCSR_ENCRYPT_TYPE_WEP40:
6065 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6066 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6067 break;
6068 case eCSR_ENCRYPT_TYPE_TKIP:
6069 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6070 break;
6071 case eCSR_ENCRYPT_TYPE_WEP104:
6072 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6073 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6074 break;
6075 case eCSR_ENCRYPT_TYPE_AES:
6076 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6077 break;
6078 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006079 hdd_notice("called with unknown auth type %d",
6080 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 return -EIO;
6082 }
6083 }
6084
6085 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6086 switch (pRoamProfile->negotiatedMCEncryptionType) {
6087 case eCSR_ENCRYPT_TYPE_NONE:
6088 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6089 break;
6090 case eCSR_ENCRYPT_TYPE_WEP40:
6091 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6092 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6093 break;
6094 case eCSR_ENCRYPT_TYPE_TKIP:
6095 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6096 break;
6097 case eCSR_ENCRYPT_TYPE_WEP104:
6098 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6099 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6100 break;
6101 case eCSR_ENCRYPT_TYPE_AES:
6102 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6103 break;
6104 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006105 hdd_info("called with unknown auth type %d",
6106 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006107 return -EIO;
6108 }
6109 }
6110
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006111 hdd_info("called with auth type %d",
6112 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113 EXIT();
6114 return 0;
6115}
6116
6117/**
6118 * iw_get_auth() - get auth callback function
6119 * @dev: Pointer to the net device.
6120 * @info: Pointer to the iw_request_info.
6121 * @wrqu: Pointer to the iwreq_data.
6122 * @extra: Pointer to the data.
6123 *
6124 * Return: 0 for success, error number on failure.
6125 */
6126int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6127 union iwreq_data *wrqu, char *extra)
6128{
6129 int ret;
6130
6131 cds_ssr_protect(__func__);
6132 ret = __iw_get_auth(dev, info, wrqu, extra);
6133 cds_ssr_unprotect(__func__);
6134
6135 return ret;
6136}
6137
6138/**
6139 * __iw_set_ap_address() - set ap address
6140 * @dev: pointer to the net device
6141 * @info: pointer to the iw request info
6142 * @wrqu: pointer to iwreq_data
6143 * @extra: pointer to the data
6144 *
6145 * This function updates the HDD global station context connection info
6146 * BSSID with the MAC address received from the wpa_supplicant.
6147 *
6148 * Return: 0 on success, error number otherwise
6149 */
6150static int __iw_set_ap_address(struct net_device *dev,
6151 struct iw_request_info *info,
6152 union iwreq_data *wrqu, char *extra)
6153{
6154
6155 hdd_adapter_t *adapter;
6156 hdd_context_t *hdd_ctx;
6157 hdd_station_ctx_t *pHddStaCtx =
6158 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6159 uint8_t *pMacAddress = NULL;
6160 int ret;
6161
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006162 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163
6164 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6165
6166 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6167 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306168 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 return ret;
6170
6171 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006172 hdd_info(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306173 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306174 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 EXIT();
6176
6177 return 0;
6178}
6179
6180/**
6181 * iw_set_ap_address() - set ap addresses callback function
6182 * @dev: Pointer to the net device.
6183 * @info: Pointer to the iw_request_info.
6184 * @wrqu: Pointer to the iwreq_data.
6185 * @extra: Pointer to the data.
6186 *
6187 * Return: 0 for success, error number on failure.
6188 */
6189int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6190 union iwreq_data *wrqu, char *extra)
6191{
6192 int ret;
6193
6194 cds_ssr_protect(__func__);
6195 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6196 cds_ssr_unprotect(__func__);
6197
6198 return ret;
6199}
6200
6201/**
6202 * __iw_get_ap_address() - get ap address
6203 * @dev: pointer to the net device
6204 * @info: pointer to the iw request info
6205 * @wrqu: pointer to iwreq_data
6206 * @extra: pointer to the data
6207 *
6208 * This function returns currently associated BSSID.
6209 *
6210 * Return: 0 on success, error number otherwise
6211 */
6212static int __iw_get_ap_address(struct net_device *dev,
6213 struct iw_request_info *info,
6214 union iwreq_data *wrqu, char *extra)
6215{
6216 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6217 hdd_context_t *hdd_ctx;
6218 hdd_station_ctx_t *pHddStaCtx =
6219 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6220 int ret;
6221
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006222 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006223
6224 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6225 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306226 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006227 return ret;
6228
6229 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6230 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306231 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006232 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306233 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006234 } else {
6235 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6236 }
6237 EXIT();
6238 return 0;
6239}
6240
6241/**
6242 * iw_get_ap_address() - get ap addresses callback function
6243 * @dev: Pointer to the net device.
6244 * @info: Pointer to the iw_request_info.
6245 * @wrqu: Pointer to the iwreq_data.
6246 * @extra: Pointer to the data.
6247 *
6248 * Return: 0 for success, error number on failure.
6249 */
6250int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6251 union iwreq_data *wrqu, char *extra)
6252{
6253 int ret;
6254
6255 cds_ssr_protect(__func__);
6256 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6257 cds_ssr_unprotect(__func__);
6258
6259 return ret;
6260}