blob: 0171652590368412b2ea5eb2fef4ae5b791bb809 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_assoc.c
30 *
31 * WLAN Host Device Driver implementation
32 *
33 */
34
35#include "wlan_hdd_includes.h"
36#include <ani_global.h>
37#include "dot11f.h"
38#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053039#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include <linux/ieee80211.h>
41#include <linux/wireless.h>
42#include <linux/etherdevice.h>
43#include <net/cfg80211.h>
44#include "wlan_hdd_cfg80211.h"
45#include "csr_inside_api.h"
46#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_api.h"
49#include "wlan_hdd_hostapd.h"
50#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070051#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070052#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <cds_sched.h>
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -080054#include "wlan_policy_mgr_api.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053055#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070057#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070058#include <cdp_txrx_cmn.h>
59#include <cdp_txrx_flow_ctrl_legacy.h>
60#include <cdp_txrx_peer_ops.h>
61#include <cdp_txrx_misc.h>
Kabilan Kannan256e3182017-05-02 16:02:37 -070062#include <cdp_txrx_ctrl.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053063#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080064#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080065#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053066#include "wlan_pmo_ucfg_api.h"
Yu Wang000dc2f2017-05-26 17:38:48 +080067#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
69/* These are needed to recognize WPA and RSN suite types */
70#define HDD_WPA_OUI_SIZE 4
71#define HDD_RSN_OUI_SIZE 4
72uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
73uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
74uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
75uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
76uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
77uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
78
79#ifdef FEATURE_WLAN_ESE
80/* CCKM */
81uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
82/* CCKM */
83uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
84#endif /* FEATURE_WLAN_ESE */
85
86/* group cipher */
87uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
88
89/* WEP-40 or RSN */
90uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
91
92/* TKIP or RSN-PSK */
93uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
94
95/* Reserved */
96uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
97
98/* AES-CCMP */
99uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
100
101/* WEP-104 */
102uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
103
104#ifdef WLAN_FEATURE_11W
105/* RSN-PSK-SHA256 */
106uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
107
108/* RSN-8021X-SHA256 */
109uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
110#endif
111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112/* Offset where the EID-Len-IE, start. */
113#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
114#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115
116#define BEACON_FRAME_IES_OFFSET 12
117#define HDD_PEER_AUTHORIZE_WAIT 10
118
119/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700120 * beacon_filter_table - table of IEs used for beacon filtering
121 */
122static const int beacon_filter_table[] = {
123 SIR_MAC_DS_PARAM_SET_EID,
124 SIR_MAC_ERP_INFO_EID,
125 SIR_MAC_EDCA_PARAM_SET_EID,
126 SIR_MAC_QOS_CAPABILITY_EID,
127 SIR_MAC_HT_INFO_EID,
128 SIR_MAC_VHT_OPMODE_EID,
129 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700130#ifdef WLAN_FEATURE_11AX_BSS_COLOR
131 /*
132 * EID: 221 vendor IE is being used temporarily by 11AX
133 * bss-color-change IE till it gets any fixed number. This
134 * vendor EID needs to be replaced with bss-color-change IE
135 * number.
136 */
137 SIR_MAC_EID_VENDOR,
138#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700139};
140
141/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 * hdd_conn_set_authenticated() - set authentication state
143 * @pAdapter: pointer to the adapter
144 * @authState: authentication state
145 *
146 * This function updates the global HDD station context
147 * authentication state.
148 *
149 * Return: none
150 */
151static void
152hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
153{
154 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
155 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
156
157 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700158 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700159 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 pHddStaCtx->conn_info.uIsAuthenticated = authState;
161
162 /* Check is pending ROC request or not when auth state changed */
163 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
164}
165
166/**
167 * hdd_conn_set_connection_state() - set connection state
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700168 * @adapter: pointer to the adapter
169 * @conn_state: connection state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 *
171 * This function updates the global HDD station context connection state.
172 *
173 * Return: none
174 */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700175void hdd_conn_set_connection_state(hdd_adapter_t *adapter,
176 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177{
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700178 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
179 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180
181 /* save the new connection state */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700182 hdd_debug("%pS Changed conn state from old:%d to new:%d for dev %s",
183 (void *)_RET_IP_, hdd_sta_ctx->conn_info.connState,
184 conn_state, adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800185
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700186 hdd_tsf_notify_wlan_state_change(adapter,
187 hdd_sta_ctx->conn_info.connState,
188 conn_state);
189 hdd_sta_ctx->conn_info.connState = conn_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800190
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700191 schedule_delayed_work(&hdd_ctx->roc_req_work, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192}
193
194/**
195 * hdd_conn_get_connection_state() - get connection state
196 * @pAdapter: pointer to the adapter
197 * @pConnState: pointer to connection state
198 *
199 * This function updates the global HDD station context connection state.
200 *
201 * Return: true if (Infra Associated or IBSS Connected)
202 * and sets output parameter pConnState;
203 * false otherwise
204 */
205static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
206 eConnectionState *pConnState)
207{
208 bool fConnected = false;
209 eConnectionState connState;
210
211 /* get the connection state. */
212 connState = pHddStaCtx->conn_info.connState;
213
214 if (eConnectionState_Associated == connState ||
215 eConnectionState_IbssConnected == connState ||
216 eConnectionState_IbssDisconnected == connState) {
217 fConnected = true;
218 }
219
220 if (pConnState)
221 *pConnState = connState;
222
223 return fConnected;
224}
225
226/**
227 * hdd_is_connecting() - Function to check connection progress
228 * @hdd_sta_ctx: pointer to global HDD Station context
229 *
230 * Return: true if connecting, false otherwise
231 */
232bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
233{
234 return hdd_sta_ctx->conn_info.connState ==
235 eConnectionState_Connecting;
236}
237
238/**
239 * hdd_conn_is_connected() - Function to check connection status
240 * @pHddStaCtx: pointer to global HDD Station context
241 *
242 * Return: false if any errors encountered, true otherwise
243 */
244bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
245{
246 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
247}
248
249/**
250 * hdd_conn_get_connected_band() - get current connection radio band
251 * @pHddStaCtx: pointer to global HDD Station context
252 *
253 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
254 * eCSR_BAND_ALL if not connected
255 */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700256enum band_info hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257{
258 uint8_t staChannel = 0;
259
260 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
261 staChannel = pHddStaCtx->conn_info.operationChannel;
262
263 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700264 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700266 return BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267 else /* If station is not connected return as eCSR_BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700268 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269}
270
271/**
272 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
273 * @pHddStaCtx: pointer to global HDD Station context
274 * @pConnectedCipherAlgo: pointer to connected cipher algo
275 *
276 * Return: false if any errors encountered, true otherwise
277 */
278static inline bool
279hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
280 eCsrEncryptionType *pConnectedCipherAlgo)
281{
282 bool fConnected = false;
283
284 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
285
286 if (pConnectedCipherAlgo)
287 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
288
289 return fConnected;
290}
291
292/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700293 * hdd_remove_beacon_filter() - remove beacon filter
294 * @adapter: Pointer to the hdd adapter
295 *
296 * Return: 0 on success and errno on failure
297 */
298static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
299{
300 QDF_STATUS status;
301 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
302
303 status = sme_remove_beacon_filter(hdd_ctx->hHal,
304 adapter->sessionId);
305 if (!QDF_IS_STATUS_SUCCESS(status)) {
306 hdd_err("sme_remove_beacon_filter() failed");
307 return -EFAULT;
308 }
309
310 return 0;
311}
312
313/**
314 * hdd_add_beacon_filter() - add beacon filter
315 * @adapter: Pointer to the hdd adapter
316 *
317 * Return: 0 on success and errno on failure
318 */
319static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
320{
321 int i;
322 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
323 QDF_STATUS status;
324 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
325
326 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530327 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700328 (unsigned long int *)ie_map);
329
330 status = sme_add_beacon_filter(hdd_ctx->hHal,
331 adapter->sessionId, ie_map);
332 if (!QDF_IS_STATUS_SUCCESS(status)) {
333 hdd_err("sme_add_beacon_filter() failed");
334 return -EFAULT;
335 }
336 return 0;
337}
338
339/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530340 * hdd_copy_vht_caps()- copy vht caps info from roam info to
341 * hdd station context.
342 * @hdd_sta_ctx: pointer to hdd station context
343 * @roam_info: pointer to roam info
344 *
345 * Return: None
346 */
347static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
348 tCsrRoamInfo *roam_info)
349{
350 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
351 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
352 uint32_t i, temp_ht_cap;
353
354 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
355
356 if (roam_ht_cap->advCodingCap)
357 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
358 if (roam_ht_cap->supportedChannelWidthSet)
359 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
360 temp_ht_cap = roam_ht_cap->mimoPowerSave &
361 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
362 if (temp_ht_cap)
363 hdd_ht_cap->cap_info |=
364 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
365 if (roam_ht_cap->greenField)
366 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
367 if (roam_ht_cap->shortGI20MHz)
368 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
369 if (roam_ht_cap->shortGI40MHz)
370 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
371 if (roam_ht_cap->txSTBC)
372 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
373 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
374 IEEE80211_HT_CAP_RX_STBC_SHIFT);
375 if (temp_ht_cap)
376 hdd_ht_cap->cap_info |=
377 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
378 if (roam_ht_cap->delayedBA)
379 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
380 if (roam_ht_cap->maximalAMSDUsize)
381 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
382 if (roam_ht_cap->dsssCckMode40MHz)
383 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
384 if (roam_ht_cap->psmp)
385 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
386 if (roam_ht_cap->stbcControlFrame)
387 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
388 if (roam_ht_cap->lsigTXOPProtection)
389 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
390
391 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
392 if (roam_ht_cap->maxRxAMPDUFactor)
393 hdd_ht_cap->ampdu_params_info |=
394 IEEE80211_HT_AMPDU_PARM_FACTOR;
395 temp_ht_cap = roam_ht_cap->mpduDensity &
396 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
397 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
398 if (temp_ht_cap)
399 hdd_ht_cap->ampdu_params_info |=
400 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
401
402 /* 802.11n HT extended capabilities masks */
403 if (roam_ht_cap->pco)
404 hdd_ht_cap->extended_ht_cap_info |=
405 IEEE80211_HT_EXT_CAP_PCO;
406 temp_ht_cap = roam_ht_cap->transitionTime &
407 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
408 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
409 if (temp_ht_cap)
410 hdd_ht_cap->extended_ht_cap_info |=
411 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
412 temp_ht_cap = roam_ht_cap->mcsFeedback &
413 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
414 if (temp_ht_cap)
415 hdd_ht_cap->extended_ht_cap_info |=
416 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
417
418 /* tx_bf_cap_info capabilities */
419 if (roam_ht_cap->txBF)
420 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
421 if (roam_ht_cap->rxStaggeredSounding)
422 hdd_ht_cap->tx_BF_cap_info |=
423 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
424 if (roam_ht_cap->txStaggeredSounding)
425 hdd_ht_cap->tx_BF_cap_info |=
426 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
427 if (roam_ht_cap->rxZLF)
428 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
429 if (roam_ht_cap->txZLF)
430 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
431 if (roam_ht_cap->implicitTxBF)
432 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
433 temp_ht_cap = roam_ht_cap->calibration &
434 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
435 if (temp_ht_cap)
436 hdd_ht_cap->tx_BF_cap_info |=
437 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
438 if (roam_ht_cap->explicitCSITxBF)
439 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
440 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
441 hdd_ht_cap->tx_BF_cap_info |=
442 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
443 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
444 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
445 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
446 if (temp_ht_cap)
447 hdd_ht_cap->tx_BF_cap_info |=
448 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
449 temp_ht_cap =
450 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
451 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
452 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
453 if (temp_ht_cap)
454 hdd_ht_cap->tx_BF_cap_info |=
455 temp_ht_cap <<
456 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
457 temp_ht_cap =
458 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
459 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
460 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
461 if (temp_ht_cap)
462 hdd_ht_cap->tx_BF_cap_info |=
463 temp_ht_cap <<
464 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
465 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
466 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
467 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
468 if (temp_ht_cap)
469 hdd_ht_cap->tx_BF_cap_info |=
470 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
471 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
472 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
473 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
474 if (temp_ht_cap)
475 hdd_ht_cap->tx_BF_cap_info |=
476 temp_ht_cap <<
477 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
478 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
479 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
480 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
481 if (temp_ht_cap)
482 hdd_ht_cap->tx_BF_cap_info |=
483 temp_ht_cap <<
484 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
485
486 /* antenna selection */
487 if (roam_ht_cap->antennaSelection)
488 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
489 if (roam_ht_cap->explicitCSIFeedbackTx)
490 hdd_ht_cap->antenna_selection_info |=
491 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
492 if (roam_ht_cap->antennaIndicesFeedbackTx)
493 hdd_ht_cap->antenna_selection_info |=
494 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
495 if (roam_ht_cap->explicitCSIFeedback)
496 hdd_ht_cap->antenna_selection_info |=
497 ANTENNA_SEL_INFO_EXP_CSI_FB;
498 if (roam_ht_cap->antennaIndicesFeedback)
499 hdd_ht_cap->antenna_selection_info |=
500 ANTENNA_SEL_INFO_ANT_ID_FB;
501 if (roam_ht_cap->rxAS)
502 hdd_ht_cap->antenna_selection_info |=
503 ANTENNA_SEL_INFO_RX_AS;
504 if (roam_ht_cap->txSoundingPPDUs)
505 hdd_ht_cap->antenna_selection_info |=
506 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
507
508 /* mcs data rate */
509 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
510 hdd_ht_cap->mcs.rx_mask[i] =
511 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800512 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530513 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
514 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800515 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530516 roam_ht_cap->supportedMCSSet[12];
517}
518
519#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
520#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
521#define VHT_CAP_RXSTBC_MASK_SHIFT 8
522#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
523#define VHT_CAP_BEAMFORMEE_STS_MASK \
524 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
525#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
526#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
527 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
528#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
529#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
530 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
531#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
532
533/**
534 * hdd_copy_ht_caps()- copy ht caps info from roam info to
535 * hdd station context.
536 * @hdd_sta_ctx: pointer to hdd station context
537 * @roam_info: pointer to roam info
538 *
539 * Return: None
540 */
541static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
542 tCsrRoamInfo *roam_info)
543{
544 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
545 struct ieee80211_vht_cap *hdd_vht_cap =
546 &hdd_sta_ctx->conn_info.vht_caps;
547 uint32_t temp_vht_cap;
548
549 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
550
551 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
552 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
553 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
554 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
555 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800556 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530557 if (roam_vht_cap->supportedChannelWidthSet &
558 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
559 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
560 hdd_vht_cap->vht_cap_info |=
561 temp_vht_cap <<
562 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
563 if (roam_vht_cap->supportedChannelWidthSet &
564 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
565 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
566 hdd_vht_cap->vht_cap_info |=
567 temp_vht_cap <<
568 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800569 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530570 if (roam_vht_cap->ldpcCodingCap)
571 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
572 if (roam_vht_cap->shortGI80MHz)
573 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
574 if (roam_vht_cap->shortGI160and80plus80MHz)
575 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
576 if (roam_vht_cap->txSTBC)
577 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
578 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
579 VHT_CAP_RXSTBC_MASK_SHIFT);
580 if (temp_vht_cap)
581 hdd_vht_cap->vht_cap_info |=
582 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
583 if (roam_vht_cap->suBeamFormerCap)
584 hdd_vht_cap->vht_cap_info |=
585 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
586 if (roam_vht_cap->suBeamformeeCap)
587 hdd_vht_cap->vht_cap_info |=
588 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
589 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
590 (VHT_CAP_BEAMFORMEE_STS_MASK);
591 if (temp_vht_cap)
592 hdd_vht_cap->vht_cap_info |=
593 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
594 temp_vht_cap = roam_vht_cap->numSoundingDim &
595 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
596 if (temp_vht_cap)
597 hdd_vht_cap->vht_cap_info |=
598 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
599 if (roam_vht_cap->muBeamformerCap)
600 hdd_vht_cap->vht_cap_info |=
601 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
602 if (roam_vht_cap->muBeamformeeCap)
603 hdd_vht_cap->vht_cap_info |=
604 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
605 if (roam_vht_cap->vhtTXOPPS)
606 hdd_vht_cap->vht_cap_info |=
607 IEEE80211_VHT_CAP_VHT_TXOP_PS;
608 if (roam_vht_cap->htcVHTCap)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_HTC_VHT;
611 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
612 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
613 if (temp_vht_cap)
614 hdd_vht_cap->vht_cap_info |=
615 temp_vht_cap <<
616 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
617 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
618 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
619 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
620 if (temp_vht_cap)
621 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
622 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
623 if (roam_vht_cap->rxAntPattern)
624 hdd_vht_cap->vht_cap_info |=
625 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
626 if (roam_vht_cap->txAntPattern)
627 hdd_vht_cap->vht_cap_info |=
628 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
629 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
630 hdd_vht_cap->supp_mcs.rx_highest =
631 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
632 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
633 hdd_vht_cap->supp_mcs.tx_highest =
634 ((uint16_t)roam_vht_cap->txSupDataRate);
635}
636
637/* ht param */
638#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
639#define HT_PARAM_SERVICE_INT_GRAN 0xe0
640#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
641
642/* operatinon mode */
643#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
644
645/* stbc_param */
646#define HT_STBC_PARAM_MCS 0x007f
647
648/**
649 * hdd_copy_ht_operation()- copy HT operation element from roam info to
650 * hdd station context.
651 * @hdd_sta_ctx: pointer to hdd station context
652 * @roam_info: pointer to roam info
653 *
654 * Return: None
655 */
656static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
657 tCsrRoamInfo *roam_info)
658{
659 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
660 struct ieee80211_ht_operation *hdd_ht_ops =
661 &hdd_sta_ctx->conn_info.ht_operation;
662 uint32_t i, temp_ht_ops;
663
664 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
665
666 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
667
668 /* HT_PARAMS */
669 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
670 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
671 if (temp_ht_ops)
672 hdd_ht_ops->ht_param |= temp_ht_ops;
673 else
674 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
675 if (roam_ht_ops->recommendedTxWidthSet)
676 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
677 if (roam_ht_ops->rifsMode)
678 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
679 if (roam_ht_ops->controlledAccessOnly)
680 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
681 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
682 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
683 if (temp_ht_ops)
684 hdd_ht_ops->ht_param |= temp_ht_ops <<
685 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
686
687 /* operation mode */
688 temp_ht_ops = roam_ht_ops->opMode &
689 IEEE80211_HT_OP_MODE_PROTECTION;
690 switch (temp_ht_ops) {
691 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
692 hdd_ht_ops->operation_mode |=
693 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
694 break;
695 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
696 hdd_ht_ops->operation_mode |=
697 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
698 break;
699 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
700 hdd_ht_ops->operation_mode |=
701 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
702 break;
703 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
704 default:
705 hdd_ht_ops->operation_mode |=
706 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
707 }
708 if (roam_ht_ops->nonGFDevicesPresent)
709 hdd_ht_ops->operation_mode |=
710 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
711 if (roam_ht_ops->transmitBurstLimit)
712 hdd_ht_ops->operation_mode |=
713 HT_OP_MODE_TX_BURST_LIMIT;
714 if (roam_ht_ops->obssNonHTStaPresent)
715 hdd_ht_ops->operation_mode |=
716 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
717
718 /* stbc_param */
719 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
720 HT_STBC_PARAM_MCS;
721 if (temp_ht_ops)
722 hdd_ht_ops->stbc_param |= temp_ht_ops;
723 if (roam_ht_ops->dualCTSProtection)
724 hdd_ht_ops->stbc_param |=
725 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
726 if (roam_ht_ops->secondaryBeacon)
727 hdd_ht_ops->stbc_param |=
728 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
729 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
730 hdd_ht_ops->stbc_param |=
731 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
732 if (roam_ht_ops->pcoActive)
733 hdd_ht_ops->stbc_param |=
734 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
735 if (roam_ht_ops->pcoPhase)
736 hdd_ht_ops->stbc_param |=
737 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
738
739 /* basic MCs set */
740 for (i = 0; i < 16; ++i)
741 hdd_ht_ops->basic_set[i] =
742 roam_ht_ops->basicMCSSet[i];
743}
744
745/**
746 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
747 * hdd station context.
748 * @hdd_sta_ctx: pointer to hdd station context
749 * @roam_info: pointer to roam info
750 *
751 * Return: None
752 */
753static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
754 tCsrRoamInfo *roam_info)
755{
756 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
757 struct ieee80211_vht_operation *hdd_vht_ops =
758 &hdd_sta_ctx->conn_info.vht_operation;
759
760 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
761
762 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
763 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
764 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
765 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
766}
767
768
769/**
770 * hdd_save_bss_info() - save connection info in hdd sta ctx
771 * @adapter: Pointer to adapter
772 * @roam_info: pointer to roam info
773 *
774 * Return: None
775 */
776static void hdd_save_bss_info(hdd_adapter_t *adapter,
777 tCsrRoamInfo *roam_info)
778{
779 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
780
781 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
782 hdd_sta_ctx->conn_info.operationChannel);
783 if (roam_info->vht_caps.present) {
784 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
785 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
786 } else {
787 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
788 }
789 if (roam_info->ht_caps.present) {
790 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
791 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
792 } else {
793 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
794 }
795 if (roam_info->reassoc)
796 hdd_sta_ctx->conn_info.roam_count++;
797 if (roam_info->hs20vendor_ie.present) {
798 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
799 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
800 &roam_info->hs20vendor_ie,
801 sizeof(roam_info->hs20vendor_ie));
802 } else {
803 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
804 }
805 if (roam_info->ht_operation.present) {
806 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
807 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
808 } else {
809 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
810 }
811 if (roam_info->vht_operation.present) {
812 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
813 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
814 } else {
815 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
816 }
817}
818
819/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 * hdd_conn_save_connect_info() - save current connection information
821 * @pAdapter: pointer to adapter
822 * @pRoamInfo: pointer to roam info
823 * @eBssType: bss type
824 *
825 * Return: none
826 */
827static void
828hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
829 eCsrRoamBssType eBssType)
830{
831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
832 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
833
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530834 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835
836 if (pRoamInfo) {
837 /* Save the BSSID for the connection */
838 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530839 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530840 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 &pRoamInfo->bssid);
842
843 /*
844 * Save the Station ID for this station from
845 * the 'Roam Info'. For IBSS mode, staId is
846 * assigned in NEW_PEER_IND. For reassoc,
847 * the staID doesn't change and it may be invalid
848 * in this structure so no change here.
849 */
850 if (!pRoamInfo->fReassocReq) {
851 pHddStaCtx->conn_info.staId[0] =
852 pRoamInfo->staId;
853 }
854 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530855 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 &pRoamInfo->bssid);
857 } else {
858 /*
859 * can't happen. We need a valid IBSS or Infra setting
860 * in the BSSDescription or we can't function.
861 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530862 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 }
864
865 /* notify WMM */
866 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
867
868 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530869 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 } else {
871 /* Get Multicast Encryption Type */
872 encryptType =
873 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
874 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
875 /* Get Unicast Encryption Type */
876 encryptType =
877 pRoamInfo->u.pConnectedProfile->EncryptionType;
878 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
879
880 pHddStaCtx->conn_info.authType =
881 pRoamInfo->u.pConnectedProfile->AuthType;
882
883 pHddStaCtx->conn_info.operationChannel =
884 pRoamInfo->u.pConnectedProfile->operationChannel;
885
886 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530887 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 &pRoamInfo->u.pConnectedProfile->SSID,
889 sizeof(tSirMacSSid));
890
891 /* Save dot11mode in which STA associated to AP */
892 pHddStaCtx->conn_info.dot11Mode =
893 pRoamInfo->u.pConnectedProfile->dot11Mode;
894
895 pHddStaCtx->conn_info.proxyARPService =
896 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530897
898 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
899
900 pHddStaCtx->conn_info.rate_flags =
901 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530903 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905}
906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907/**
908 * hdd_send_ft_assoc_response() - send fast transition assoc response
909 * @dev: pointer to net device
910 * @pAdapter: pointer to adapter
911 * @pCsrRoamInfo: pointer to roam info
912 *
913 * Send the 11R key information to the supplicant. Only then can the supplicant
914 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
915 * for the same purpose.)
916 *
917 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
918 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
919 * This is the Assoc Response.
920 *
921 * Return: none
922 */
923static void
924hdd_send_ft_assoc_response(struct net_device *dev,
925 hdd_adapter_t *pAdapter,
926 tCsrRoamInfo *pCsrRoamInfo)
927{
928 union iwreq_data wrqu;
929 char *buff;
930 unsigned int len = 0;
931 u8 *pFTAssocRsp = NULL;
932
933 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700934 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 return;
936 }
937
938 pFTAssocRsp =
939 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
940 pCsrRoamInfo->nAssocReqLength);
941 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700942 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 return;
944 }
945 /* pFTAssocRsp needs to point to the IEs */
946 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700947 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700948 (unsigned int)pFTAssocRsp[0],
949 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950
951 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700952 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700954 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 return;
956 }
957 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
958 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
959 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 memcpy(buff, pFTAssocRsp, len);
961 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
962
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700963 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966/**
967 * hdd_send_ft_event() - send fast transition event
968 * @pAdapter: pointer to adapter
969 *
970 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
971 * FT events to the supplicant. At the reception of Auth2 we send the RIC
972 * followed by the auth response IEs to the supplicant.
973 * Once both are received in the supplicant, an FT event is generated
974 * to the supplicant.
975 *
976 * Return: none
977 */
978static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
979{
980 uint16_t auth_resp_len = 0;
981 uint32_t ric_ies_length = 0;
982 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
983
984#if defined(KERNEL_SUPPORT_11R_CFG80211)
985 struct cfg80211_ft_event_params ftEvent;
986 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
987 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
988 struct net_device *dev = pAdapter->dev;
989#else
990 char *buff;
991 union iwreq_data wrqu;
992 uint16_t str_len;
993#endif
994
995#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530996 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
997 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998
999 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
1000 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001001 if (ric_ies_length == 0)
1002 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003
1004 ftEvent.ric_ies = ricIe;
1005 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001006 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
1008 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1009 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1010 &auth_resp_len);
1011
1012 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001013 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 return;
1015 }
1016
1017 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1018
1019 ftEvent.target_ap = ftIe;
1020
Anurag Chouhan6d760662016-02-20 16:05:43 +05301021 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1022 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001024 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1025 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1026 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 ftEvent.target_ap[0], ftEvent.target_ap[1],
1028 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1029 ftEvent.target_ap[5]);
1030
1031 (void)cfg80211_ft_event(dev, &ftEvent);
1032
1033#else
1034 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001035 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001037 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 return;
1039 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040
1041 /* Sme needs to send the RIC IEs first */
1042 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1043 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1044 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1045 &ric_ies_length);
1046 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001047 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 } else {
1049 wrqu.data.length = str_len + ric_ies_length;
1050 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1051 }
1052
1053 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301054 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1056 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1057 (u8 *) &buff[str_len],
1058 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1059
1060 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001061 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001062 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 return;
1064 }
1065
1066 wrqu.data.length = str_len + auth_resp_len;
1067 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1068
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001069 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070#endif
1071}
1072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073#ifdef FEATURE_WLAN_ESE
1074/**
1075 * hdd_send_new_ap_channel_info() - send new ap channel info
1076 * @dev: pointer to net device
1077 * @pAdapter: pointer to adapter
1078 * @pCsrRoamInfo: pointer to roam info
1079 *
1080 * Send the ESE required "new AP Channel info" to the supplicant.
1081 * (This keeps the supplicant "up to date" on the current channel.)
1082 *
1083 * The current (new AP) channel information is passed in.
1084 *
1085 * Return: none
1086 */
1087static void
1088hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1089 tCsrRoamInfo *pCsrRoamInfo)
1090{
1091 union iwreq_data wrqu;
1092 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1093
1094 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001095 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 return;
1097 }
1098 /*
1099 * Send the Channel event, the supplicant needs this to generate
1100 * the Adjacent AP report.
1101 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001102 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001103 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 memset(&wrqu, '\0', sizeof(wrqu));
1105 wrqu.freq.m = descriptor->channelId;
1106 wrqu.freq.e = 0;
1107 wrqu.freq.i = 0;
1108 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1109}
1110
1111#endif /* FEATURE_WLAN_ESE */
1112
1113/**
1114 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1115 * @pAdapter: pointer to adapter
1116 * @pCsrRoamInfo: pointer to roam info
1117 *
1118 * Return: none
1119 */
1120static void
1121hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1122 tCsrRoamInfo *pCsrRoamInfo)
1123{
1124 union iwreq_data wrqu;
1125 u8 *pBeaconIes;
1126 u8 currentLen = 0;
1127 char *buff;
1128 int totalIeLen = 0, currentOffset = 0, strLen;
1129
1130 memset(&wrqu, '\0', sizeof(wrqu));
1131
1132 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001133 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 return;
1135 }
1136 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1137 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001138 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 return;
1140 }
1141 /* pBeaconIes needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001142 hdd_debug("Beacon IEs is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001143 (unsigned int)pBeaconIes[0],
1144 (unsigned int)pBeaconIes[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001145 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001146 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147
1148 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001149 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001151 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 return;
1153 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154
1155 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1156 currentLen = strLen + 1;
1157
1158 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1159 do {
1160 /*
1161 * If the beacon size exceeds max CUSTOM event size, break it
1162 * into chunks of CUSTOM event max size and send it to
1163 * supplicant. Changes are done in supplicant to handle this.
1164 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301165 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301167 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301168 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169 currentLen);
1170 currentOffset += currentLen;
1171 totalIeLen -= currentLen;
1172 wrqu.data.length = strLen + 1 + currentLen;
1173 if (totalIeLen)
1174 buff[strLen] = 1; /* more chunks pending */
1175 else
1176 buff[strLen] = 0; /* last chunk */
1177
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001178 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001179 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1181 } while (totalIeLen > 0);
1182
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001183 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184}
1185
1186/**
1187 * hdd_send_association_event() - send association event
1188 * @dev: pointer to net device
1189 * @pCsrRoamInfo: pointer to roam info
1190 *
1191 * Return: none
1192 */
1193static void hdd_send_association_event(struct net_device *dev,
1194 tCsrRoamInfo *pCsrRoamInfo)
1195{
Rajeev Kumar78427682017-01-13 16:13:11 -08001196 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1198 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1199 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1200 union iwreq_data wrqu;
1201 int we_event;
1202 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301203 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205 /* Added to find the auth type on the fly at run time */
1206 /* rather than with cfg to see if FT is enabled */
1207 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1208 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209
1210 memset(&wrqu, '\0', sizeof(wrqu));
1211 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1212 we_event = SIOCGIWAP;
1213#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1214 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301215 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001217 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301218 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001219 hdd_notify_sta_disconnect(pAdapter->sessionId,
1220 true, pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301221 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301222 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223#endif
1224 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001225 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001228 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 return;
1230 }
1231
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001232 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001233 policy_mgr_incr_active_session(pHddCtx->hdd_psoc,
1234 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1236 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1237
1238#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001239 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 if (global_p2p_connection_status ==
1241 P2P_CLIENT_CONNECTING_STATE_1) {
1242 global_p2p_connection_status =
1243 P2P_CLIENT_CONNECTED_STATE_1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001244 hdd_debug("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 } else if (global_p2p_connection_status ==
1246 P2P_CLIENT_CONNECTING_STATE_2) {
1247 global_p2p_connection_status =
1248 P2P_CLIENT_COMPLETED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001249 hdd_debug("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 }
1251 }
1252#endif
1253 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1254 MAC_ADDRESS_STR "\n",
1255 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1256 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1257 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1258
1259 /*
1260 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1261 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001262 * fFTEnable is true.
1263 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 if ((pRoamProfile->AuthType.authType[0] ==
1266 eCSR_AUTH_TYPE_FT_RSN_PSK)
1267 || (pRoamProfile->AuthType.authType[0] ==
1268 eCSR_AUTH_TYPE_FT_RSN)
1269#ifdef FEATURE_WLAN_ESE
1270 || (pRoamProfile->AuthType.authType[0] ==
1271 eCSR_AUTH_TYPE_CCKM_RSN)
1272 || (pRoamProfile->AuthType.authType[0] ==
1273 eCSR_AUTH_TYPE_CCKM_WPA)
1274#endif
1275 ) {
1276 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1277 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301278 qdf_copy_macaddr(&peerMacAddr,
1279 &pHddStaCtx->conn_info.bssId);
1280 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1281 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1282 chan_info.info = pCsrRoamInfo->chan_info.info;
1283 chan_info.band_center_freq1 =
1284 pCsrRoamInfo->chan_info.band_center_freq1;
1285 chan_info.band_center_freq2 =
1286 pCsrRoamInfo->chan_info.band_center_freq2;
1287 chan_info.reg_info_1 =
1288 pCsrRoamInfo->chan_info.reg_info_1;
1289 chan_info.reg_info_2 =
1290 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301291
Dustin Brown7d043f62017-03-27 12:07:36 -07001292 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1293 pAdapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301294 peerMacAddr.bytes,
1295 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001296 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301297 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1298 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001299 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1300 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301301 if (ret)
1302 hdd_err("Peer object %pM fail to set associated state",
1303 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301304
Abhishek Singh1c676222016-05-09 14:20:28 +05301305 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001306 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1307 ePeerConnected,
1308 pCsrRoamInfo->timingMeasCap,
1309 pAdapter->sessionId, &chan_info,
1310 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001311 /* Update tdls module about connection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001312 hdd_notify_sta_connect(pAdapter->sessionId,
1313 pCsrRoamInfo->tdls_chan_swit_prohibited,
1314 pCsrRoamInfo->tdls_prohibited,
1315 pAdapter->hdd_vdev);
1316
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001317 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001318
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001321#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 /* start timer in sta/p2p_cli */
1323 spin_lock_bh(&pHddCtx->bus_bw_lock);
1324 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1325 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001326 cdp_get_intra_bss_fwd_pkts_count(
1327 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301328 &pAdapter->prev_fwd_tx_packets,
1329 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001331 hdd_bus_bw_compute_timer_start(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332#endif
1333#endif
1334 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1335 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001336 policy_mgr_update_connection_info(pHddCtx->hdd_psoc,
1337 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001339 ETH_ALEN);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001340 hdd_info("wlan: new IBSS connection to " MAC_ADDRESS_STR,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001341 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301342
Dustin Brown7d043f62017-03-27 12:07:36 -07001343 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1344 QDF_IBSS_MODE,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301345 pCsrRoamInfo->bssid.bytes,
1346 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001347 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301348 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1349 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001350 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1351 WLAN_ASSOC_STATE);
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301352 if (ret)
1353 hdd_err("Peer object %pM fail to set associated state",
1354 peerMacAddr.bytes);
1355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 } else { /* Not Associated */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001357 hdd_info("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001359 policy_mgr_decr_session_set_pcl(pHddCtx->hdd_psoc,
1360 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361
1362#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1363 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1364#endif
1365
Abhishek Singh1c676222016-05-09 14:20:28 +05301366 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1367 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301368 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 &pHddStaCtx->conn_info.bssId);
1370
1371 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001372 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301373 ePeerDisconnected, 0,
1374 pAdapter->sessionId,
1375 NULL,
1376 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301378
Dustin Brown7d043f62017-03-27 12:07:36 -07001379 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
1380 peerMacAddr.bytes);
Rajeev Kumardfa37072017-01-13 16:27:22 -08001381 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301382 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1383 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1384
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001385 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001386 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001387 hdd_notify_sta_disconnect(pAdapter->sessionId,
1388 false,
1389 pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301390 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392#ifdef MSM_PLATFORM
1393 /* stop timer in sta/p2p_cli */
1394 spin_lock_bh(&pHddCtx->bus_bw_lock);
1395 pAdapter->prev_tx_packets = 0;
1396 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301397 pAdapter->prev_fwd_tx_packets = 0;
1398 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001400 hdd_bus_bw_compute_timer_try_stop(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401#endif
1402 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001403 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 /* Send SCC/MCC Switching event to IPA */
1405 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1406
1407 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001408 /* During the WLAN uninitialization,supplicant is stopped before the
1409 * driver so not sending the status of the connection to supplicant
1410 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001411 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 wireless_send_event(dev, we_event, &wrqu, msg);
1413#ifdef FEATURE_WLAN_ESE
1414 if (eConnectionState_Associated ==
1415 pHddStaCtx->conn_info.connState) {
1416 if ((pRoamProfile->AuthType.authType[0] ==
1417 eCSR_AUTH_TYPE_CCKM_RSN) ||
1418 (pRoamProfile->AuthType.authType[0] ==
1419 eCSR_AUTH_TYPE_CCKM_WPA))
1420 hdd_send_new_ap_channel_info(dev, pAdapter,
1421 pCsrRoamInfo);
1422 }
1423#endif
1424 }
1425}
1426
1427/**
1428 * hdd_conn_remove_connect_info() - remove connection info
1429 * @pHddStaCtx: pointer to global HDD station context
1430 * @pCsrRoamInfo: pointer to roam info
1431 *
1432 * Return: none
1433 */
1434static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1435{
1436 /* Remove staId, bssId and peerMacAddress */
1437 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301438 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1439 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301440 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441
1442 /* Clear all security settings */
1443 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1444 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1445 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1446
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301447 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1448 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450 pHddStaCtx->conn_info.proxyARPService = 0;
1451
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301452 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453}
1454
1455/**
1456 * hdd_roam_deregister_sta() - deregister station
1457 * @pAdapter: pointer to adapter
1458 * @staId: station identifier
1459 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301460 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 */
Abhishek Singh07c627e2017-03-20 17:56:34 +05301462QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301464 QDF_STATUS qdf_status;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301465 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1466 int ret = 0;
1467 uint8_t *peer_mac = NULL;
1468 struct qdf_mac_addr broadcastMacAddr =
1469 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 if (eConnectionState_IbssDisconnected ==
1471 pHddStaCtx->conn_info.connState) {
1472 /*
1473 * Do not set the carrier off when the last peer leaves.
1474 * We will set the carrier off while stopping the IBSS.
1475 */
1476 }
1477
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001478 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001479 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301480 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301481 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301482 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1483 staid, qdf_status, qdf_status);
1484 }
1485
1486 if (adapter->device_mode == QDF_STA_MODE) {
1487 peer_mac = pHddStaCtx->conn_info.bssId.bytes;
1488 } else if (adapter->device_mode == QDF_IBSS_MODE) {
1489 if (pHddStaCtx->broadcast_staid == staid)
1490 peer_mac = broadcastMacAddr.bytes;
1491 else
1492 peer_mac = pHddStaCtx->conn_info.
1493 peerMacAddress[staid].bytes;
1494 }
1495
Dustin Brown7d043f62017-03-27 12:07:36 -07001496 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301497 if (ret) {
1498 hdd_err("Peer obj %pM delete fails", peer_mac);
1499 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301501 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502}
1503
1504/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301505 * hdd_print_bss_info() - print bss info
1506 * @hdd_sta_ctx: pointer to hdd station context
1507 *
1508 * Return: None
1509 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001510static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301511{
1512 uint32_t *cap_info;
1513
1514 hdd_info("WIFI DATA LOGGER");
1515 hdd_info("channel: %d",
1516 hdd_sta_ctx->conn_info.freq);
1517 hdd_info("dot11mode: %d",
1518 hdd_sta_ctx->conn_info.dot11Mode);
1519 hdd_info("AKM: %d",
1520 hdd_sta_ctx->conn_info.authType);
1521 hdd_info("ssid: %.*s",
1522 hdd_sta_ctx->conn_info.SSID.SSID.length,
1523 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1524 hdd_info("roam count: %d",
1525 hdd_sta_ctx->conn_info.roam_count);
1526 hdd_info("ant_info: %d",
1527 hdd_sta_ctx->conn_info.txrate.nss);
1528 hdd_info("datarate legacy %d",
1529 hdd_sta_ctx->conn_info.txrate.legacy);
1530 hdd_info("datarate mcs: %d",
1531 hdd_sta_ctx->conn_info.txrate.mcs);
1532 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1533 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1534 hdd_info("ht caps: %x", *cap_info);
1535 }
1536 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1537 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1538 hdd_info("vht caps: %x", *cap_info);
1539 }
1540 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1541 hdd_info("hs20 info: %x",
1542 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1543 hdd_info("signal: %d",
1544 hdd_sta_ctx->conn_info.signal);
1545 hdd_info("noise: %d",
1546 hdd_sta_ctx->conn_info.noise);
1547}
1548
1549/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 * hdd_dis_connect_handler() - disconnect event handler
1551 * @pAdapter: pointer to adapter
1552 * @pRoamInfo: pointer to roam info
1553 * @roamId: roam identifier
1554 * @roamStatus: roam status
1555 * @roamResult: roam result
1556 *
1557 * This function handles disconnect event:
1558 * 1. Disable transmit queues;
1559 * 2. Clean up internal connection states and data structures;
1560 * 3. Send disconnect indication to supplicant.
1561 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301562 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301564static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 tCsrRoamInfo *pRoamInfo,
1566 uint32_t roamId,
1567 eRoamCmdStatus roamStatus,
1568 eCsrRoamResult roamResult)
1569{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301570 QDF_STATUS status = QDF_STATUS_SUCCESS;
1571 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 struct net_device *dev = pAdapter->dev;
1573 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1574 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1575 uint8_t sta_id;
1576 bool sendDisconInd = true;
1577
1578 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001579 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301580 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 }
1582 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001583 hdd_notice("Disabling queues");
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301584 wlan_hdd_netif_queue_control(pAdapter,
1585 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1586 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587
1588 if (hdd_ipa_is_enabled(pHddCtx))
1589 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001590 HDD_IPA_STA_DISCONNECT,
1591 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592
1593#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1594 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1595#endif
1596
Nirav Shah1da77682016-05-03 20:16:39 +05301597 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1598 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001599 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301600 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601
1602 /* HDD has initiated disconnect, do not send disconnect indication
1603 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301604 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 * to cfg80211_disconnected.
1606 */
1607 if ((eConnectionState_Disconnecting ==
1608 pHddStaCtx->conn_info.connState) ||
1609 (eConnectionState_NotConnected ==
1610 pHddStaCtx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001611 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 sendDisconInd = false;
1613 }
1614
1615 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1616 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 hdd_conn_set_connection_state(pAdapter,
1618 eConnectionState_Disconnecting);
1619 }
1620
1621 hdd_clear_roam_profile_ie(pAdapter);
1622 hdd_wmm_init(pAdapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001623 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301624 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625
1626 /* indicate 'disconnect' status to wpa_supplicant... */
1627 hdd_send_association_event(dev, pRoamInfo);
1628 /* indicate disconnected event to nl80211 */
1629 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1630 /*
1631 * Only send indication to kernel if not initiated
1632 * by kernel
1633 */
1634 if (sendDisconInd) {
1635 /*
1636 * To avoid wpa_supplicant sending "HANGED" CMD
1637 * to ICS UI.
1638 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001639 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1640 if (pRoamInfo->reasonCode ==
1641 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1642 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301643 wlan_hdd_cfg80211_indicate_disconnect(
1644 dev, false,
1645 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001646 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301647 wlan_hdd_cfg80211_indicate_disconnect(
1648 dev, false,
1649 WLAN_REASON_UNSPECIFIED
1650 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001651 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301653 hdd_info("sent disconnected event to nl80211, reason code %d",
1654 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1655 pRoamInfo->reasonCode :
1656 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 }
1658 /*
1659 * During the WLAN uninitialization,supplicant is stopped
1660 * before the driver so not sending the status of the
1661 * connection to supplicant.
1662 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001663 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001665 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 if (global_p2p_connection_status ==
1667 P2P_CLIENT_CONNECTED_STATE_1) {
1668 global_p2p_connection_status =
1669 P2P_CLIENT_DISCONNECTED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001670 hdd_debug("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 } else if (global_p2p_connection_status ==
1672 P2P_CLIENT_COMPLETED_STATE) {
1673 global_p2p_connection_status =
1674 P2P_NOT_ACTIVE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001675 hdd_debug("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 }
1677 }
1678#endif
1679
1680 }
1681 }
1682
1683 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001685 if (hdd_remove_beacon_filter(pAdapter) != 0)
1686 hdd_err("hdd_remove_beacon_filter() failed");
1687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301689 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001690
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001691 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301693 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001694 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301695 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301696 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 }
1698 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301699 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001700 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001701 if (HDD_WLAN_INVALID_STA_ID ==
1702 pHddStaCtx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301703 continue;
1704 sta_id = pHddStaCtx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001705 hdd_debug("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301706 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301707 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001708 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301709 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301710 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301711 }
1712 /* set the staid and peer mac as 0, all other
1713 * reset are done in hdd_connRemoveConnectInfo.
1714 */
1715 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301716 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301717 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301718 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1719 pHddCtx->sta_to_adapter[sta_id] = NULL;
1720 }
1721 } else {
1722 sta_id = pHddStaCtx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001723 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301724
1725 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001726 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1727 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301728 eCSR_ROAM_LOSTLINK == roamStatus) {
Abhishek Singhc9941602016-08-09 16:06:22 +05301729 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1730 pHddStaCtx->conn_info.bssId.bytes);
1731 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1732 pHddStaCtx->conn_info.bssId.bytes);
1733 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301734 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 /* Clear saved connection information in HDD */
1737 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301739 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740
1741#ifdef FEATURE_WLAN_TDLS
1742 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1743 wlan_hdd_tdls_disconnection_callback(pAdapter);
1744#endif
1745
Krunal Sonibe766b02016-03-10 13:00:44 -08001746 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1747 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1749 (pAdapter),
1750 pAdapter->sessionId);
1751 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301752 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 /* Unblock anyone waiting for disconnect to complete */
1754 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301755 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 return status;
1757}
1758
1759/**
1760 * hdd_set_peer_authorized_event() - set peer_authorized_event
1761 * @vdev_id: vdevid
1762 *
1763 * Return: None
1764 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001765static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301767 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 hdd_adapter_t *adapter = NULL;
1769
1770 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1771 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001772 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001773 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 }
1775 complete(&adapter->sta_authorized_event);
1776}
1777
1778/**
1779 * hdd_change_peer_state() - change peer state
1780 * @pAdapter: HDD adapter
1781 * @sta_state: peer state
1782 * @roam_synch_in_progress: roam synch in progress
1783 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301784 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301786QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 uint8_t sta_id,
1788 enum ol_txrx_peer_state sta_state,
1789 bool roam_synch_in_progress)
1790{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301791 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001792 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001793 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1794 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1795 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796
1797 if (!pdev) {
1798 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301799 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 }
1801
1802 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001803 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 }
1806
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001807 peer = cdp_peer_find_by_local_id(soc,
1808 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301810 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811
Leo Changfdb45c32016-10-28 11:09:23 -07001812 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001813 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001814 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001815 return QDF_STATUS_E_FAULT;
1816 }
1817
Leo Changfdb45c32016-10-28 11:09:23 -07001818 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301819 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001820 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301821 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 }
1823#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1824 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301825 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826#endif
1827
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001828 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1830 /* make sure event is reset */
1831 INIT_COMPLETION(pAdapter->sta_authorized_event);
1832#endif
1833
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001834 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 hdd_set_peer_authorized_event,
1836 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301837 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001838 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301839 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 }
1841
Krunal Sonibe766b02016-03-10 13:00:44 -08001842 if (pAdapter->device_mode == QDF_STA_MODE ||
1843 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001845 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 unsigned long rc;
1847
1848 /* wait for event from firmware to set the event */
1849 rc = wait_for_completion_timeout(
1850 &pAdapter->sta_authorized_event,
1851 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001852 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001853 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001854
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001855 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1856 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001857 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858#endif
1859 }
1860 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301861 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862}
1863
1864/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001865 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1866 * @cbk_data: callback data
1867 * @sta_id: station id
1868 * @vdev_param: vdev parameter
1869 * @is_link_up: link state up or down
1870 *
1871 * Return: QDF status
1872 */
1873QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1874 uint8_t sta_id,
1875 uint32_t vdev_param,
1876 bool is_link_up)
1877{
1878 struct cdp_vdev *data_vdev;
1879 QDF_STATUS status = QDF_STATUS_SUCCESS;
1880 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1881 hdd_context_t *hdd_ctx;
1882 struct wlan_objmgr_psoc **psoc;
1883
1884 if (!cbk_data)
1885 return status;
1886
1887 psoc = cbk_data;
1888 hdd_ctx = container_of(psoc, hdd_context_t, hdd_psoc);
1889
1890 if (!hdd_ctx->tdls_nap_active)
1891 return status;
1892
1893 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, sta_id);
1894 if (NULL == data_vdev) {
1895 status = QDF_STATUS_E_FAILURE;
1896 return status;
1897 }
1898
1899 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1900
1901 return status;
1902}
1903
1904/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 * hdd_roam_register_sta() - register station
1906 * @pAdapter: pointer to adapter
1907 * @pRoamInfo: pointer to roam info
1908 * @staId: station identifier
1909 * @pPeerMacAddress: peer MAC address
1910 * @pBssDesc: pointer to BSS description
1911 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301912 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001914QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 tCsrRoamInfo *pRoamInfo,
1916 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301917 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 tSirBssDescription *pBssDesc)
1919{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301920 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 struct ol_txrx_desc_type staDesc = { 0 };
1922 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001923 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001924 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1925 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926
1927 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301928 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929
1930 /* Get the Station ID from the one saved during the association */
1931 staDesc.sta_id = staId;
1932
1933 /* set the QoS field appropriately */
1934 if (hdd_wmm_is_active(pAdapter))
1935 staDesc.is_qos_enabled = 1;
1936 else
1937 staDesc.is_qos_enabled = 0;
1938
1939#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07001940 hdd_debug("WAPI STA Registered: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001941 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 if (pAdapter->wapi_info.fIsWapiSta)
1943 staDesc.is_wapi_supported = 1;
1944 else
1945 staDesc.is_wapi_supported = 0;
1946#endif /* FEATURE_WLAN_WAPI */
1947
Dhanashri Atre50141c52016-04-07 13:15:29 -07001948 /* Register the vdev transmit and receive functions */
1949 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1950 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001951
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001952 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1953 (struct cdp_pdev *)pdev,
1954 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001955 if (!pAdapter->txrx_vdev) {
1956 hdd_err("%s find vdev fail", __func__);
1957 return QDF_STATUS_E_FAILURE;
1958 }
1959
1960 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001961 cdp_vdev_register(soc,
1962 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001963 if (!txrx_ops.tx.tx) {
1964 hdd_err("%s vdev register fail", __func__);
1965 return QDF_STATUS_E_FAILURE;
1966 }
1967
Dhanashri Atre50141c52016-04-07 13:15:29 -07001968 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001969 qdf_status = cdp_peer_register(soc,
1970 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301971 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001972 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001973 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301974 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 }
1976
1977 if (!pRoamInfo->fAuthRequired) {
1978 /*
1979 * Connections that do not need Upper layer auth, transition
1980 * TLSHIM directly to 'Authenticated' state
1981 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301982 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001984 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1986 pRoamInfo->roamSynchInProgress
1987#else
1988 false
1989#endif
1990 );
1991
1992 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001993 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001995 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301997 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001999 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2001 pRoamInfo->roamSynchInProgress
2002#else
2003 false
2004#endif
2005 );
2006 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002007 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302009 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010}
2011
2012/**
2013 * hdd_send_re_assoc_event() - send reassoc event
2014 * @dev: pointer to net device
2015 * @pAdapter: pointer to adapter
2016 * @pCsrRoamInfo: pointer to roam info
2017 * @reqRsnIe: pointer to RSN Information element
2018 * @reqRsnLength: length of RSN IE
2019 *
2020 * Return: none
2021 */
2022static void hdd_send_re_assoc_event(struct net_device *dev,
2023 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
2024 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2025{
2026 unsigned int len = 0;
2027 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002028 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2029 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 uint32_t rspRsnLength = 0;
2031 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2033 uint8_t *buf_ptr, ssid_ie_len;
2034 struct cfg80211_bss *bss = NULL;
2035 uint8_t *final_req_ie = NULL;
2036 tCsrRoamConnectedProfile roam_profile;
2037 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002038 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002040 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2041
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002043 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002044 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 }
2046
Naveen Rawat14298b92015-11-25 16:27:41 -08002047 if (!assoc_req_ies) {
2048 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002049 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002050 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002052 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 goto done;
2054 }
2055
2056 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002057 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 goto done;
2059 }
2060
2061 pFTAssocRsp =
2062 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2063 pCsrRoamInfo->nAssocReqLength);
2064 if (pFTAssocRsp == NULL)
2065 goto done;
2066
2067 /* pFTAssocRsp needs to point to the IEs */
2068 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002069 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002070 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071
2072 /*
2073 * Active session count is decremented upon disconnection, but during
2074 * roaming, there is no disconnect indication and hence active session
2075 * count is not decremented.
2076 * After roaming is completed, active session count is incremented
2077 * as a part of connect indication but effectively after roaming the
2078 * active session count should still be the same and hence upon
2079 * successful reassoc decrement the active session count here.
2080 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002081 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002082 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
2083 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084
2085 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2086 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2087 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302088 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2089 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090
2091 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302092 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2094 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302095
2096 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2097 chan, pCsrRoamInfo->bssid.bytes,
2098 &roam_profile.SSID.ssId[0],
2099 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100
2101 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002102 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 buf_ptr = buf_ssid_ie;
2104 *buf_ptr = SIR_MAC_SSID_EID;
2105 buf_ptr++;
2106 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2107 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302108 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 roam_profile.SSID.length);
2110 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002111 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302112 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002113 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002114 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Kapil Gupta8731e812017-07-11 18:42:39 +05302115 if (final_req_ie == NULL) {
2116 if (bss)
2117 cfg80211_put_bss(pAdapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302119 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302121 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302123 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2124 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2125 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002127 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302128 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002129 final_req_ie, (ssid_ie_len + reqRsnLength));
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08002130 cfg80211_roamed_bss(dev, bss,
2131 final_req_ie, (ssid_ie_len + reqRsnLength),
2132 rspRsnIe, rspRsnLength, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302134 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002135 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2136 pCsrRoamInfo->nAssocReqLength);
2137
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002138 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302139 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002140 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2141
Prakash Dhavali989127d2016-11-29 14:56:44 +05302142 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002143 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2144 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002145 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002147 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002149 qdf_mem_free(final_req_ie);
2150 qdf_mem_free(rspRsnIe);
2151 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152}
2153
2154/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302155 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002156 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302157 *
2158 * Return: roam sync status if roaming offloaded else false
2159 */
2160#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002161bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302162{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002163 if (roaminfo)
2164 return roaminfo->roamSynchInProgress;
2165 else
2166 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302167}
2168#endif
2169
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002170/**
2171 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2172 * @hddstactx: pointer to HDD sta context
2173 * @roaminfo: pointer to roaminfo structure
2174 *
2175 * This function returns staid for IBSS peer. If peer is broadcast
2176 * MAC address return self staid(0) else find the peer sta id of
2177 * the peer.
2178 *
2179 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2180 */
2181static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2182 tCsrRoamInfo *roaminfo)
2183{
2184 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2185 QDF_STATUS status;
2186
2187 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2188 staid = 0;
2189 } else {
2190 status = hdd_get_peer_sta_id(hddstactx,
2191 &roaminfo->peerMac, &staid);
2192 if (status != QDF_STATUS_SUCCESS) {
2193 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2194 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2195 }
2196 }
2197
2198 return staid;
2199}
Govind Singhedc5cda2015-10-23 17:11:35 +05302200
2201/**
2202 * hdd_change_sta_state_authenticated()-
2203 * This function changes STA state to authenticated
2204 * @adapter: pointer to the adapter structure.
2205 * @roaminfo: pointer to the RoamInfo structure.
2206 *
2207 * This is called from hdd_RoamSetKeyCompleteHandler
2208 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2209 *
2210 * Return: 0 on success and errno on failure
2211 */
2212static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2213 tCsrRoamInfo *roaminfo)
2214{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002215 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002216 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002217 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302218 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002219 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302220
Dustin Brownf660fb42016-09-09 12:04:00 -07002221 timeout = hddstactx->hdd_ReassocScenario ?
2222 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002223 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002224
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002225 if (QDF_IBSS_MODE == adapter->device_mode)
2226 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2227 else
2228 staid = hddstactx->conn_info.staId[0];
2229
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002230 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302231
2232 /* Connections that do not need Upper layer authentication,
2233 * transition TL to 'Authenticated' state after the keys are set
2234 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002235 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302236 hdd_is_roam_sync_in_progress(roaminfo));
2237 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002238 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2239
Krunal Sonibe766b02016-03-10 13:00:44 -08002240 if ((QDF_STA_MODE == adapter->device_mode) ||
2241 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302242 sme_ps_enable_auto_ps_timer(
2243 WLAN_HDD_GET_HAL_CTX(adapter),
2244 adapter->sessionId,
Dustin Brown84411b02017-07-21 16:44:44 -07002245 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302246 }
2247
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002248 return qdf_status_to_os_return(status);
2249}
2250
2251/**
2252 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2253 * if key installation is required
2254 * @encr_type: encryption type
2255 *
2256 * Return: true if key installation is required and false otherwise.
2257 */
2258static inline bool hdd_is_key_install_required_for_ibss(
2259 eCsrEncryptionType encr_type)
2260{
2261 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2262 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2263 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
2264 eCSR_ENCRYPT_TYPE_AES == encr_type)
2265 return true;
2266 else
2267 return false;
2268}
2269
2270/**
2271 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2272 * complete
2273 * @adapter: pointer to HDD adapter
2274 * @roaminfo: pointer to roam info
2275 * @roam_result: roam result
2276 *
2277 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2278 * This function checks for the successful set key completion and update
2279 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2280 *
2281 * Return: None
2282 */
2283static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2284 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2285{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002286 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2287 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2288
2289 /*
2290 * If the security mode is one of the following, IBSS peer will be
2291 * waiting in CONN state and we will move the peer state to AUTH
2292 * here. For non-secure connection, no need to wait for set-key complete
2293 * peer will be moved to AUTH in hdd_roam_register_sta.
2294 */
2295 if (QDF_IBSS_MODE == adapter->device_mode) {
2296 if (hdd_is_key_install_required_for_ibss(encr_type))
2297 hdd_change_sta_state_authenticated(adapter, roaminfo);
2298
2299 return;
2300 }
2301
2302 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2303 hdd_sta_ctx->conn_info.gtk_installed = true;
2304 /*
2305 * PTK exchange happens in preauthentication itself if key_mgmt
2306 * is FT-PSK, ptk_installed was false as there is no set PTK
2307 * after roaming. STA TL state moves to authenticated only if
2308 * ptk_installed is true. So, make ptk_installed to true in
2309 * case of 11R roaming.
2310 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302311 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
2312 adapter->sessionId))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002313 hdd_sta_ctx->conn_info.ptk_installed = true;
2314 } else {
2315 hdd_sta_ctx->conn_info.ptk_installed = true;
2316 }
2317
2318 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2319 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2320 * unicast key and it was resulting in sending few un-encrypted packet.
2321 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2322 * set the unicast and broadcast key.
2323 */
2324 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2325 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2326 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2327 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2328 if (hdd_sta_ctx->conn_info.gtk_installed &&
2329 hdd_sta_ctx->conn_info.ptk_installed)
2330 hdd_change_sta_state_authenticated(adapter, roaminfo);
2331 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2332 hdd_change_sta_state_authenticated(adapter, roaminfo);
2333 }
2334
2335 if (hdd_sta_ctx->conn_info.gtk_installed &&
2336 hdd_sta_ctx->conn_info.ptk_installed) {
2337 hdd_sta_ctx->conn_info.gtk_installed = false;
2338 hdd_sta_ctx->conn_info.ptk_installed = false;
2339 }
2340
2341 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2342
2343 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302344}
2345
2346/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 * hdd_roam_set_key_complete_handler() - Update the security parameters
2348 * @pAdapter: pointer to adapter
2349 * @pRoamInfo: pointer to roam info
2350 * @roamId: roam id
2351 * @roamStatus: roam status
2352 * @roamResult: roam result
2353 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302354 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302356static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 tCsrRoamInfo *pRoamInfo,
2358 uint32_t roamId,
2359 eRoamCmdStatus roamStatus,
2360 eCsrRoamResult roamResult)
2361{
2362 eCsrEncryptionType connectedCipherAlgo;
2363 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302365
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 ENTER();
2367
2368 if (NULL == pRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002369 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302370 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 }
2372 /*
2373 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2374 * then go to 'authenticated'. For all other authentication types
2375 * (those that do not require upper layer authentication) we can put TL
2376 * directly into 'authenticated' state.
2377 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002378 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379 MAC_ADDRESS_STR, roamStatus, roamResult,
2380 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2381
2382 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2383 &connectedCipherAlgo);
2384 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002385 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2386 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 } else {
2388 /*
2389 * possible disassoc after issuing set key and waiting
2390 * set key complete.
2391 */
2392 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2393 }
2394
2395 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302396 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397}
2398
2399/**
2400 * hdd_perform_roam_set_key_complete() - perform set key complete
2401 * @pAdapter: pointer to adapter
2402 *
2403 * Return: none
2404 */
2405void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2406{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302407 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2409 tCsrRoamInfo roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002410
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302412 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302413 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302414 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302415 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302417 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 hdd_roam_set_key_complete_handler(pAdapter,
2419 &roamInfo,
2420 pHddStaCtx->roam_info.roamId,
2421 pHddStaCtx->roam_info.roamStatus,
2422 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302423 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002424 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425
2426 pHddStaCtx->roam_info.deferKeyComplete = false;
2427}
2428
2429/**
2430 * hdd_association_completion_handler() - association completion handler
2431 * @pAdapter: pointer to adapter
2432 * @pRoamInfo: pointer to roam info
2433 * @roamId: roam id
2434 * @roamStatus: roam status
2435 * @roamResult: roam result
2436 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302437 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302439static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 tCsrRoamInfo *pRoamInfo,
2441 uint32_t roamId,
2442 eRoamCmdStatus roamStatus,
2443 eCsrRoamResult roamResult)
2444{
2445 struct net_device *dev = pAdapter->dev;
2446 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2447 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302448 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002450 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 bool hddDisconInProgress = false;
2453 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302454 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302455 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456
2457 if (!pHddCtx) {
2458 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302459 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 }
2461
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302462 /* validate config */
2463 if (!pHddCtx->config) {
2464 hdd_err("config is NULL");
2465 return QDF_STATUS_E_NULL_VALUE;
2466 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 /* HDD has initiated disconnect, do not send connect result indication
2468 * to kernel as it will be handled by __cfg80211_disconnect.
2469 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302470 if (((eConnectionState_Disconnecting ==
2471 pHddStaCtx->conn_info.connState) ||
2472 (eConnectionState_NotConnected ==
2473 pHddStaCtx->conn_info.connState)) &&
2474 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2475 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002476 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
2477 pHddStaCtx->conn_info.connState,
2478 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 hddDisconInProgress = true;
2480 }
2481
2482 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2483 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002484 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302485 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 }
2487 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 hdd_conn_set_connection_state(pAdapter,
2489 eConnectionState_Associated);
2490 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302491
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 /* Save the connection info from CSR... */
2493 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2494 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002495
2496 if (hdd_add_beacon_filter(pAdapter) != 0)
2497 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498#ifdef FEATURE_WLAN_WAPI
2499 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2500 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2501 || pRoamInfo->u.pConnectedProfile->AuthType ==
2502 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2503 pAdapter->wapi_info.fIsWapiSta = 1;
2504 } else {
2505 pAdapter->wapi_info.fIsWapiSta = 0;
2506 }
2507#endif /* FEATURE_WLAN_WAPI */
Krunal Soni364e0872017-05-10 21:24:34 -07002508 hdd_debug("bss_descr[%d] devicemode[%d]", !!pRoamInfo->pBssDesc,
2509 pAdapter->device_mode);
2510 if ((QDF_STA_MODE == pAdapter->device_mode) &&
2511 pRoamInfo->pBssDesc) {
2512 ie_len = GET_IE_LEN_IN_BSS(pRoamInfo->pBssDesc->length);
2513 pHddStaCtx->ap_supports_immediate_power_save =
2514 wlan_hdd_is_ap_supports_immediate_power_save(
2515 (uint8_t *) pRoamInfo->pBssDesc->ieFields,
2516 ie_len);
2517 hdd_debug("ap_supports_immediate_power_save flag [%d]",
2518 pHddStaCtx->ap_supports_immediate_power_save);
2519 }
2520
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 /* Indicate 'connect' status to user space */
2522 hdd_send_association_event(dev, pRoamInfo);
2523
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002524 if (policy_mgr_is_mcc_in_24G(pHddCtx->hdd_psoc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 if (pHddCtx->miracast_value)
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002526 wlan_hdd_set_mas(pAdapter,
2527 pHddCtx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 }
2529
2530 /* Initialize the Linkup event completion variable */
2531 INIT_COMPLETION(pAdapter->linkup_event_var);
2532
2533 /*
2534 * Sometimes Switching ON the Carrier is taking time to activate
2535 * the device properly. Before allowing any packet to go up to
2536 * the application, device activation has to be ensured for
2537 * proper queue mapping by the kernel. we have registered net
2538 * device notifier for device change notification. With this we
2539 * will come to know that the device is getting
2540 * activated properly.
2541 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002543 /*
2544 * Enable Linkup Event Servicing which allows the net
2545 * device notifier to set the linkup event variable.
2546 */
2547 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002549 /* Switch on the Carrier to activate the device */
2550 wlan_hdd_netif_queue_control(pAdapter,
2551 WLAN_NETIF_CARRIER_ON,
2552 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002554 /*
2555 * Wait for the Link to up to ensure all the queues
2556 * are set properly by the kernel.
2557 */
2558 rc = wait_for_completion_timeout(
2559 &pAdapter->linkup_event_var,
2560 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2561 );
2562 if (!rc)
2563 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002565 /*
2566 * Disable Linkup Event Servicing - no more service
2567 * required from the net device notifier call.
2568 */
2569 pAdapter->isLinkUpSvcNeeded = false;
2570 } else {
2571 pHddStaCtx->ft_carrier_on = false;
2572 ft_carrier_on = true;
2573 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2575 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2576 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002577 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578
2579 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2580
2581 if (hdd_ipa_is_enabled(pHddCtx))
2582 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002583 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 pRoamInfo->bssid.bytes);
2585
2586#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2587 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2588#endif
2589
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302590 hdd_debug("check if STA chan ok for DNBS");
2591 if (policy_mgr_is_chan_ok_for_dnbs(pHddCtx->hdd_psoc,
2592 pHddStaCtx->conn_info.operationChannel,
2593 &ok)) {
2594 hdd_err("Unable to check DNBS eligibility for chan:%d",
2595 pHddStaCtx->conn_info.operationChannel);
2596 return QDF_STATUS_E_FAILURE;
2597 }
2598
2599 if (!ok) {
2600 hdd_err("Chan:%d not suitable for DNBS",
2601 pHddStaCtx->conn_info.operationChannel);
2602 wlan_hdd_netif_queue_control(pAdapter,
2603 WLAN_NETIF_CARRIER_OFF,
2604 WLAN_CONTROL_PATH);
2605 if (!hddDisconInProgress) {
2606 hdd_err("Disconnecting...");
2607 sme_roam_disconnect(
2608 WLAN_HDD_GET_HAL_CTX(pAdapter),
2609 pAdapter->sessionId,
2610 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2611 }
2612 return QDF_STATUS_E_FAILURE;
2613 }
2614
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002615 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002616 policy_mgr_check_concurrent_intf_and_restart_sap(
2617 pHddCtx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618
Nirav Shah1da77682016-05-03 20:16:39 +05302619 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2620 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002621 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302622 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2623
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 /*
2625 * For reassoc, the station is already registered, all we need
2626 * is to change the state of the STA in TL.
2627 * If authentication is required (WPA/WPA2/DWEP), change TL to
2628 * CONNECTED instead of AUTHENTICATED.
2629 */
2630 if (!pRoamInfo->fReassocReq) {
2631 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 u8 *pFTAssocRsp = NULL;
2633 unsigned int assocRsplen = 0;
2634 u8 *pFTAssocReq = NULL;
2635 unsigned int assocReqlen = 0;
2636 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2638 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2639
2640 /* add bss_id to cfg80211 data base */
2641 bss =
2642 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2643 pRoamInfo);
2644 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302645 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646 wlan_hdd_netif_queue_control(pAdapter,
2647 WLAN_NETIF_CARRIER_OFF,
2648 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302649 if (!hddDisconInProgress) {
2650 /*
2651 * Here driver was not able to add bss
2652 * in cfg80211 database this can happen
2653 * if connected channel is not valid,
2654 * i.e reg domain was changed during
2655 * connection. Queue disconnect for the
2656 * session if disconnect is not in
2657 * progress.
2658 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002659 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302660 sme_roam_disconnect(
2661 WLAN_HDD_GET_HAL_CTX(pAdapter),
2662 pAdapter->sessionId,
2663 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2664 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302665 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2668 eCSR_AUTH_TYPE_FT_RSN
2669 || pRoamInfo->u.pConnectedProfile->AuthType ==
2670 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2671
2672 /* Association Response */
2673 pFTAssocRsp =
2674 (u8 *) (pRoamInfo->pbFrames +
2675 pRoamInfo->nBeaconLength +
2676 pRoamInfo->nAssocReqLength);
2677 if (pFTAssocRsp != NULL) {
2678 /*
2679 * pFTAssocRsp needs to point to the IEs
2680 */
2681 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002682 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002683 (unsigned int)pFTAssocRsp[0],
2684 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 assocRsplen =
2686 pRoamInfo->nAssocRspLength -
2687 FT_ASSOC_RSP_IES_OFFSET;
2688 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002689 hdd_debug("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 assocRsplen = 0;
2691 }
2692
2693 /* Association Request */
2694 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2695 pRoamInfo->nBeaconLength);
2696 if (pFTAssocReq != NULL) {
2697 if (!ft_carrier_on) {
2698 /*
2699 * pFTAssocReq needs to point to
2700 * the IEs
2701 */
2702 pFTAssocReq +=
2703 FT_ASSOC_REQ_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002704 hdd_debug("pFTAssocReq is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002705 (unsigned int)
2706 pFTAssocReq[0],
2707 (unsigned int)
2708 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 assocReqlen =
2710 pRoamInfo->nAssocReqLength -
2711 FT_ASSOC_REQ_IES_OFFSET;
2712 } else {
2713 /*
2714 * This should contain only the
2715 * FTIEs
2716 */
2717 assocReqlen =
2718 pRoamInfo->nAssocReqLength;
2719 }
2720 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002721 hdd_debug("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 assocReqlen = 0;
2723 }
2724
2725 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08002726 if (!hddDisconInProgress &&
2727 pRoamInfo->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302728 struct cfg80211_bss *roam_bss;
2729
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 /*
2731 * After roaming is completed,
2732 * active session count is
2733 * incremented as a part of
2734 * connect indication but
2735 * effectively the active
2736 * session count should still
2737 * be the same and hence upon
2738 * successful reassoc
2739 * decrement the active session
2740 * count here.
2741 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002742 if (!hdd_is_roam_sync_in_progress
2743 (pRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002744 policy_mgr_decr_session_set_pcl(
2745 pHddCtx->hdd_psoc,
2746 pAdapter->device_mode,
2747 pAdapter->sessionId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002748 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002749 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 chan =
2751 ieee80211_get_channel
2752 (pAdapter->wdev.wiphy,
2753 (int)pRoamInfo->pBssDesc->
2754 channelId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002755 hdd_debug(
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002756 "assocReqlen %d assocRsplen %d",
2757 assocReqlen,
2758 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002759
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002760 hdd_debug(
Naveen Rawat14298b92015-11-25 16:27:41 -08002761 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302762 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302763 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302764 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002765 pFTAssocReq,
2766 assocReqlen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302767 roam_bss =
2768 hdd_cfg80211_get_bss(
2769 pAdapter->wdev.wiphy,
2770 chan,
2771 pRoamInfo->bssid.bytes,
2772 pRoamInfo->u.
2773 pConnectedProfile->SSID.ssId,
2774 pRoamInfo->u.
2775 pConnectedProfile->SSID.length);
2776 cfg80211_roamed_bss(dev,
2777 roam_bss,
2778 pFTAssocReq,
2779 assocReqlen,
2780 pFTAssocRsp,
2781 assocRsplen,
2782 GFP_KERNEL);
2783 wlan_hdd_send_roam_auth_event(
2784 pAdapter,
2785 pRoamInfo->bssid.bytes,
2786 pFTAssocReq,
2787 assocReqlen,
2788 pFTAssocRsp,
2789 assocRsplen,
2790 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 }
2792 if (sme_get_ftptk_state
2793 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2794 pAdapter->sessionId)) {
2795 sme_set_ftptk_state
2796 (WLAN_HDD_GET_HAL_CTX
2797 (pAdapter),
2798 pAdapter->sessionId,
2799 false);
2800 pRoamInfo->fAuthRequired =
2801 false;
2802
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302803 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 roam_info.bssid,
2805 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302806 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302807 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 roam_info.peerMac,
2809 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302810 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 pHddStaCtx->roam_info.roamId =
2812 roamId;
2813 pHddStaCtx->roam_info.
2814 roamStatus = roamStatus;
2815 pHddStaCtx->roam_info.
2816 deferKeyComplete = true;
2817 }
2818 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002819 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002820 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302821 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302822 pRoamInfo->
2823 bssid.bytes,
2824 pRoamInfo,
2825 pFTAssocReq,
2826 assocReqlen,
2827 pFTAssocRsp,
2828 assocRsplen,
2829 WLAN_STATUS_SUCCESS,
2830 GFP_KERNEL,
2831 false,
2832 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002834 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 /*
2836 * wpa supplicant expecting WPA/RSN IE in
2837 * connect result.
2838 */
2839 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2840 (pAdapter),
2841 pAdapter->sessionId,
2842 &reqRsnLength,
2843 reqRsnIe);
2844
2845 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2846 (pAdapter),
2847 pAdapter->sessionId,
2848 &rspRsnLength,
2849 rspRsnIe);
2850 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 if (ft_carrier_on)
2852 hdd_send_re_assoc_event(dev,
2853 pAdapter,
2854 pRoamInfo,
2855 reqRsnIe,
2856 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002857 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002858 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002859 MAC_ADDRESS_STR
2860 " result:%d and Status:%d",
2861 MAC_ADDR_ARRAY
2862 (pRoamInfo->bssid.bytes),
2863 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864
2865 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302866 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302867 pRoamInfo->
2868 bssid.bytes,
2869 pRoamInfo,
2870 reqRsnIe,
2871 reqRsnLength,
2872 rspRsnIe,
2873 rspRsnLength,
2874 WLAN_STATUS_SUCCESS,
2875 GFP_KERNEL,
2876 false,
2877 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 }
2879 }
2880 }
2881 if (!hddDisconInProgress) {
2882 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 bss);
2885
2886 /*
2887 * Perform any WMM-related association
2888 * processing.
2889 */
2890 hdd_wmm_assoc(pAdapter, pRoamInfo,
2891 eCSR_BSS_TYPE_INFRASTRUCTURE);
2892
2893 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002894 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002896 qdf_status = hdd_roam_register_sta(pAdapter,
2897 pRoamInfo,
2898 pHddStaCtx->conn_info.staId[0],
2899 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002900 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 wlan_hdd_netif_queue_control(pAdapter,
2902 WLAN_WAKE_ALL_NETIF_QUEUE,
2903 WLAN_CONTROL_PATH);
2904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 }
2906 } else {
2907 /*
2908 * wpa supplicant expecting WPA/RSN IE in connect result
2909 * in case of reassociation also need to indicate it to
2910 * supplicant.
2911 */
2912 csr_roam_get_wpa_rsn_req_ie(
2913 WLAN_HDD_GET_HAL_CTX(pAdapter),
2914 pAdapter->sessionId,
2915 &reqRsnLength, reqRsnIe);
2916
2917 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2918 reqRsnIe, reqRsnLength);
2919 /* Reassoc successfully */
2920 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302921 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 hdd_change_peer_state(pAdapter,
2923 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002924 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2926 pRoamInfo->roamSynchInProgress
2927#else
2928 false
2929#endif
2930 );
2931 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002932 hdd_objmgr_set_peer_mlme_auth_state(
2933 pAdapter->hdd_vdev,
2934 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002936 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002937 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302938 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002939 hdd_change_peer_state(pAdapter,
2940 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002941 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2943 pRoamInfo->roamSynchInProgress
2944#else
2945 false
2946#endif
2947 );
2948 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002949 hdd_objmgr_set_peer_mlme_auth_state(
2950 pAdapter->hdd_vdev,
2951 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 }
2953
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302954 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 /*
2956 * Perform any WMM-related association
2957 * processing
2958 */
2959 hdd_wmm_assoc(pAdapter, pRoamInfo,
2960 eCSR_BSS_TYPE_INFRASTRUCTURE);
2961 }
2962
2963 /* Start the tx queues */
2964#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2965 if (pRoamInfo->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002966 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002968 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 wlan_hdd_netif_queue_control(pAdapter,
2970 WLAN_WAKE_ALL_NETIF_QUEUE,
2971 WLAN_CONTROL_PATH);
2972 }
2973
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302974#ifdef FEATURE_WLAN_TDLS
2975 wlan_hdd_tdls_connection_callback(pAdapter);
2976#endif
2977
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302978 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002979 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302980 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 }
2982#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302983 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002984 sizeof(pAdapter->hdd_stats.hddPmfStats));
2985#endif
2986 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302987 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 hdd_wext_state_t *pWextState =
2989 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2990 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302991 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002992 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302993 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2994 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302996 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002997 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302998 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2999 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05303000
3001 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
3002 (pRoamInfo &&
3003 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
3004 pRoamInfo->statusCode) ||
3005 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
3006 pRoamInfo->statusCode) ||
3007 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
3008 pRoamInfo->statusCode)))) {
3009 wlan_hdd_cfg80211_update_bss_list(pAdapter,
3010 pRoamInfo ?
3011 pRoamInfo->bssid.bytes :
3012 pWextState->req_bssId.bytes);
3013 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
3014 pRoamInfo ?
3015 pRoamInfo->bssid.bytes :
3016 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303017 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303018 }
3019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020 /*
3021 * CR465478: Only send up a connection failure result when CSR
3022 * has completed operation - with a ASSOCIATION_FAILURE status.
3023 */
3024 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3025 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303026 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003027 hdd_err("send connect failure to nl80211: for bssid "
3028 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003029 " result: %d and Status: %d reasoncode: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003030 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3031 roamResult, roamStatus,
3032 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303033 pHddStaCtx->conn_info.assoc_status_code =
3034 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003035 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003036 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003038 " result: %d and status: %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3040 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003041 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003042 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303043 wlan_deregister_txrx_packetdump();
3044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 /* inform association failure event to nl80211 */
3046 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3047 roamResult) {
3048 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303049 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303051 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303053 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303054 connect_timeout,
3055 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303057 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303059 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303061 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303062 connect_timeout,
3063 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 } else {
Wu Gao77d28352016-11-23 17:50:56 +08003065 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303066 hdd_connect_result(dev,
3067 pRoamInfo->bssid.bytes,
3068 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08003069 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05303070 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303072 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303073 connect_timeout,
3074 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003075 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303076 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303078 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303080 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303081 connect_timeout,
3082 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 }
Abhishek Singhac2be142015-12-03 16:16:25 +05303084 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003085 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3086 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05303087 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003088 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05303089 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003090 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303091 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303092 connect_timeout,
3093 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 }
3095
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 /*
3097 * Set connection state to eConnectionState_NotConnected only
3098 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003099 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003101 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3102 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 hdd_conn_set_connection_state(pAdapter,
3105 eConnectionState_NotConnected);
3106 }
3107 hdd_wmm_init(pAdapter);
3108
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003109 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303111 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112 WLAN_CONTROL_PATH);
3113 }
3114
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303115 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116}
3117
3118/**
3119 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
3120 * @pAdapter: pointer to adapter
3121 * @pRoamInfo: pointer to roam info
3122 * @roamId: roam id
3123 * @roamStatus: roam status
3124 * @roamResult: roam result
3125 *
3126 * Here we update the status of the Ibss when we receive information that we
3127 * have started/joined an ibss session.
3128 *
3129 * Return: none
3130 */
3131static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3132 tCsrRoamInfo *pRoamInfo,
3133 uint32_t roamId,
3134 eRoamCmdStatus roamStatus,
3135 eCsrRoamResult roamResult)
3136{
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003137 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3138
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003139 hdd_debug("%s: id %d, status %d, result %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003140 pAdapter->dev->name, roamId,
3141 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142
3143 switch (roamResult) {
3144 /* both IBSS Started and IBSS Join should come in here. */
3145 case eCSR_ROAM_RESULT_IBSS_STARTED:
3146 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3147 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3148 {
3149 hdd_context_t *pHddCtx =
3150 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303151 hdd_station_ctx_t *hdd_sta_ctx =
3152 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303153 struct qdf_mac_addr broadcastMacAddr =
3154 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155
3156 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303157 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 return;
3159 }
3160
3161 /* When IBSS Started comes from CSR, we need to move
3162 * connection state to IBSS Disconnected (meaning no peers
3163 * are in the IBSS).
3164 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 hdd_conn_set_connection_state(pAdapter,
3166 eConnectionState_IbssDisconnected);
3167 /* notify wmm */
3168 hdd_wmm_connect(pAdapter, pRoamInfo,
3169 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303170
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003171 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303172
3173 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 pAdapter;
3175 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303176 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 &broadcastMacAddr,
3178 pRoamInfo->pBssDesc);
3179
3180 if (pRoamInfo->pBssDesc) {
3181 struct cfg80211_bss *bss;
3182#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3183 struct ieee80211_channel *chan;
3184 int chan_no;
3185 unsigned int freq;
3186#endif
3187 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003188 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3189 pAdapter->dev->name,
3190 MAC_ADDR_ARRAY(
3191 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192
3193 /* we must first give cfg80211 the BSS information */
3194 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3195 pRoamInfo);
3196 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003197 hdd_err("%s: unable to create IBSS entry",
3198 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 return;
3200 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003201 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 wlan_hdd_netif_queue_control(pAdapter,
3203 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3204 WLAN_CONTROL_PATH);
3205
3206#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3207 chan_no = pRoamInfo->pBssDesc->channelId;
3208
3209 if (chan_no <= 14)
3210 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003211 HDD_NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212 else
3213 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003214 HDD_NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215
3216 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3217
3218 if (chan)
3219 cfg80211_ibss_joined(pAdapter->dev,
3220 bss->bssid, chan,
3221 GFP_KERNEL);
3222 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003223 hdd_warn("%s: chanId: %d, can't find channel",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003224 pAdapter->dev->name,
3225 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226#else
3227 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3228 GFP_KERNEL);
3229#endif
3230 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 bss);
3233 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003234 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003235 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
3236 pAdapter->device_mode, pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003237 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3238 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003239 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
3240 pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003241 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 break;
3243 }
3244
3245 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3246 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003247 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 break;
3249 }
3250
3251 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003252 hdd_err("%s: unexpected result %d",
3253 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 break;
3255 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256}
3257
3258/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003259 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3260 * @sta_ctx: pointer to hdd station context
3261 * @sta_id: station ID
3262 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 *
3264 * This information is passed to iwconfig later. The peer that joined
3265 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003266
3267 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003269bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3270 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003272 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003274 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3275 if (0 == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003276 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003277 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003278 sta_ctx->conn_info.staId[idx] = sta_id;
3279 qdf_copy_macaddr(
3280 &sta_ctx->conn_info.peerMacAddress[idx],
3281 peer_mac_addr);
3282 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 }
3284 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003285 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286}
3287
3288/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003289 * hdd_delete_peer() - removes peer from hdd station context peer table
3290 * @sta_ctx: pointer to hdd station context
3291 * @sta_id: station ID
3292 *
3293 * Return: None
3294 */
3295void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3296{
3297 int i;
3298
3299 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3300 if (sta_id == sta_ctx->conn_info.staId[i]) {
3301 sta_ctx->conn_info.staId[i] = 0;
3302 return;
3303 }
3304 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003305}
3306
3307/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3309 * @pAdapter: pointer to adapter
3310 * @staId: station id
3311 *
3312 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003313 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 * false otherwise.
3315 */
3316static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3317{
3318 bool fSuccess = false;
3319 int idx = 0;
3320 uint8_t valid_idx = 0;
3321 uint8_t del_idx = 0;
3322 uint8_t empty_slots = 0;
3323 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3324
Naveen Rawatc45d1622016-07-05 12:20:09 -07003325 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3327 pHddStaCtx->conn_info.staId[idx] = 0;
3328
Anurag Chouhanc5548422016-02-24 18:33:27 +05303329 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 peerMacAddress[idx]);
3331
3332 fSuccess = true;
3333
3334 /*
3335 * Note the deleted Index, if its 0 we need special
3336 * handling.
3337 */
3338 del_idx = idx;
3339
3340 empty_slots++;
3341 } else {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003342 if (pHddStaCtx->conn_info.staId[idx] !=
3343 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 valid_idx = idx;
3345 } else {
3346 /* Found an empty slot */
3347 empty_slots++;
3348 }
3349 }
3350 }
3351
Naveen Rawatc45d1622016-07-05 12:20:09 -07003352 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 /* Last peer departed, set the IBSS state appropriately */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003354 hdd_conn_set_connection_state(pAdapter,
3355 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003356 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 }
3358 /* Find next active staId, to have a valid sta trigger for TL. */
3359 if (fSuccess == true) {
3360 if (del_idx == 0) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003361 if (pHddStaCtx->conn_info.staId[valid_idx] !=
3362 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363 pHddStaCtx->conn_info.staId[0] =
3364 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303365 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 peerMacAddress[0],
3367 &pHddStaCtx->conn_info.
3368 peerMacAddress[valid_idx]);
3369
3370 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303371 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 peerMacAddress[valid_idx]);
3373 }
3374 }
3375 }
3376 return fSuccess;
3377}
3378
3379/**
3380 * roam_ibss_connect_handler() - IBSS connection handler
3381 * @pAdapter: pointer to adapter
3382 * @pRoamInfo: pointer to roam info
3383 *
3384 * We update the status of the IBSS to connected in this function.
3385 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303386 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303388static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 tCsrRoamInfo *pRoamInfo)
3390{
3391 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 /*
3393 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3394 * a partner stations).
3395 */
3396 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3397
3398 /* Save the connection info from CSR... */
3399 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3400
3401 /* Send the bssid address to the wext. */
3402 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3403 /* add bss_id to cfg80211 data base */
3404 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3405 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003406 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303408 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 }
3410 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003412 bss);
3413
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303414 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415}
3416
3417/**
3418 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3419 * @pAdapter: pointer to adapter
3420 * @pRoamInfo: pointer to roam info
3421 * @roamId: roam id
3422 * @roamStatus: roam status
3423 * @roamResult: roam result
3424 *
3425 * This function indicates the Mic failure to the supplicant
3426 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303427 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303429static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3431 tCsrRoamInfo *pRoamInfo,
3432 uint32_t roamId,
3433 eRoamCmdStatus roamStatus,
3434 eCsrRoamResult roamResult)
3435{
3436 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3437
3438 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3439 TKIP_COUNTER_MEASURE_STOPED ==
3440 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3441 struct iw_michaelmicfailure msg;
3442 union iwreq_data wreq;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003443
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 memset(&msg, '\0', sizeof(msg));
3445 msg.src_addr.sa_family = ARPHRD_ETHER;
3446 memcpy(msg.src_addr.sa_data,
3447 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3448 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003449 hdd_debug("MIC MAC " MAC_ADDRESS_STR,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003450 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003451
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07003452 if (pRoamInfo->u.pMICFailureInfo->multicast == true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 msg.flags = IW_MICFAILURE_GROUP;
3454 else
3455 msg.flags = IW_MICFAILURE_PAIRWISE;
3456 memset(&wreq, 0, sizeof(wreq));
3457 wreq.data.length = sizeof(msg);
3458 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3459 (char *)&msg);
3460 /* inform mic failure to nl80211 */
3461 cfg80211_michael_mic_failure(pAdapter->dev,
3462 pRoamInfo->u.pMICFailureInfo->
3463 taMacAddr,
3464 ((pRoamInfo->u.pMICFailureInfo->
3465 multicast ==
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07003466 true) ?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 NL80211_KEYTYPE_GROUP :
3468 NL80211_KEYTYPE_PAIRWISE),
3469 pRoamInfo->u.pMICFailureInfo->
3470 keyId,
3471 pRoamInfo->u.pMICFailureInfo->TSC,
3472 GFP_KERNEL);
3473
3474 }
3475
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303476 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477}
3478
3479/**
3480 * roam_roam_connect_status_update_handler() - IBSS connect status update
3481 * @pAdapter: pointer to adapter
3482 * @pRoamInfo: pointer to roam info
3483 * @roamId: roam id
3484 * @roamStatus: roam status
3485 * @roamResult: roam result
3486 *
3487 * The Ibss connection status is updated regularly here in this function.
3488 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303489 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303491static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3493 tCsrRoamInfo *pRoamInfo,
3494 uint32_t roamId,
3495 eRoamCmdStatus roamStatus,
3496 eCsrRoamResult roamResult)
3497{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003499 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303500
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 switch (roamResult) {
3502 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3503 {
3504 hdd_station_ctx_t *pHddStaCtx =
3505 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003506 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003507 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003509 hdd_info("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303510 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3511 MAC_ADDRESS_STR " and stationID= %d",
3512 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3513 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3514 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003516 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3518 pRoamInfo->staId,
3519 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003520 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 break;
3522 }
3523
3524 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3525
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003526 if (hdd_is_key_install_required_for_ibss(encr_type))
3527 pRoamInfo->fAuthRequired = true;
3528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303530 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 pRoamInfo,
3532 pRoamInfo->staId,
3533 &pRoamInfo->peerMac,
3534 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303535 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003536 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303537 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 }
3539 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003540 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3541 if (stainfo == NULL) {
3542 hdd_err("memory allocation for station_info failed");
3543 return QDF_STATUS_E_NOMEM;
3544 }
3545 stainfo->filled = 0;
3546 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547
3548 cfg80211_new_sta(pAdapter->dev,
3549 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003550 stainfo, GFP_KERNEL);
3551 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003553 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 pHddStaCtx->ibss_enc_key.keyDirection =
3555 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303556 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 &pRoamInfo->peerMac);
3558
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003559 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003560 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303562 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3564 (pAdapter),
3565 pAdapter->sessionId,
3566 &pHddStaCtx->ibss_enc_key,
3567 &roamId);
3568
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303569 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003570 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003571 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303572 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 }
3574 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003575 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 wlan_hdd_netif_queue_control(pAdapter,
3577 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3578 WLAN_CONTROL_PATH);
3579 break;
3580 }
3581
3582 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3583 {
3584
3585 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3586
3587 break;
3588 }
3589 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3590 {
3591 hdd_station_ctx_t *pHddStaCtx =
3592 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3593
3594 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003595 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003597 hdd_info("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303598 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3599 MAC_ADDRESS_STR " and stationID= %d",
3600 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3601 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3602 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603
3604 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3605
3606 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3607 pHddStaCtx->ibss_sta_generation++;
3608
3609 cfg80211_del_sta(pAdapter->dev,
3610 (const u8 *)&pRoamInfo->peerMac.bytes,
3611 GFP_KERNEL);
3612 break;
3613 }
3614 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3615 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003616 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003618 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303620 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 hdd_conn_set_connection_state(pAdapter,
3623 eConnectionState_NotConnected);
3624
3625 /* Send the bssid address to the wext. */
3626 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3627 break;
3628 }
3629 default:
3630 break;
3631
3632 }
3633
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303634 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635}
3636
3637#ifdef FEATURE_WLAN_TDLS
3638/**
3639 * hdd_roam_register_tdlssta() - register new TDLS station
3640 * @pAdapter: pointer to adapter
3641 * @peerMac: pointer to peer MAC address
3642 * @staId: station identifier
3643 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303644 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 *
3646 * Construct the staDesc and register with TL the new STA.
3647 * This is called as part of ADD_STA in the TDLS setup.
3648 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303649 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303651QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303653 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303655 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003657 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003658 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3659 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660
3661 /*
3662 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3663 * be peer MAC, here we are working on direct Link
3664 */
3665 staDesc.sta_id = staId;
3666
3667 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303668 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669
Dhanashri Atre50141c52016-04-07 13:15:29 -07003670 /* Register the vdev transmit and receive functions */
3671 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3672 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003673 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003674 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3675 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003676 pAdapter, &txrx_ops);
3677 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678
3679 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003680 qdf_status = cdp_peer_register(soc,
3681 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303682 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003683 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303684 qdf_status, qdf_status);
3685 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686 }
3687
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303688 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689}
3690
3691/**
3692 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3693 * @pAdapter: pointer to adapter
3694 * @staId: station identifier
3695 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303696 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697 */
Nitesh Shah99dd9552017-03-20 19:27:47 +05303698QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303700 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003701 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003702 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3703 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303704 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003705 hdd_err("cdp_clear_peer() failed for staID: %d Status: %d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003706 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303708 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709}
3710
3711/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003712 * hdd_tdls_connection_tracker_update() - update connection tracker state
3713 * @adapter: pointer to adapter
3714 * @roam_info: pointer to roam info
3715 * @hdd_tdls_ctx: tdls context
3716 *
3717 * Return: QDF_STATUS enumeration
3718 */
3719static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3720 tCsrRoamInfo *roam_info,
3721 tdlsCtx_t *hdd_tdls_ctx)
3722{
3723 hddTdlsPeer_t *curr_peer;
3724 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3725
3726 curr_peer = wlan_hdd_tdls_find_peer(adapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303727 roam_info->peerMac.bytes);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003728
3729 if (!curr_peer) {
3730 hdd_err("curr_peer is null");
3731 return QDF_STATUS_E_FAILURE;
3732 }
3733
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003734 if (eTDLS_LINK_CONNECTED ==
3735 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003736 hdd_debug("Received CONNECTION_TRACKER_NOTIFICATION "
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003737 MAC_ADDRESS_STR
3738 " staId: %d, reason: %d",
3739 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3740 roam_info->staId,
3741 roam_info->reasonCode);
3742
3743 if (roam_info->reasonCode ==
3744 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3745 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003746 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3747 roam_info->reasonCode ==
3748 eWMI_TDLS_SCAN_STARTED_EVENT)
3749 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003750 else if (roam_info->reasonCode ==
3751 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3752 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003753 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3754 roam_info->reasonCode ==
3755 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3756 hdd_ctx->enable_tdls_connection_tracker = true;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003757 hdd_debug("hdd_ctx->enable_tdls_connection_tracker %d",
Nitesh Shahc549dd52017-02-23 16:45:44 +05303758 hdd_ctx->enable_tdls_connection_tracker);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003759 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003760 hdd_debug("TDLS not connected, ignore notification, reason: %d",
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003761 roam_info->reasonCode);
3762 }
3763
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003764 return QDF_STATUS_SUCCESS;
3765}
3766
3767
3768
3769
3770/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3772 * @pAdapter: pointer to adapter
3773 * @pRoamInfo: pointer to roam info
3774 * @roamId: roam id
3775 * @roamStatus: roam status
3776 * @roamResult: roam result
3777 *
3778 * HDD interface between SME and TL to ensure TDLS client registration with
3779 * TL in case of new TDLS client is added and deregistration at the time
3780 * TDLS client is deleted.
3781 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303782 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303784static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3786 tCsrRoamInfo *pRoamInfo,
3787 uint32_t roamId,
3788 eRoamCmdStatus roamStatus,
3789 eCsrRoamResult roamResult)
3790{
3791 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303792 tdlsCtx_t *pHddTdlsCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303794 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 uint8_t staIdx;
3796 hddTdlsPeer_t *curr_peer;
3797 uint32_t reason;
3798
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003799 hdd_debug("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 roamResult ==
3801 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3802 ==
3803 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3804 roamResult ==
3805 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3806 : roamResult ==
3807 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3808 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3809 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3810 roamResult ==
3811 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3812 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3813 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3814 : roamResult ==
3815 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3816 : roamResult ==
3817 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3818 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3819 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 switch (roamResult) {
3822 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3823 {
3824 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003825 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303827 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828 } else {
3829 /*
3830 * Check if there is available index for this new TDLS
3831 * STA.
3832 */
3833 for (staIdx = 0;
3834 staIdx < pHddCtx->max_num_tdls_sta;
3835 staIdx++) {
3836 if (0 ==
3837 pHddCtx->tdlsConnInfo[staIdx].
3838 staId) {
3839 pHddCtx->tdlsConnInfo[staIdx].
3840 sessionId =
3841 pRoamInfo->sessionId;
3842 pHddCtx->tdlsConnInfo[staIdx].
3843 staId = pRoamInfo->staId;
3844
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003845 hdd_debug("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003847 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848 staIdx,
3849 pHddCtx->
3850 tdlsConnInfo[staIdx].
3851 staId,
3852 MAC_ADDR_ARRAY
3853 (pRoamInfo->peerMac.bytes));
3854
Anurag Chouhanc5548422016-02-24 18:33:27 +05303855 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 tdlsConnInfo
3857 [staIdx].
3858 peerMac,
3859 &pRoamInfo->
3860 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303861 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 break;
3863 }
3864 }
3865 if (staIdx < pHddCtx->max_num_tdls_sta) {
3866 if (-1 ==
3867 wlan_hdd_tdls_set_sta_id(pAdapter,
3868 pRoamInfo->
3869 peerMac.bytes,
3870 pRoamInfo->
3871 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003872 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303873 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 }
3875
3876 (WLAN_HDD_GET_CTX(pAdapter))->
3877 sta_to_adapter[pRoamInfo->staId] =
3878 pAdapter;
3879 /*
3880 * store the ucast signature,
3881 * if required for further reference.
3882 */
3883
3884 wlan_hdd_tdls_set_signature(pAdapter,
3885 pRoamInfo->
3886 peerMac.bytes,
3887 pRoamInfo->
3888 ucastSig);
3889 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303890 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003891 hdd_debug("no available slot in conn_info. staId: %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 pRoamInfo->staId);
3893 }
3894 pAdapter->tdlsAddStaStatus = status;
3895 }
3896 complete(&pAdapter->tdls_add_station_comp);
3897 break;
3898 }
3899 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3900 {
3901 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003902 hdd_err("Add Sta failed. status code: %d",
Varun Reddy Yeturued1215e2017-07-07 16:40:28 -07003903 pRoamInfo->statusCode);
3904 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3905 } else {
3906 pAdapter->tdlsAddStaStatus = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 complete(&pAdapter->tdls_add_station_comp);
3909 break;
3910 }
3911 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3912 {
3913 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003914 hdd_err("Link Establish Request failed. status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 pRoamInfo->statusCode);
3916 }
3917 complete(&pAdapter->tdls_link_establish_req_comp);
3918 break;
3919 }
3920 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3921 {
3922 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3923 staIdx++) {
3924 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3925 pRoamInfo->sessionId)
3926 && pRoamInfo->staId ==
3927 pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003928 hdd_debug("HDD: del STA IDX = %x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003929 pRoamInfo->staId);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303930 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 curr_peer =
3932 wlan_hdd_tdls_find_peer(pAdapter,
3933 pRoamInfo->
Nitesh Shah90a02e92017-02-01 15:28:03 +05303934 peerMac.bytes);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303935 if (NULL != curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003936 hdd_debug("Current status for peer " MAC_ADDRESS_STR " is %d",
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303937 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3938 curr_peer->link_status);
3939 if (TDLS_IS_CONNECTED(curr_peer)) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303940 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 hdd_roam_deregister_tdlssta
3942 (pAdapter,
3943 pRoamInfo->staId);
3944 wlan_hdd_tdls_decrement_peer_count
3945 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303946 } else if (eTDLS_LINK_CONNECTING ==
3947 curr_peer->link_status) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303948 mutex_unlock(&pHddCtx->tdls_lock);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303949 hdd_roam_deregister_tdlssta
3950 (pAdapter,
3951 pRoamInfo->staId);
Nitesh Shah0bf768f2017-03-31 15:01:37 +05303952 } else
3953 mutex_unlock(&pHddCtx->tdls_lock);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303954 } else
3955 mutex_unlock(&pHddCtx->tdls_lock);
3956
Nitesh Shah99dd9552017-03-20 19:27:47 +05303957 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958 wlan_hdd_tdls_reset_peer(pAdapter,
3959 pRoamInfo->
3960 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05303961 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962
3963 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3964 pHddCtx->tdlsConnInfo[staIdx].
3965 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303966 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 tdlsConnInfo[staIdx].
3968 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303969 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303970 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971 break;
3972 }
3973 }
3974 complete(&pAdapter->tdls_del_station_comp);
3975 }
3976 break;
3977 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3978 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003979 hdd_debug("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 pRoamInfo->reasonCode);
3981
Nitesh Shahf1f38992017-01-31 16:40:16 +05303982 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 curr_peer =
3984 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303985 pRoamInfo->peerMac.bytes);
Ganesh Kondabattini9c8dc462017-04-19 10:52:54 +05303986
3987 if (!curr_peer) {
3988 mutex_unlock(&pHddCtx->tdls_lock);
3989 hdd_debug("peer doesn't exists");
3990 status = QDF_STATUS_SUCCESS;
3991 break;
3992 }
3993
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05303995 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303996 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3997 curr_peer->peerMac);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303998 mutex_unlock(&pHddCtx->tdls_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303999 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000 break;
4001 }
4002 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
4003 {
4004 /* 0 staIdx is assigned to AP we dont want to touch that */
4005 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
4006 staIdx++) {
4007 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
4008 pRoamInfo->sessionId)
4009 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004010 hdd_debug("hdd_tdlsStatusUpdate: staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004011 MAC_ADDRESS_STR,
4012 pHddCtx->tdlsConnInfo[staIdx].
4013 staId,
4014 MAC_ADDR_ARRAY(pHddCtx->
4015 tdlsConnInfo
4016 [staIdx].
4017 peerMac.
4018 bytes));
Nitesh Shah99dd9552017-03-20 19:27:47 +05304019 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 wlan_hdd_tdls_reset_peer(pAdapter,
4021 pHddCtx->
4022 tdlsConnInfo
4023 [staIdx].
4024 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304025 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 hdd_roam_deregister_tdlssta(pAdapter,
4027 pHddCtx->
4028 tdlsConnInfo
4029 [staIdx].
4030 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304031 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 sizeof
4033 (smeTdlsPeerStateParams));
4034 smeTdlsPeerStateParams.vdevId =
4035 pHddCtx->tdlsConnInfo[staIdx].
4036 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304037 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 peerMacAddr,
4039 &pHddCtx->
4040 tdlsConnInfo[staIdx].
4041 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304042 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 smeTdlsPeerStateParams.peerState =
4044 eSME_TDLS_PEER_STATE_TEARDOWN;
4045
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004046 hdd_debug("calling sme_update_tdls_peer_state for staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004047 MAC_ADDRESS_STR,
4048 pHddCtx->tdlsConnInfo[staIdx].
4049 staId,
4050 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 tdlsConnInfo
4052 [staIdx].
4053 peerMac.
4054 bytes));
4055 status =
4056 sme_update_tdls_peer_state(
4057 pHddCtx->hHal,
4058 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304059 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004060 hdd_err("sme_update_tdls_peer_state failed for "
4061 MAC_ADDRESS_STR,
4062 MAC_ADDR_ARRAY
4063 (pHddCtx->
4064 tdlsConnInfo[staIdx].
4065 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 }
4067 wlan_hdd_tdls_decrement_peer_count
4068 (pAdapter);
4069
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304070 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 tdlsConnInfo[staIdx].
4072 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304073 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4075 pHddCtx->tdlsConnInfo[staIdx].
4076 sessionId = 255;
4077
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304078 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 }
4080 }
4081 break;
4082 }
4083 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
4084 {
4085 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07004086 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
4087 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304088 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 break;
4090 }
4091
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004092 if (pHddCtx->tdls_nss_switch_in_progress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004093 hdd_debug("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004094 status = QDF_STATUS_SUCCESS;
4095 break;
4096 }
4097
Nitesh Shah8e866642017-01-31 15:43:31 +05304098 mutex_lock(&pHddCtx->tdls_lock);
4099 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4100 if (!pHddTdlsCtx) {
4101 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004102 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shah8e866642017-01-31 15:43:31 +05304103 roamResult);
4104 status = QDF_STATUS_E_FAILURE;
4105 break;
4106 }
4107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004108 curr_peer =
4109 wlan_hdd_tdls_get_peer(pAdapter,
Nitesh Shah379449e2017-01-31 19:11:29 +05304110 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004112 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304113 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 } else {
4115 if (eTDLS_LINK_CONNECTED ==
4116 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004117 hdd_debug("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 } else {
4119 /*
4120 * If external control is enabled then initiate
4121 * TDLS only if forced peer is set otherwise
4122 * ignore should Discover trigger from fw.
4123 */
4124 if (pHddCtx->config->
4125 fTDLSExternalControl
4126 && (false ==
4127 curr_peer->isForcedPeer)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004128 hdd_debug("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304129 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004132 hdd_debug("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Jeff Johnson68755312017-02-10 11:46:55 -08004133 pHddCtx->config->
4134 fTDLSExternalControl,
4135 curr_peer->isForcedPeer,
4136 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05304137 pHddTdlsCtx->curr_candidate = curr_peer;
4138 wlan_hdd_tdls_implicit_send_discovery_request(
4139 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304141 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 }
Nitesh Shah8e866642017-01-31 15:43:31 +05304143 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 break;
4145 }
4146
4147 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4148 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304149 mutex_lock(&pHddCtx->tdls_lock);
4150 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4151 if (!pHddTdlsCtx) {
4152 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004153 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304154 roamResult);
4155 status = QDF_STATUS_E_FAILURE;
4156 break;
4157 }
4158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 curr_peer =
4160 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304161 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004163 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304164 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 } else {
4166 if (eTDLS_LINK_CONNECTED ==
4167 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004168 hdd_debug("Received SHOULD_TEARDOWN for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004169 MAC_ADDRESS_STR
4170 " staId: %d, reason: %d",
4171 MAC_ADDR_ARRAY(pRoamInfo->
4172 peerMac.bytes),
4173 pRoamInfo->staId,
4174 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175
4176 if (pRoamInfo->reasonCode ==
4177 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4178 pRoamInfo->reasonCode ==
4179 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4180 pRoamInfo->reasonCode ==
4181 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4182 pRoamInfo->reasonCode ==
4183 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4184 reason =
4185 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4186 } else
4187 reason =
4188 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4189
4190 wlan_hdd_tdls_indicate_teardown
4191 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304192 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304193 hdd_send_wlan_tdls_teardown_event(
4194 eTDLS_TEARDOWN_BSS_DISCONNECT,
4195 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004197 hdd_debug("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004198 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304200 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304202 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 break;
4204 }
4205
4206 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4207 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304208 mutex_lock(&pHddCtx->tdls_lock);
4209 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4210 if (!pHddTdlsCtx) {
4211 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004212 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304213 roamResult);
4214 status = QDF_STATUS_E_FAILURE;
4215 break;
4216 }
4217
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 curr_peer =
4219 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304220 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004222 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304223 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224 } else {
4225 if (eTDLS_LINK_CONNECTED ==
4226 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004227 hdd_debug("Received SHOULD_PEER_DISCONNECTED for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004228 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004229 " staId: %d reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004230 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4231 pRoamInfo->staId,
4232 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233
4234 if (pRoamInfo->reasonCode ==
4235 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4236 pRoamInfo->reasonCode ==
4237 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4238 pRoamInfo->reasonCode ==
4239 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4240 pRoamInfo->reasonCode ==
4241 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4242 reason =
4243 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4244 } else
4245 reason =
4246 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4247
4248 wlan_hdd_tdls_indicate_teardown
4249 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304250 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304251 hdd_send_wlan_tdls_teardown_event(
4252 eTDLS_TEARDOWN_BSS_DISCONNECT,
4253 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004255 hdd_debug("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004256 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304258 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304260 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261 break;
4262 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004263
4264 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
Nitesh Shahf1f38992017-01-31 16:40:16 +05304265 mutex_lock(&pHddCtx->tdls_lock);
4266 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4267 if (!pHddTdlsCtx) {
4268 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004269 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304270 roamResult);
4271 status = QDF_STATUS_E_FAILURE;
4272 break;
4273 }
4274
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004275 status = hdd_tdls_connection_tracker_update(pAdapter,
4276 pRoamInfo,
4277 pHddTdlsCtx);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304278 mutex_unlock(&pHddCtx->tdls_lock);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004279 break;
4280
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 default:
4282 {
4283 break;
4284 }
4285 }
4286
4287 return status;
4288}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004289#else
4290
Nitesh Shah99dd9552017-03-20 19:27:47 +05304291inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004292 uint8_t staId)
4293{
4294 return QDF_STATUS_SUCCESS;
4295}
4296
4297static inline QDF_STATUS
4298hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4299 tCsrRoamInfo *pRoamInfo,
4300 uint32_t roamId,
4301 eRoamCmdStatus roamStatus,
4302 eCsrRoamResult roamResult)
4303{
4304 return QDF_STATUS_SUCCESS;
4305}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306#endif
4307
4308#ifdef WLAN_FEATURE_11W
4309/**
4310 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4311 * @pAdapter: pointer to the adapter
4312 * @nFrameLength: Length of the unprotected frame being passed
4313 * @pbFrames: Pointer to the frame buffer
4314 * @frameType: 802.11 frame type
4315 *
4316 * This function forwards the unprotected management frame to the supplicant.
4317 *
4318 * Return: nothing
4319 */
4320static void
4321hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4322 uint8_t *pbFrames, uint8_t frameType)
4323{
4324 uint8_t type = 0;
4325 uint8_t subType = 0;
4326
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004327 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004328 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329
4330 /* Sanity Checks */
4331 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004332 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 return;
4334 }
4335
4336 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004337 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 return;
4339 }
4340
4341 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004342 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343 return;
4344 }
4345
4346 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004347 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 return;
4349 }
4350
4351 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004352 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 return;
4354 }
4355
4356 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4357 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4358
4359 /* Get pAdapter from Destination mac address of the frame */
4360 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4361#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4362 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4363 nFrameLength);
4364#else
4365 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4366 nFrameLength);
4367#endif
4368 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4369 } else if (type == SIR_MAC_MGMT_FRAME &&
4370 subType == SIR_MAC_MGMT_DEAUTH) {
4371#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4372 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4373 nFrameLength);
4374#else
4375 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4376 nFrameLength);
4377#endif
4378 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4379 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004380 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004381 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382 return;
4383 }
4384}
4385#endif
4386
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004387#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388/**
4389 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4390 * @pAdapter: pointer to adapter
4391 * @tid: traffic identifier
4392 * @state: state
4393 * @measInterval: measurement interval
4394 *
4395 * This function sends traffic stream metrics IE information to
4396 * the supplicant via wireless event.
4397 *
4398 * Return: none
4399 */
4400static void
4401hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4402 uint8_t state, uint16_t measInterval)
4403{
4404 union iwreq_data wrqu;
4405 char buf[IW_CUSTOM_MAX + 1];
4406 int nBytes = 0;
4407
4408 if (NULL == pAdapter)
4409 return;
4410
4411 /* create the event */
4412 memset(&wrqu, '\0', sizeof(wrqu));
4413 memset(buf, '\0', sizeof(buf));
4414
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004415 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004416 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417
4418 nBytes =
4419 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4420 measInterval);
4421
4422 wrqu.data.pointer = buf;
4423 wrqu.data.length = nBytes;
4424 /* send the event */
4425 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4426}
4427
4428/**
4429 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4430 * @pAdapter: pointer to adapter
4431 * @pRoamInfo: pointer to roam info
4432 *
4433 * This function sends cckm preauth indication to the supplicant
4434 * via wireless custom event.
4435 *
4436 * Return: none
4437 */
4438static void
4439hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4440{
4441 union iwreq_data wrqu;
4442 char buf[IW_CUSTOM_MAX + 1];
4443 char *pos = buf;
4444 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4445
4446 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4447 return;
4448
4449 /* create the event */
4450 memset(&wrqu, '\0', sizeof(wrqu));
4451 memset(buf, '\0', sizeof(buf));
4452
4453 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004454 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004455 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4456 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457
4458 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4459 pos += nBytes;
4460 freeBytes -= nBytes;
4461
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304462 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304463 pos += QDF_MAC_ADDR_SIZE;
4464 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465
4466 nBytes = snprintf(pos, freeBytes, " %u:%u",
4467 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4468 freeBytes -= nBytes;
4469
4470 wrqu.data.pointer = buf;
4471 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4472
4473 /* send the event */
4474 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4475}
4476
4477/**
4478 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4479 * @pAdapter: pointer to adapter
4480 * @pRoamInfo: pointer to roam info
4481 *
4482 * Return: none
4483 */
4484static void
4485hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4486 tCsrRoamInfo *pRoamInfo)
4487{
4488 union iwreq_data wrqu;
4489 char buf[IW_CUSTOM_MAX + 1];
4490 int nBytes = 0;
4491
4492 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4493 return;
4494
4495 /* create the event */
4496 memset(&wrqu, '\0', sizeof(wrqu));
4497 memset(buf, '\0', sizeof(buf));
4498
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004499 hdd_debug("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500
4501 nBytes =
4502 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4503 pRoamInfo->tsmRoamDelay);
4504
4505 wrqu.data.pointer = buf;
4506 wrqu.data.length = nBytes;
4507
4508 /* send the event */
4509 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4510}
4511
4512/**
4513 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4514 * @pAdapter: pointer to adapter
4515 * @measurementToken: measurement token
4516 * @flag: flag
4517 * @numBss: number of bss
4518 *
4519 * If the measurement is none and no scan results found,
4520 * indicate the supplicant about measurement done.
4521 *
4522 * Return: none
4523 */
4524void
4525hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4526 const uint16_t measurementToken,
4527 const bool flag, const uint8_t numBss)
4528{
4529 union iwreq_data wrqu;
4530 char buf[IW_CUSTOM_MAX];
4531 char *pos = buf;
4532 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4533
4534 memset(&wrqu, '\0', sizeof(wrqu));
4535 memset(buf, '\0', sizeof(buf));
4536
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004537 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004538 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539
4540 nBytes =
4541 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4542 flag, numBss);
4543
4544 wrqu.data.pointer = buf;
4545 wrqu.data.length = nBytes;
4546 /* send the event */
4547 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4548}
4549
4550/**
4551 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4552 * @pAdapter: pointer to adapter
4553 * @pRoamInfo: pointer to roam info
4554 *
4555 * If the measurement is none and no scan results found,
4556 * indicate the supplicant about measurement done.
4557 *
4558 * Return: none
4559 */
4560static void
4561hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4562 const tCsrRoamInfo *pRoamInfo)
4563{
4564 union iwreq_data wrqu;
4565 char buf[IW_CUSTOM_MAX];
4566 char *pos = buf;
4567 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4568 uint8_t i = 0, len = 0;
4569 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4570 uint8_t lastSent = 0, sendBss = 0;
4571 int bcnRepFieldSize =
4572 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4573 bcnReportFields);
4574 uint8_t ieLenByte = 1;
4575 /*
4576 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4577 */
4578#define ESEBCNREPHEADER_LEN (18)
4579
4580 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4581 return;
4582
4583 /*
4584 * Custom event can pass maximum of 256 bytes of data,
4585 * based on the IE len we need to identify how many BSS info can
4586 * be filled in to custom event data.
4587 */
4588 /*
4589 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4590 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4591 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4592 */
4593
4594 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4595 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004596 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004598 * indicate the supplicant about measurement done
4599 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 hdd_indicate_ese_bcn_report_no_results(
4601 pAdapter,
4602 pRoamInfo->pEseBcnReportRsp->
4603 measurementToken,
4604 pRoamInfo->pEseBcnReportRsp->flag,
4605 pRoamInfo->pEseBcnReportRsp->numBss);
4606 } else {
4607 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4608 memset(&wrqu, '\0', sizeof(wrqu));
4609 memset(buf, '\0', sizeof(buf));
4610 tot_bcn_ieLen = 0;
4611 sendBss = 0;
4612 pos = buf;
4613 freeBytes = IW_CUSTOM_MAX;
4614
4615 for (i = lastSent;
4616 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4617 len =
4618 bcnRepFieldSize + ieLenByte +
4619 pRoamInfo->pEseBcnReportRsp->
4620 bcnRepBssInfo[i].ieLen;
4621 if ((len + tot_bcn_ieLen) >
4622 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4623 break;
4624 }
4625 tot_bcn_ieLen += len;
4626 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004627 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004628 i, bcnRepFieldSize, 1,
4629 pRoamInfo->pEseBcnReportRsp->
4630 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 }
4632
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004633 hdd_debug("Sending %d BSS Info", sendBss);
4634 hdd_debug("CCXBCNREP=%d %d %d %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004635 pRoamInfo->pEseBcnReportRsp->measurementToken,
4636 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4637 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638
4639 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4640 pRoamInfo->pEseBcnReportRsp->
4641 measurementToken,
4642 pRoamInfo->pEseBcnReportRsp->flag,
4643 sendBss);
4644 pos += nBytes;
4645 freeBytes -= nBytes;
4646
4647 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304648 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 sizeof(tot_bcn_ieLen));
4650 pos += sizeof(tot_bcn_ieLen);
4651 freeBytes -= sizeof(tot_bcn_ieLen);
4652
4653 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004654 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4656 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4657 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4658 pRoamInfo->pEseBcnReportRsp->
4659 bcnRepBssInfo[i +
4660 lastSent].bcnReportFields.
4661 ChanNum,
4662 pRoamInfo->pEseBcnReportRsp->
4663 bcnRepBssInfo[i +
4664 lastSent].bcnReportFields.
4665 Spare,
4666 pRoamInfo->pEseBcnReportRsp->
4667 bcnRepBssInfo[i +
4668 lastSent].bcnReportFields.
4669 MeasDuration,
4670 pRoamInfo->pEseBcnReportRsp->
4671 bcnRepBssInfo[i +
4672 lastSent].bcnReportFields.
4673 PhyType,
4674 pRoamInfo->pEseBcnReportRsp->
4675 bcnRepBssInfo[i +
4676 lastSent].bcnReportFields.
4677 RecvSigPower,
4678 pRoamInfo->pEseBcnReportRsp->
4679 bcnRepBssInfo[i +
4680 lastSent].bcnReportFields.
4681 ParentTsf,
4682 pRoamInfo->pEseBcnReportRsp->
4683 bcnRepBssInfo[i +
4684 lastSent].bcnReportFields.
4685 TargetTsf[0],
4686 pRoamInfo->pEseBcnReportRsp->
4687 bcnRepBssInfo[i +
4688 lastSent].bcnReportFields.
4689 TargetTsf[1],
4690 pRoamInfo->pEseBcnReportRsp->
4691 bcnRepBssInfo[i +
4692 lastSent].bcnReportFields.
4693 BcnInterval,
4694 pRoamInfo->pEseBcnReportRsp->
4695 bcnRepBssInfo[i +
4696 lastSent].bcnReportFields.
4697 CapabilityInfo,
4698 pRoamInfo->pEseBcnReportRsp->
4699 bcnRepBssInfo[i +
4700 lastSent].bcnReportFields.
4701 Bssid[0],
4702 pRoamInfo->pEseBcnReportRsp->
4703 bcnRepBssInfo[i +
4704 lastSent].bcnReportFields.
4705 Bssid[1],
4706 pRoamInfo->pEseBcnReportRsp->
4707 bcnRepBssInfo[i +
4708 lastSent].bcnReportFields.
4709 Bssid[2],
4710 pRoamInfo->pEseBcnReportRsp->
4711 bcnRepBssInfo[i +
4712 lastSent].bcnReportFields.
4713 Bssid[3],
4714 pRoamInfo->pEseBcnReportRsp->
4715 bcnRepBssInfo[i +
4716 lastSent].bcnReportFields.
4717 Bssid[4],
4718 pRoamInfo->pEseBcnReportRsp->
4719 bcnRepBssInfo[i +
4720 lastSent].bcnReportFields.
4721 Bssid[5]);
4722
4723 /* bcn report fields are copied */
4724 len =
4725 sizeof(pRoamInfo->pEseBcnReportRsp->
4726 bcnRepBssInfo[i +
4727 lastSent].
4728 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304729 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004730 (char *)&pRoamInfo->
4731 pEseBcnReportRsp->bcnRepBssInfo[i +
4732 lastSent].
4733 bcnReportFields, len);
4734 pos += len;
4735 freeBytes -= len;
4736
4737 /* Add 1 byte of ie len */
4738 len =
4739 pRoamInfo->pEseBcnReportRsp->
4740 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304741 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 pos += sizeof(len);
4743 freeBytes -= sizeof(len);
4744
4745 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304746 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 (char *)pRoamInfo->
4748 pEseBcnReportRsp->bcnRepBssInfo[i +
4749 lastSent].
4750 pBuf, len);
4751 pos += len;
4752 freeBytes -= len;
4753 }
4754
4755 wrqu.data.pointer = buf;
4756 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4757
4758 /* send the event */
4759 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4760 buf);
4761 lastSent += sendBss;
4762 }
4763 }
4764}
4765
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004766#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767
4768/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304769 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4770 * @pHddStaCtx: Station Context
4771 *
4772 * API to check if the connection authentication type is 8021x_sha256.
4773 *
4774 * Return: bool
4775 */
4776#ifdef WLAN_FEATURE_11W
4777static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4778{
4779 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4780 pHddStaCtx->conn_info.authType;
4781}
4782#else
4783static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4784{
4785 return false;
4786}
4787#endif
4788
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304789/*
4790 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4791 * @adapter: Pointer to adapter context
4792 * @roam_info: Pointer to roam info
4793 *
4794 * Return: None
4795 */
4796static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4797 tCsrRoamInfo *roam_info)
4798{
4799 struct hdd_chan_change_params chan_change;
4800 struct cfg80211_bss *bss;
4801 struct net_device *dev = adapter->dev;
4802 struct wireless_dev *wdev = dev->ieee80211_ptr;
4803 struct wiphy *wiphy = wdev->wiphy;
4804 QDF_STATUS status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004805 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304806
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004807 hdd_debug("channel switch for session:%d to channel:%d",
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304808 adapter->sessionId, roam_info->chan_info.chan_id);
4809
4810 chan_change.chan = roam_info->chan_info.chan_id;
4811 chan_change.chan_params.ch_width =
4812 roam_info->chan_info.ch_width;
4813 chan_change.chan_params.sec_ch_offset =
4814 roam_info->chan_info.sec_ch_offset;
4815 chan_change.chan_params.center_freq_seg0 =
4816 roam_info->chan_info.band_center_freq1;
4817 chan_change.chan_params.center_freq_seg1 =
4818 roam_info->chan_info.band_center_freq2;
4819
4820 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4821 if (NULL == bss)
4822 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4823 else
4824 cfg80211_put_bss(wiphy, bss);
4825
bings58ce8622017-07-10 15:55:36 +08004826 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4827 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304828 if (QDF_IS_STATUS_ERROR(status))
4829 hdd_err("channel change notification failed");
4830
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004831 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
4832 adapter->sessionId);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304833 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004834 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304835}
4836
Komal Seelam98760ba2015-12-15 11:05:18 +05304837/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004838 * hdd_sme_roam_callback() - hdd sme roam callback
4839 * @pContext: pointer to adapter context
4840 * @pRoamInfo: pointer to roam info
4841 * @roamId: roam id
4842 * @roamStatus: roam status
4843 * @roamResult: roam result
4844 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304845 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304847QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4849 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4850{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304851 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004852 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4853 hdd_wext_state_t *pWextState = NULL;
4854 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304855 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304856 struct cfg80211_bss *bss_status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004857 hdd_context_t *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004859 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004860 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004861
4862 /* Sanity check */
4863 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004864 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304865 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 }
4867
4868 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4869 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004870 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304872 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4873 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4874 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4875 pAdapter->sessionId, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877 switch (roamStatus) {
4878 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304879 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4880 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004881 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 break;
4883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884 /*
4885 * We did pre-auth,then we attempted a 11r or ese reassoc.
4886 * reassoc failed due to failure, timeout, reject from ap
4887 * in any case tell the OS, our carrier is off and mark
4888 * interface down.
4889 */
4890 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004891 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4892 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304893 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4895 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896 pHddStaCtx->ft_carrier_on = false;
4897 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004898 hdd_debug("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004899 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 break;
4901
4902 case eCSR_ROAM_FT_START:
4903 /*
4904 * When we roam for ESE and 11r, we dont want the OS to be
4905 * informed that the link is down. So mark the link ready for
4906 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4907 * be received. Where in we will not mark the link down
4908 * Also we want to stop tx at this point when we will be
4909 * doing disassoc at this time. This saves 30-60 msec
4910 * after reassoc.
4911 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004912 hdd_info("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004913 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004914 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004915 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304916 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004917 WLAN_CONTROL_PATH);
4918 status = hdd_roam_deregister_sta(pAdapter,
4919 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304920 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304921 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922 pHddStaCtx->ft_carrier_on = true;
4923 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004924 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4925 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004927 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004928 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004929 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004930 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304931 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
4932 pAdapter->roam_ho_fail = true;
4933 else
4934 pAdapter->roam_ho_fail = false;
4935 complete(&pAdapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004936 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004939 hdd_debug("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304941 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 wlan_hdd_netif_queue_control(pAdapter,
4945 WLAN_NETIF_CARRIER_OFF,
4946 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 break;
4949 case eCSR_ROAM_LOSTLINK:
4950 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004951 hdd_debug("Roaming started due to connection lost");
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004952 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304954 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 WLAN_CONTROL_PATH);
4956 break;
4957 }
4958 case eCSR_ROAM_DISASSOCIATED:
4959 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004960 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304961 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004962 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304963 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304964 pAdapter->roam_ho_fail = false;
4965 complete(&pAdapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004967 /* Call to clear any MC Addr List filter applied after
4968 * successful connection.
4969 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304970 hdd_disable_and_flush_mc_addr_list(pAdapter,
4971 pmo_peer_disconnect);
4972 qdf_ret_status =
4973 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4974 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 }
4976 break;
4977 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004978 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304979 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4981 roamStatus, roamResult);
4982 break;
4983 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004984 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 /*
4986 * To Do - address probable memory leak with WEP encryption upon
4987 * successful association.
4988 */
4989 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4990 /* Clear saved connection information in HDD */
4991 hdd_conn_remove_connect_info(
4992 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4993 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304994 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004995 hdd_association_completion_handler(pAdapter, pRoamInfo,
4996 roamId, roamStatus,
4997 roamResult);
4998#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4999 if (pRoamInfo)
5000 pRoamInfo->roamSynchInProgress = false;
5001#endif
5002 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07005003 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005004 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305006 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007 pRoamInfo,
5008 roamId,
5009 roamStatus,
5010 roamResult);
5011 break;
5012 case eCSR_ROAM_IBSS_IND:
5013 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
5014 roamStatus, roamResult);
5015 break;
5016
5017 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305018 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 roam_roam_connect_status_update_handler(pAdapter,
5020 pRoamInfo,
5021 roamId,
5022 roamStatus,
5023 roamResult);
5024 break;
5025
5026 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305027 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005028 hdd_roam_mic_error_indication_handler(pAdapter,
5029 pRoamInfo,
5030 roamId,
5031 roamStatus,
5032 roamResult);
5033 break;
5034
5035 case eCSR_ROAM_SET_KEY_COMPLETE:
5036 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305037 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
5039 roamId, roamStatus,
5040 roamResult);
5041 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
5042 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005043 hdd_debug("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005044 pHddStaCtx->hdd_ReassocScenario,
5045 pAdapter->sessionId);
5046 }
5047 }
5048#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5049 if (pRoamInfo != NULL)
5050 pRoamInfo->roamSynchInProgress = false;
5051#endif
5052 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005054 case eCSR_ROAM_FT_RESPONSE:
5055 hdd_send_ft_event(pAdapter);
5056 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005057
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05305059 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
5060 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005061 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305062 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005063 wlan_hdd_cfg80211_pmksa_candidate_notify(
5064 pAdapter, pRoamInfo, 1, false);
5065 }
5066 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005067
5068#ifdef FEATURE_WLAN_LFR_METRICS
5069 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
5070 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305071 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005072 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
5073 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305074 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 }
5076 break;
5077 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
5078 /*
5079 * This event will notify pre-auth completion in case of success
5080 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305081 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5083 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305084 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 }
5086 break;
5087 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
5088 /*
5089 * This event will notify pre-auth completion incase of failure.
5090 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305091 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005092 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5093 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305094 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095 }
5096 break;
5097 case eCSR_ROAM_HANDOVER_SUCCESS:
5098 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08005099 * It will be only invoked on success
5100 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305101 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
5103 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305104 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 }
5106 break;
5107#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005108 case eCSR_ROAM_REMAIN_CHAN_READY:
5109 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
5110 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005111#ifdef FEATURE_WLAN_TDLS
5112 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305113 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005114 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
5115 roamId,
5116 roamStatus,
5117 roamResult);
5118 break;
5119 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
5120 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
5121 pRoamInfo->reasonCode);
5122 break;
5123#endif
5124#ifdef WLAN_FEATURE_11W
5125 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
5126 hdd_indicate_unprot_mgmt_frame(pAdapter,
5127 pRoamInfo->nFrameLength,
5128 pRoamInfo->pbFrames,
5129 pRoamInfo->frameType);
5130 break;
5131#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005132#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005133 case eCSR_ROAM_TSM_IE_IND:
5134 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
5135 pRoamInfo->tsmIe.state,
5136 pRoamInfo->tsmIe.msmt_interval);
5137 break;
5138
5139 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
5140 {
5141 if (eCSR_AUTH_TYPE_CCKM_WPA ==
5142 pHddStaCtx->conn_info.authType
5143 || eCSR_AUTH_TYPE_CCKM_RSN ==
5144 pHddStaCtx->conn_info.authType) {
5145 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
5146 }
5147 break;
5148 }
5149
5150 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
5151 {
5152 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
5153 break;
5154 }
5155
5156 case eCSR_ROAM_ESE_BCN_REPORT_IND:
5157 {
5158 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
5159 break;
5160 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005161#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305162 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305163 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305164 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305165
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305166 case eCSR_ROAM_UPDATE_SCAN_RESULT:
5167 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
5168 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
5169 pAdapter, pRoamInfo->pBssDesc);
5170 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005171 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305172 else
5173 cfg80211_put_bss(
5174#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5175 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5176#endif
5177 bss_status);
5178 }
5179 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005180 case eCSR_ROAM_NDP_STATUS_UPDATE:
5181 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5182 roamResult);
5183 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005184 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005185 hdd_debug("Process ROAM_START from firmware");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005186 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305187 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005188 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005189 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005190 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005191 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08005192 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005193 break;
5194 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005195 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005196 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005197 wlan_hdd_netif_queue_control(pAdapter,
5198 WLAN_WAKE_ALL_NETIF_QUEUE,
5199 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005200 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005201 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305202 pAdapter->roam_ho_fail = false;
5203 complete(&pAdapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005204 break;
5205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 default:
5207 break;
5208 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305209 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210}
5211
5212/**
5213 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5214 * @auth_suite: auth suite
5215 *
5216 * Return: eCsrAuthType enumeration
5217 */
5218eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5219{
5220 eCsrAuthType auth_type;
5221 /* is the auth type supported? */
5222 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5223 auth_type = eCSR_AUTH_TYPE_RSN;
5224 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5225 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005226 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227 /* Check for 11r FT Authentication with PSK */
5228 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5229 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5230 /* Check for 11R FT Authentication with 802.1X */
5231 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5232 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005233#ifdef FEATURE_WLAN_ESE
5234 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5235 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5236 } else
5237#endif /* FEATURE_WLAN_ESE */
5238#ifdef WLAN_FEATURE_11W
5239 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5240 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5241 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5242 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5243 } else
5244#endif
5245 {
5246 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5247 }
5248 return auth_type;
5249}
5250
5251/**
5252 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5253 * @auth_suite: auth suite
5254 *
5255 * Return: eCsrAuthType enumeration
5256 */
5257eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5258{
5259 eCsrAuthType auth_type;
5260 /* is the auth type supported? */
5261 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5262 auth_type = eCSR_AUTH_TYPE_WPA;
5263 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5264 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5265 } else
5266#ifdef FEATURE_WLAN_ESE
5267 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5268 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5269 } else
5270#endif /* FEATURE_WLAN_ESE */
5271 {
5272 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5273 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005274 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 return auth_type;
5276}
5277
5278/**
5279 * hdd_translate_rsn_to_csr_encryption_type() -
5280 * Translate RSN to CSR encryption type
5281 * @cipher_suite: cipher suite
5282 *
5283 * Return: eCsrEncryptionType enumeration
5284 */
5285eCsrEncryptionType
5286hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5287{
5288 eCsrEncryptionType cipher_type;
5289
5290 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5291 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5292 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5293 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5294 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5295 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5296 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5297 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5298 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5299 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5300 else
5301 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5302
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005303 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 return cipher_type;
5305}
5306
5307/**
5308 * hdd_translate_wpa_to_csr_encryption_type() -
5309 * Translate WPA to CSR encryption type
5310 * @cipher_suite: cipher suite
5311 *
5312 * Return: eCsrEncryptionType enumeration
5313 */
5314eCsrEncryptionType
5315hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5316{
5317 eCsrEncryptionType cipher_type;
5318
5319 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5320 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5321 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5322 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5323 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5324 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5325 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5326 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5327 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5328 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5329 else
5330 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5331
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005332 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 return cipher_type;
5334}
5335
5336/**
5337 * hdd_process_genie() - process gen ie
5338 * @pAdapter: pointer to adapter
5339 * @bssid: pointer to mac address
5340 * @pEncryptType: pointer to encryption type
5341 * @mcEncryptType: pointer to multicast encryption type
5342 * @pAuthType: pointer to auth type
5343 *
5344 * Return: 0 on success, error number otherwise
5345 */
5346static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5347 u8 *bssid,
5348 eCsrEncryptionType *pEncryptType,
5349 eCsrEncryptionType *mcEncryptType,
5350 eCsrAuthType *pAuthType,
5351#ifdef WLAN_FEATURE_11W
5352 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5353#endif
5354 uint16_t gen_ie_len, uint8_t *gen_ie)
5355{
5356 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305357 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005358 tDot11fIERSN dot11RSNIE;
5359 tDot11fIEWPA dot11WPAIE;
5360 uint32_t i;
5361 uint8_t *pRsnIe;
5362 uint16_t RSNIeLen;
5363 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5364 bool updatePMKCache = false;
5365
5366 /*
5367 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5368 * setting present flag to 0.
5369 */
5370 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5371 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5372
5373 /* Type check */
5374 if (gen_ie[0] == DOT11F_EID_RSN) {
5375 /* Validity checks */
5376 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5377 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005378 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005379 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005380 return -EINVAL;
5381 }
5382 /* Skip past the EID byte and length byte */
5383 pRsnIe = gen_ie + 2;
5384 RSNIeLen = gen_ie_len - 2;
5385 /* Unpack the RSN IE */
5386 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305387 pRsnIe, RSNIeLen, &dot11RSNIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005388 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005389 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005390 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005391 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005392 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005393 /* dot11RSNIE.akm_suite_count */
5394 /* Just translate the FIRST one */
5395 *pAuthType =
5396 hdd_translate_rsn_to_csr_auth_type(
5397 dot11RSNIE.akm_suites[0]);
5398 /* dot11RSNIE.pwise_cipher_suite_count */
5399 *pEncryptType =
5400 hdd_translate_rsn_to_csr_encryption_type(
5401 dot11RSNIE.pwise_cipher_suites[0]);
5402 /* dot11RSNIE.gp_cipher_suite_count */
5403 *mcEncryptType =
5404 hdd_translate_rsn_to_csr_encryption_type(
5405 dot11RSNIE.gp_cipher_suite);
5406#ifdef WLAN_FEATURE_11W
5407 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5408 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5409#endif
5410 /* Set the PMKSA ID Cache for this interface */
5411 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5412 if (is_zero_ether_addr(bssid)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005413 hdd_warn("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 break;
5415 }
5416 updatePMKCache = true;
5417 /*
5418 * For right now, I assume setASSOCIATE() has passed
5419 * in the bssid.
5420 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305421 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305422 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305423 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5425 }
5426
5427 if (updatePMKCache) {
5428 /*
5429 * Calling csr_roam_set_pmkid_cache to configure the
5430 * PMKIDs into the cache.
5431 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005432 hdd_debug("Calling sme_roam_set_pmkid_cache with cache entry %d.",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005433 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005434 /* Finally set the PMKSA ID Cache in CSR */
5435 result =
5436 sme_roam_set_pmkid_cache(halHandle,
5437 pAdapter->sessionId,
5438 PMKIDCache,
5439 dot11RSNIE.pmkid_count,
5440 false);
5441 }
5442 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5443 /* Validity checks */
5444 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5445 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005446 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005447 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005448 return -EINVAL;
5449 }
5450 /* Skip past the EID and length byte - and four byte WiFi OUI */
5451 pRsnIe = gen_ie + 2 + 4;
5452 RSNIeLen = gen_ie_len - (2 + 4);
5453 /* Unpack the WPA IE */
5454 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305455 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005456 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005457 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005458 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005459 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005460 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461 /* dot11WPAIE.auth_suite_count */
5462 /* Just translate the FIRST one */
5463 *pAuthType =
5464 hdd_translate_wpa_to_csr_auth_type(
5465 dot11WPAIE.auth_suites[0]);
5466 /* dot11WPAIE.unicast_cipher_count */
5467 *pEncryptType =
5468 hdd_translate_wpa_to_csr_encryption_type(
5469 dot11WPAIE.unicast_ciphers[0]);
5470 /* dot11WPAIE.unicast_cipher_count */
5471 *mcEncryptType =
5472 hdd_translate_wpa_to_csr_encryption_type(
5473 dot11WPAIE.multicast_cipher);
5474 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005475 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476 return -EINVAL;
5477 }
5478 return 0;
5479}
5480
5481/**
5482 * hdd_set_genie_to_csr() - set genie to csr
5483 * @pAdapter: pointer to adapter
5484 * @RSNAuthType: pointer to auth type
5485 *
5486 * Return: 0 on success, error number otherwise
5487 */
5488int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5489{
5490 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5491 uint32_t status = 0;
5492 eCsrEncryptionType RSNEncryptType;
5493 eCsrEncryptionType mcRSNEncryptType;
5494#ifdef WLAN_FEATURE_11W
5495 uint8_t RSNMfpRequired = 0;
5496 uint8_t RSNMfpCapable = 0;
5497#endif
5498 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5499 /* MAC address of assoc peer */
5500 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305501 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 pWextState->roamProfile.BSSIDs.bssid,
5503 sizeof(bssid));
5504 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5505 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5506 /* continue */
5507 } else {
5508 return 0;
5509 }
5510 /* The actual processing may eventually be more extensive than this. */
5511 /* Right now, just consume any PMKIDs that are sent in by the app. */
5512 status = hdd_process_genie(pAdapter, bssid,
5513 &RSNEncryptType,
5514 &mcRSNEncryptType, RSNAuthType,
5515#ifdef WLAN_FEATURE_11W
5516 &RSNMfpRequired, &RSNMfpCapable,
5517#endif
5518 pWextState->WPARSNIE[1] + 2,
5519 pWextState->WPARSNIE);
5520 if (status == 0) {
5521 /*
5522 * Now copy over all the security attributes
5523 * you have parsed out.
5524 */
5525 pWextState->roamProfile.EncryptionType.numEntries = 1;
5526 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5527
5528 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5529 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5530 mcRSNEncryptType;
5531
Krunal Sonibe766b02016-03-10 13:00:44 -08005532 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5534 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5535 /*
5536 * For wpa none supplicant sends the WPA IE with unicast
5537 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5538 * multicast cipher as either AES/TKIP based on group
5539 * cipher configuration mentioned in the
5540 * wpa_supplicant.conf.
5541 */
5542
5543 /* Set the unicast cipher same as multicast cipher */
5544 pWextState->roamProfile.EncryptionType.encryptionType[0]
5545 = mcRSNEncryptType;
5546 }
5547#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005548 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005549 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5551 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5552#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005553 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005554 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555 }
5556 return 0;
5557}
5558
5559/**
5560 * hdd_set_csr_auth_type() - set csr auth type
5561 * @pAdapter: pointer to adapter
5562 * @RSNAuthType: auth type
5563 *
5564 * Return: 0 on success, error number otherwise
5565 */
5566int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5567{
5568 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5569 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5570 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571
5572 pRoamProfile->AuthType.numEntries = 1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005573 hdd_debug("pHddStaCtx->conn_info.authType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005574 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575
5576 switch (pHddStaCtx->conn_info.authType) {
5577 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5578#ifdef FEATURE_WLAN_ESE
5579 case eCSR_AUTH_TYPE_CCKM_WPA:
5580 case eCSR_AUTH_TYPE_CCKM_RSN:
5581#endif
5582 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5583
5584 pRoamProfile->AuthType.authType[0] =
5585 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5586 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5587
5588#ifdef FEATURE_WLAN_ESE
5589 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5590 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5591 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005592 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593 pRoamProfile->AuthType.authType[0] =
5594 eCSR_AUTH_TYPE_CCKM_WPA;
5595 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005596 hdd_debug("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 pRoamProfile->AuthType.authType[0] =
5598 eCSR_AUTH_TYPE_CCKM_WPA;
5599 } else
5600#endif
5601 if ((pWextState->
5602 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5603 == IW_AUTH_KEY_MGMT_802_1X) {
5604 pRoamProfile->AuthType.authType[0] =
5605 eCSR_AUTH_TYPE_WPA;
5606 } else
5607 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5608 == IW_AUTH_KEY_MGMT_PSK) {
5609 pRoamProfile->AuthType.authType[0] =
5610 eCSR_AUTH_TYPE_WPA_PSK;
5611 } else {
5612 pRoamProfile->AuthType.authType[0] =
5613 eCSR_AUTH_TYPE_WPA_NONE;
5614 }
5615 }
5616 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5617#ifdef FEATURE_WLAN_ESE
5618 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5619 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5620 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005621 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005622 pRoamProfile->AuthType.authType[0] =
5623 eCSR_AUTH_TYPE_CCKM_RSN;
5624 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005625 hdd_debug("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 pRoamProfile->AuthType.authType[0] =
5627 eCSR_AUTH_TYPE_CCKM_RSN;
5628 } else
5629#endif
5630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005631 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5632 ((pWextState->
5633 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5634 == IW_AUTH_KEY_MGMT_802_1X)) {
5635 pRoamProfile->AuthType.authType[0] =
5636 eCSR_AUTH_TYPE_FT_RSN;
5637 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5638 &&
5639 ((pWextState->
5640 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5641 == IW_AUTH_KEY_MGMT_PSK)) {
5642 pRoamProfile->AuthType.authType[0] =
5643 eCSR_AUTH_TYPE_FT_RSN_PSK;
5644 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645
5646#ifdef WLAN_FEATURE_11W
5647 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5648 pRoamProfile->AuthType.authType[0] =
5649 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5650 } else if (RSNAuthType ==
5651 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5652 pRoamProfile->AuthType.authType[0] =
5653 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5654 } else
5655#endif
5656
5657 if ((pWextState->
5658 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5659 == IW_AUTH_KEY_MGMT_802_1X) {
5660 pRoamProfile->AuthType.authType[0] =
5661 eCSR_AUTH_TYPE_RSN;
5662 } else
5663 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5664 == IW_AUTH_KEY_MGMT_PSK) {
5665 pRoamProfile->AuthType.authType[0] =
5666 eCSR_AUTH_TYPE_RSN_PSK;
5667 } else {
5668 pRoamProfile->AuthType.authType[0] =
5669 eCSR_AUTH_TYPE_UNKNOWN;
5670 }
5671 }
5672 break;
5673
5674 case eCSR_AUTH_TYPE_SHARED_KEY:
5675
5676 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5677 break;
5678 default:
5679
5680#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005681 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005682#endif /* FEATURE_WLAN_ESE */
5683 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5684 break;
5685 }
5686
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005687 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005688 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005690 return 0;
5691}
5692
5693/**
5694 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5695 * to the CSR roam profile.
5696 *
5697 * @dev: Pointer to the net device.
5698 * @info: Pointer to the iw_request_info.
5699 * @wrqu: Pointer to the iwreq_data.
5700 * @extra: Pointer to the data.
5701 *
5702 * Return: 0 for success, error number on failure
5703 */
5704static int __iw_set_essid(struct net_device *dev,
5705 struct iw_request_info *info,
5706 union iwreq_data *wrqu, char *extra)
5707{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005708 uint32_t status = 0;
5709 hdd_wext_state_t *pWextState;
5710 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5711 hdd_context_t *hdd_ctx;
5712 uint32_t roamId;
5713 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714 eCsrAuthType RSNAuthType;
5715 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 int ret;
5717
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005718 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719
5720 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5721 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305722 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005723 return ret;
5724
Jeff Johnson441e1f72017-02-07 08:50:49 -08005725 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5726 if (0 != ret)
5727 return ret;
5728
Krunal Sonibe766b02016-03-10 13:00:44 -08005729 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005730 pAdapter->device_mode != QDF_IBSS_MODE &&
5731 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005732 hdd_warn("device mode %s(%d) is not allowed",
5733 hdd_device_mode_to_string(pAdapter->device_mode),
5734 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005735 return -EINVAL;
5736 }
5737
5738 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5739
5740 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005741 hdd_warn("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742 return -EBUSY;
5743 }
5744 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5745 return -EINVAL;
5746
5747 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305748 /*Try disconnecting if already in connected state*/
5749 status = wlan_hdd_try_disconnect(pAdapter);
5750 if (0 > status) {
5751 hdd_err("Failed to disconnect the existing connection");
5752 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 }
5754
5755 /*
5756 * when cfg80211 defined, wpa_supplicant wext driver uses
5757 * zero-length, null-string ssid for force disconnection.
5758 * after disconnection (if previously connected) and cleaning ssid,
5759 * driver MUST return success.
5760 */
5761 if (0 == wrqu->essid.length)
5762 return 0;
5763
5764 status = hdd_wmm_get_uapsd_mask(pAdapter,
5765 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305766 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767 pWextState->roamProfile.uapsd_mask = 0;
5768
5769 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5770
5771 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5772 wrqu->essid.length;
5773
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305774 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305776 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777 ssId), extra, wrqu->essid.length);
5778 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5779 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5780
5781 /* set gen ie */
5782 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5783
5784 /* set auth */
5785 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5786 }
5787#ifdef FEATURE_WLAN_WAPI
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005788 hdd_debug("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789 if (pAdapter->wapi_info.nWapiMode) {
5790 switch (pAdapter->wapi_info.wapiAuthMode) {
5791 case WAPI_AUTH_MODE_PSK:
5792 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005793 hdd_debug("WAPI AUTH TYPE: PSK: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005794 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005795 pRoamProfile->AuthType.numEntries = 1;
5796 pRoamProfile->AuthType.authType[0] =
5797 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5798 break;
5799 }
5800 case WAPI_AUTH_MODE_CERT:
5801 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005802 hdd_debug("WAPI AUTH TYPE: CERT: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005803 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 pRoamProfile->AuthType.numEntries = 1;
5805 pRoamProfile->AuthType.authType[0] =
5806 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5807 break;
5808 }
5809 } /* End of switch */
5810 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5811 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005812 hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 pRoamProfile->EncryptionType.numEntries = 1;
5814 pRoamProfile->EncryptionType.encryptionType[0] =
5815 eCSR_ENCRYPT_TYPE_WPI;
5816 pRoamProfile->mcEncryptionType.numEntries = 1;
5817 pRoamProfile->mcEncryptionType.encryptionType[0] =
5818 eCSR_ENCRYPT_TYPE_WPI;
5819 }
5820 }
5821#endif /* FEATURE_WLAN_WAPI */
5822 /* if previous genIE is not NULL, update AssocIE */
5823 if (0 != pWextState->genIE.length) {
5824 memset(&pWextState->assocAddIE, 0,
5825 sizeof(pWextState->assocAddIE));
5826 memcpy(pWextState->assocAddIE.addIEdata,
5827 pWextState->genIE.addIEdata, pWextState->genIE.length);
5828 pWextState->assocAddIE.length = pWextState->genIE.length;
5829 pWextState->roamProfile.pAddIEAssoc =
5830 pWextState->assocAddIE.addIEdata;
5831 pWextState->roamProfile.nAddIEAssocLength =
5832 pWextState->assocAddIE.length;
5833
5834 /* clear previous genIE after use it */
5835 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5836 }
5837
5838 /*
5839 * Assumes it is not WPS Association by default, except when
5840 * pAddIEAssoc has WPS IE.
5841 */
5842 pWextState->roamProfile.bWPSAssociation = false;
5843
5844 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5845 pWextState->roamProfile.
5846 nAddIEAssocLength))
5847 pWextState->roamProfile.bWPSAssociation = true;
5848
5849 /* Disable auto BMPS entry by PMC until DHCP is done */
5850 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5851 true);
5852
5853 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5854
5855 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005856 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005858 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5859 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005861
Agrawal Ashish6b015762016-05-05 11:22:18 +05305862 /*
5863 * Change conn_state to connecting before sme_roam_connect(),
5864 * because sme_roam_connect() has a direct path to call
5865 * hdd_sme_roam_callback(), which will change the conn_state
5866 * If direct path, conn_state will be accordingly changed to
5867 * NotConnected or Associated by either
5868 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5869 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5870 * Connecting state will remain until it is completed.
5871 *
5872 * If connection state is not changed,
5873 * connection state will remain in eConnectionState_NotConnected state.
5874 * In hdd_association_completion_handler, "hddDisconInProgress" is
5875 * set to true if conn state is eConnectionState_NotConnected.
5876 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5877 * informed of connect result indication which is an issue.
5878 */
5879 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305880 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305881 hdd_conn_set_connection_state(pAdapter,
5882 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005884 status = sme_roam_connect(hHal, pAdapter->sessionId,
5885 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305886 if ((QDF_STATUS_SUCCESS != status) &&
5887 (QDF_STA_MODE == pAdapter->device_mode ||
5888 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005889 hdd_err("sme_roam_connect failed session_id: %d status %d -> NotConnected",
Agrawal Ashish6b015762016-05-05 11:22:18 +05305890 pAdapter->sessionId, status);
5891 /* change back to NotAssociated */
5892 hdd_conn_set_connection_state(pAdapter,
5893 eConnectionState_NotConnected);
5894 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 pRoamProfile->ChannelInfo.ChannelList = NULL;
5896 pRoamProfile->ChannelInfo.numOfChannels = 0;
5897
5898 EXIT();
5899 return status;
5900}
5901
5902/**
5903 * iw_set_essid() - set essid handler function
5904 * @dev: Pointer to the net device.
5905 * @info: Pointer to the iw_request_info.
5906 * @wrqu: Pointer to the iwreq_data.
5907 * @extra: Pointer to the data.
5908 *
5909 * Return: 0 for success, error number on failure
5910 */
5911int iw_set_essid(struct net_device *dev,
5912 struct iw_request_info *info,
5913 union iwreq_data *wrqu, char *extra)
5914{
5915 int ret;
5916
5917 cds_ssr_protect(__func__);
5918 ret = __iw_set_essid(dev, info, wrqu, extra);
5919 cds_ssr_unprotect(__func__);
5920
5921 return ret;
5922}
5923
5924/**
5925 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5926 * @dev: pointer to the net device
5927 * @info: pointer to the iw request info
5928 * @dwrq: pointer to iw_point
5929 * @extra: pointer to the data
5930 *
5931 * Return: 0 on success, error number otherwise
5932 */
5933static int __iw_get_essid(struct net_device *dev,
5934 struct iw_request_info *info,
5935 struct iw_point *dwrq, char *extra)
5936{
5937 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5938 hdd_context_t *hdd_ctx;
5939 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5940 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5941 int ret;
5942
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005943 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944
5945 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5946 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305947 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 return ret;
5949
Jeff Johnson441e1f72017-02-07 08:50:49 -08005950 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5951 if (0 != ret)
5952 return ret;
5953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5955 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5956 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5957 || pHddStaCtx->conn_info.connState ==
5958 eConnectionState_IbssDisconnected)
5959 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5960 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5961 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5962 dwrq->length);
5963 dwrq->flags = 1;
5964 } else {
5965 memset(extra, 0, dwrq->length);
5966 dwrq->length = 0;
5967 dwrq->flags = 0;
5968 }
5969 EXIT();
5970 return 0;
5971}
5972
5973/**
5974 * iw_get_essid() - get essid handler function
5975 * @dev: Pointer to the net device.
5976 * @info: Pointer to the iw_request_info.
5977 * @wrqu: Pointer to the iwreq_data.
5978 * @extra: Pointer to the data.
5979 *
5980 * Return: 0 for success, error number on failure
5981 */
5982int iw_get_essid(struct net_device *dev,
5983 struct iw_request_info *info,
5984 struct iw_point *wrqu, char *extra)
5985{
5986 int ret;
5987
5988 cds_ssr_protect(__func__);
5989 ret = __iw_get_essid(dev, info, wrqu, extra);
5990 cds_ssr_unprotect(__func__);
5991
5992 return ret;
5993}
5994
5995/**
5996 * __iw_set_auth() -
5997 * This function sets the auth type received from the wpa_supplicant
5998 * @dev: pointer to the net device
5999 * @info: pointer to the iw request info
6000 * @wrqu: pointer to iwreq_data
6001 * @extra: pointer to the data
6002 *
6003 * Return: 0 on success, error number otherwise
6004 */
6005static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6006 union iwreq_data *wrqu, char *extra)
6007{
6008 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6009 hdd_context_t *hdd_ctx;
6010 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6011 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6012 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6013 eCsrEncryptionType mcEncryptionType;
6014 eCsrEncryptionType ucEncryptionType;
6015 int ret;
6016
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006017 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018
6019 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6020 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306021 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022 return ret;
6023
Jeff Johnson441e1f72017-02-07 08:50:49 -08006024 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6025 if (0 != ret)
6026 return ret;
6027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006028 switch (wrqu->param.flags & IW_AUTH_INDEX) {
6029 case IW_AUTH_WPA_VERSION:
6030 pWextState->wpaVersion = wrqu->param.value;
6031 break;
6032
6033 case IW_AUTH_CIPHER_PAIRWISE:
6034 {
6035 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6036 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6037 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6038 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6039 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6040 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6041 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6042 if ((IW_AUTH_KEY_MGMT_802_1X
6043 ==
6044 (pWextState->
6045 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6046 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6047 pHddStaCtx->conn_info.authType))
6048 /*Dynamic WEP key */
6049 ucEncryptionType =
6050 eCSR_ENCRYPT_TYPE_WEP40;
6051 else
6052 /*Static WEP key */
6053 ucEncryptionType =
6054 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6055 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6056 if ((IW_AUTH_KEY_MGMT_802_1X
6057 ==
6058 (pWextState->
6059 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6060 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6061 pHddStaCtx->conn_info.authType))
6062 /*Dynamic WEP key */
6063 ucEncryptionType =
6064 eCSR_ENCRYPT_TYPE_WEP104;
6065 else
6066 /*Static WEP key */
6067 ucEncryptionType =
6068 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6069 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006070 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
6071 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006072 return -EINVAL;
6073 }
6074
6075 pRoamProfile->EncryptionType.numEntries = 1;
6076 pRoamProfile->EncryptionType.encryptionType[0] =
6077 ucEncryptionType;
6078 }
6079 break;
6080 case IW_AUTH_CIPHER_GROUP:
6081 {
6082 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6083 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6084 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6085 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6086 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6087 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6088 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6089 if ((IW_AUTH_KEY_MGMT_802_1X
6090 ==
6091 (pWextState->
6092 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6093 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6094 pHddStaCtx->conn_info.authType))
6095 mcEncryptionType =
6096 eCSR_ENCRYPT_TYPE_WEP40;
6097 else
6098 mcEncryptionType =
6099 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6100 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6101 /* Dynamic WEP keys won't work with shared keys */
6102 if ((IW_AUTH_KEY_MGMT_802_1X
6103 ==
6104 (pWextState->
6105 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6106 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6107 pHddStaCtx->conn_info.authType)) {
6108 mcEncryptionType =
6109 eCSR_ENCRYPT_TYPE_WEP104;
6110 } else {
6111 mcEncryptionType =
6112 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6113 }
6114 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006115 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006116 wrqu->param.value);
6117 return -EINVAL;
6118 }
6119
6120 pRoamProfile->mcEncryptionType.numEntries = 1;
6121 pRoamProfile->mcEncryptionType.encryptionType[0] =
6122 mcEncryptionType;
6123 }
6124 break;
6125
6126 case IW_AUTH_80211_AUTH_ALG:
6127 {
Jeff Johnson5a062372017-01-12 09:51:25 -08006128 /* Save the auth algo here and set auth type to SME
6129 * Roam profile in the iw_set_ap_address
6130 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
6132 pHddStaCtx->conn_info.authType =
6133 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6134
6135 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
6136 pHddStaCtx->conn_info.authType =
6137 eCSR_AUTH_TYPE_SHARED_KEY;
6138
6139 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
6140 /*Not supported */
6141 pHddStaCtx->conn_info.authType =
6142 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6143 pWextState->roamProfile.AuthType.authType[0] =
6144 pHddStaCtx->conn_info.authType;
6145 }
6146 break;
6147
6148 case IW_AUTH_KEY_MGMT:
6149 {
6150#ifdef FEATURE_WLAN_ESE
6151#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
6152 /*Check for CCKM AKM type */
6153 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006154 hdd_debug("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006155 /* Set the CCKM bit in authKeyMgmt */
6156 /*
6157 * Right now, this breaks all ref to authKeyMgmt because
6158 * our code doesn't realize it is a "bitfield"
6159 */
6160 pWextState->authKeyMgmt |=
6161 IW_AUTH_KEY_MGMT_CCKM;
6162 /* Set the key management to 802.1X */
6163 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
6164 pWextState->isESEConnection = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006165 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
6166 /* Save the key management */
6167 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08006168 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 /* Save the key management anyway */
6170 pWextState->authKeyMgmt = wrqu->param.value;
6171 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6172 /* Save the key management */
6173 pWextState->authKeyMgmt |=
6174 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 }
6176#else
6177 /* Save the key management */
6178 pWextState->authKeyMgmt = wrqu->param.value;
6179#endif /* FEATURE_WLAN_ESE */
6180 }
6181 break;
6182
6183 case IW_AUTH_TKIP_COUNTERMEASURES:
6184 {
6185 if (wrqu->param.value) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006186 hdd_debug("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187 wrqu->param.value);
6188 pWextState->mTKIPCounterMeasures =
6189 TKIP_COUNTER_MEASURE_STARTED;
6190 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006191 hdd_debug("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006192 wrqu->param.value);
6193 pWextState->mTKIPCounterMeasures =
6194 TKIP_COUNTER_MEASURE_STOPED;
6195 }
6196 }
6197 break;
6198 case IW_AUTH_DROP_UNENCRYPTED:
6199 case IW_AUTH_WPA_ENABLED:
6200 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6201 case IW_AUTH_ROAMING_CONTROL:
6202 case IW_AUTH_PRIVACY_INVOKED:
6203
6204 default:
6205
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006206 hdd_warn("called with unsupported auth type %d",
6207 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006208 break;
6209 }
6210
6211 EXIT();
6212 return 0;
6213}
6214
6215/**
6216 * iw_set_auth() - set auth callback function
6217 * @dev: Pointer to the net device.
6218 * @info: Pointer to the iw_request_info.
6219 * @wrqu: Pointer to the iwreq_data.
6220 * @extra: Pointer to the data.
6221 *
6222 * Return: 0 for success, error number on failure.
6223 */
6224int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6225 union iwreq_data *wrqu, char *extra)
6226{
6227 int ret;
6228
6229 cds_ssr_protect(__func__);
6230 ret = __iw_set_auth(dev, info, wrqu, extra);
6231 cds_ssr_unprotect(__func__);
6232
6233 return ret;
6234}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006235/**
6236 * __iw_get_auth() -
6237 * This function returns the auth type to the wpa_supplicant
6238 * @dev: pointer to the net device
6239 * @info: pointer to the iw request info
6240 * @wrqu: pointer to iwreq_data
6241 * @extra: pointer to the data
6242 *
6243 * Return: 0 on success, error number otherwise
6244 */
6245static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6246 union iwreq_data *wrqu, char *extra)
6247{
6248 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6249 hdd_context_t *hdd_ctx;
6250 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6251 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6252 int ret;
6253
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006254 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006255
6256 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6257 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306258 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006259 return ret;
6260
Jeff Johnson441e1f72017-02-07 08:50:49 -08006261 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6262 if (0 != ret)
6263 return ret;
6264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265 switch (pRoamProfile->negotiatedAuthType) {
6266 case eCSR_AUTH_TYPE_WPA_NONE:
6267 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6268 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6269 break;
6270 case eCSR_AUTH_TYPE_WPA:
6271 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6272 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6273 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006274
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006275 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006276 case eCSR_AUTH_TYPE_RSN:
6277 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6278 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6279 break;
6280 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6281 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6282 break;
6283 case eCSR_AUTH_TYPE_SHARED_KEY:
6284 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6285 break;
6286 case eCSR_AUTH_TYPE_UNKNOWN:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006287 hdd_debug("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006288 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6289 break;
6290 case eCSR_AUTH_TYPE_AUTOSWITCH:
6291 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6292 break;
6293 case eCSR_AUTH_TYPE_WPA_PSK:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006294 hdd_debug("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006295 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6296 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006298 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006299 case eCSR_AUTH_TYPE_RSN_PSK:
6300#ifdef WLAN_FEATURE_11W
6301 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6302 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6303#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006304 hdd_debug("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006305 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6306 return -EIO;
6307 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006308 hdd_warn("Unknown auth type: %d",
6309 pRoamProfile->negotiatedAuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006310 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6311 return -EIO;
6312 }
6313 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6314 switch (pRoamProfile->negotiatedUCEncryptionType) {
6315 case eCSR_ENCRYPT_TYPE_NONE:
6316 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6317 break;
6318 case eCSR_ENCRYPT_TYPE_WEP40:
6319 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6320 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6321 break;
6322 case eCSR_ENCRYPT_TYPE_TKIP:
6323 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6324 break;
6325 case eCSR_ENCRYPT_TYPE_WEP104:
6326 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6327 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6328 break;
6329 case eCSR_ENCRYPT_TYPE_AES:
6330 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6331 break;
6332 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006333 hdd_warn("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006334 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006335 return -EIO;
6336 }
6337 }
6338
6339 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6340 switch (pRoamProfile->negotiatedMCEncryptionType) {
6341 case eCSR_ENCRYPT_TYPE_NONE:
6342 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6343 break;
6344 case eCSR_ENCRYPT_TYPE_WEP40:
6345 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6346 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6347 break;
6348 case eCSR_ENCRYPT_TYPE_TKIP:
6349 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6350 break;
6351 case eCSR_ENCRYPT_TYPE_WEP104:
6352 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6353 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6354 break;
6355 case eCSR_ENCRYPT_TYPE_AES:
6356 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6357 break;
6358 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006359 hdd_err("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006360 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006361 return -EIO;
6362 }
6363 }
6364
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006365 hdd_debug("called with auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006366 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006367 EXIT();
6368 return 0;
6369}
6370
6371/**
6372 * iw_get_auth() - get auth callback function
6373 * @dev: Pointer to the net device.
6374 * @info: Pointer to the iw_request_info.
6375 * @wrqu: Pointer to the iwreq_data.
6376 * @extra: Pointer to the data.
6377 *
6378 * Return: 0 for success, error number on failure.
6379 */
6380int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6381 union iwreq_data *wrqu, char *extra)
6382{
6383 int ret;
6384
6385 cds_ssr_protect(__func__);
6386 ret = __iw_get_auth(dev, info, wrqu, extra);
6387 cds_ssr_unprotect(__func__);
6388
6389 return ret;
6390}
6391
6392/**
6393 * __iw_set_ap_address() - set ap address
6394 * @dev: pointer to the net device
6395 * @info: pointer to the iw request info
6396 * @wrqu: pointer to iwreq_data
6397 * @extra: pointer to the data
6398 *
6399 * This function updates the HDD global station context connection info
6400 * BSSID with the MAC address received from the wpa_supplicant.
6401 *
6402 * Return: 0 on success, error number otherwise
6403 */
6404static int __iw_set_ap_address(struct net_device *dev,
6405 struct iw_request_info *info,
6406 union iwreq_data *wrqu, char *extra)
6407{
6408
6409 hdd_adapter_t *adapter;
6410 hdd_context_t *hdd_ctx;
6411 hdd_station_ctx_t *pHddStaCtx =
6412 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6413 uint8_t *pMacAddress = NULL;
6414 int ret;
6415
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006416 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006417
6418 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6419
6420 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6421 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306422 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006423 return ret;
6424
Jeff Johnson441e1f72017-02-07 08:50:49 -08006425 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6426 if (0 != ret)
6427 return ret;
6428
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006429 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006430 hdd_debug(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306431 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306432 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006433 EXIT();
6434
6435 return 0;
6436}
6437
6438/**
6439 * iw_set_ap_address() - set ap addresses callback function
6440 * @dev: Pointer to the net device.
6441 * @info: Pointer to the iw_request_info.
6442 * @wrqu: Pointer to the iwreq_data.
6443 * @extra: Pointer to the data.
6444 *
6445 * Return: 0 for success, error number on failure.
6446 */
6447int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6448 union iwreq_data *wrqu, char *extra)
6449{
6450 int ret;
6451
6452 cds_ssr_protect(__func__);
6453 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6454 cds_ssr_unprotect(__func__);
6455
6456 return ret;
6457}
6458
6459/**
6460 * __iw_get_ap_address() - get ap address
6461 * @dev: pointer to the net device
6462 * @info: pointer to the iw request info
6463 * @wrqu: pointer to iwreq_data
6464 * @extra: pointer to the data
6465 *
6466 * This function returns currently associated BSSID.
6467 *
6468 * Return: 0 on success, error number otherwise
6469 */
6470static int __iw_get_ap_address(struct net_device *dev,
6471 struct iw_request_info *info,
6472 union iwreq_data *wrqu, char *extra)
6473{
6474 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6475 hdd_context_t *hdd_ctx;
6476 hdd_station_ctx_t *pHddStaCtx =
6477 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6478 int ret;
6479
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006480 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006481
6482 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6483 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306484 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006485 return ret;
6486
Jeff Johnson441e1f72017-02-07 08:50:49 -08006487 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6488 if (0 != ret)
6489 return ret;
6490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006491 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6492 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306493 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006494 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306495 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006496 } else {
6497 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6498 }
6499 EXIT();
6500 return 0;
6501}
6502
6503/**
6504 * iw_get_ap_address() - get ap addresses callback function
6505 * @dev: Pointer to the net device.
6506 * @info: Pointer to the iw_request_info.
6507 * @wrqu: Pointer to the iwreq_data.
6508 * @extra: Pointer to the data.
6509 *
6510 * Return: 0 for success, error number on failure.
6511 */
6512int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6513 union iwreq_data *wrqu, char *extra)
6514{
6515 int ret;
6516
6517 cds_ssr_protect(__func__);
6518 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6519 cds_ssr_unprotect(__func__);
6520
6521 return ret;
6522}