blob: 4689bec7fff127add7c5faf8057b43569bdf189e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020 * DOC: csr_api_roam.c
21 *
22 * Implementation for the Common Roaming interfaces.
23 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080024#include "ani_global.h" /* for tpAniSirGlobal */
25#include "wma_types.h"
26#include "wma_if.h" /* for STA_INVALID_IDX. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080027#include "csr_inside_api.h"
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053028#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080029#include "sme_qos_internal.h"
30#include "sme_inside.h"
31#include "host_diag_core_event.h"
32#include "host_diag_core_log.h"
33#include "csr_api.h"
34#include "csr_internal.h"
35#include "cds_reg_service.h"
36#include "mac_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037#include "csr_neighbor_roam.h"
Amar Singhale4f28ee2015-10-21 14:36:56 -070038#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#include "cds_utils.h"
40#include "sir_types.h"
41#include "cfg_api.h"
42#include "sme_power_save_api.h"
43#include "wma.h"
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080044#include "wlan_policy_mgr_api.h"
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070045#include "sme_nan_datapath.h"
Agrawal Ashish21ba2572016-09-03 16:40:10 +053046#include "pld_common.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070047#include "wlan_reg_services_api.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053048#include "qdf_crypto.h"
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053049#include <wlan_logging_sock_svc.h>
Krunal Sonia8270f52017-02-23 19:51:25 -080050#include "wlan_objmgr_psoc_obj.h"
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080051#include <wlan_scan_ucfg_api.h>
Frank Liud1a28462017-09-06 22:55:48 +080052#include <wlan_tdls_tgt_api.h>
Varun Reddy Yeturu85090c92018-01-26 15:06:02 -080053#include <wlan_cfg80211_scan.h>
Sandeep Puligilla68908f22018-02-28 18:20:41 -080054#include <wlan_scan_public_structs.h>
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053055#include <wlan_action_oui_public_struct.h>
56#include <wlan_action_oui_ucfg_api.h>
Himanshu Agarwal71b93972018-06-14 01:16:01 +053057#include <wlan_utility.h>
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +053058#include "wlan_mlme_public_struct.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059
Amar Singhal7c1e8982016-05-19 15:08:09 -070060#define MAX_PWR_FCC_CHAN_12 8
61#define MAX_PWR_FCC_CHAN_13 2
62
Sandeep Puligilla80038de2017-05-10 10:43:29 -070063#define CSR_NUM_IBSS_START_CHAN_50 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064#define CSR_NUM_IBSS_START_CHANNELS_24 3
Naveen Rawatd7734142017-10-27 10:02:40 -070065/* 70 seconds, for WPA, WPA2, CCKM */
66#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD \
67 (SIR_INSTALL_KEY_TIMEOUT_SEC * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068/* 120 seconds, for WPS */
Anurag Chouhan210db072016-02-22 18:42:15 +053069#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD (120 * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053071/* OBIWAN recommends [8 10]% : pick 9% */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053073/* OBIWAN recommends -85dBm */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074#define CSR_VCC_RSSI_THRESHOLD 80
75#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 /* ms */
76#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 /* ms */
77#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 /* ms */
78/* Flag to send/do not send disassoc frame over the air */
79#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
80#define RSSI_HACK_BMPS (-40)
81#define MAX_CB_VALUE_IN_INI (2)
82
83#define MAX_SOCIAL_CHANNELS 3
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053084
85/* packet dump timer duration of 60 secs */
86#define PKT_DUMP_TIMER_DURATION 60
87
Jeff Johnson698eacd2018-05-12 17:00:03 -070088/* Choose the largest possible value that can be accommodated in 8 bit signed */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089/* variable. */
90#define SNR_HACK_BMPS (127)
91
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070092/*
93 * ROAMING_OFFLOAD_TIMER_START - Indicates the action to start the timer
94 * ROAMING_OFFLOAD_TIMER_STOP - Indicates the action to stop the timer
95 * CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD - Timeout value for roaming offload timer
96 */
97#define ROAMING_OFFLOAD_TIMER_START 1
98#define ROAMING_OFFLOAD_TIMER_STOP 2
99#define CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD (5 * QDF_MC_TIMER_TO_SEC_UNIT)
100
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -0700101/*
102 * MAWC_ROAM_TRAFFIC_THRESHOLD_DEFAULT - Indicates the traffic thresold in kBps
103 * MAWC_ROAM_AP_RSSI_THRESHOLD_DEFAULT - indicates the AP RSSI threshold
104 * MAWC_ROAM_RSSI_HIGH_ADJUST_DEFAULT - Adjustable high value to suppress scan
105 * MAWC_ROAM_RSSI_LOW_ADJUST_DEFAULT - Adjustable low value to suppress scan
106 */
107#define MAWC_ROAM_TRAFFIC_THRESHOLD_DEFAULT 300
108#define MAWC_ROAM_AP_RSSI_THRESHOLD_DEFAULT (-66)
109#define MAWC_ROAM_RSSI_HIGH_ADJUST_DEFAULT 5
110#define MAWC_ROAM_RSSI_LOW_ADJUST_DEFAULT 5
111
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +0530112/*
113 * Neighbor report offload needs to send 0xFFFFFFFF if a particular
114 * parameter is disabled from the ini
115 */
116#define NEIGHBOR_REPORT_PARAM_INVALID (0xFFFFFFFFU)
117
Himanshu Agarwal71b93972018-06-14 01:16:01 +0530118/**
119 * csr_get_ielen_from_bss_description() - to get IE length
120 * from tSirBssDescription structure
121 * @pBssDescr: pBssDescr
122 *
123 * This function is called in various places to get IE length
124 * from tSirBssDescription structure
125 *
126 * @Return: total IE length
127 */
128static inline uint16_t
129csr_get_ielen_from_bss_description(tpSirBssDescription pBssDescr)
130{
131 uint16_t ielen;
132
133 if (!pBssDescr)
134 return 0;
135
136 /*
137 * Length of BSS desription is without length of
138 * length itself and length of pointer
139 * that holds ieFields
140 *
141 * <------------sizeof(tSirBssDescription)-------------------->
142 * +--------+---------------------------------+---------------+
143 * | length | other fields | pointer to IEs|
144 * +--------+---------------------------------+---------------+
145 * ^
146 * ieFields
147 */
148
149 ielen = (uint16_t)(pBssDescr->length + sizeof(pBssDescr->length) -
150 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
151
152 return ielen;
153}
154
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +0530155#ifdef WLAN_FEATURE_SAE
156/**
157 * csr_sae_callback - Update SAE info to CSR roam session
158 * @mac_ctx: MAC context
159 * @msg_ptr: pointer to SAE message
160 *
161 * API to update SAE info to roam csr session
162 *
163 * Return: QDF_STATUS
164 */
165static QDF_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx,
166 tSirSmeRsp *msg_ptr)
167{
168 struct csr_roam_info *roam_info;
169 uint32_t session_id;
170 struct sir_sae_info *sae_info;
171
172 sae_info = (struct sir_sae_info *) msg_ptr;
173 if (!sae_info) {
174 sme_err("SAE info is NULL");
175 return QDF_STATUS_E_FAILURE;
176 }
177
178 sme_debug("vdev_id %d "MAC_ADDRESS_STR"",
179 sae_info->vdev_id,
180 MAC_ADDR_ARRAY(sae_info->peer_mac_addr.bytes));
181
182 session_id = sae_info->vdev_id;
183 if (session_id == CSR_SESSION_ID_INVALID)
184 return QDF_STATUS_E_INVAL;
185
186 roam_info = qdf_mem_malloc(sizeof(*roam_info));
187 if (!roam_info) {
188 sme_err("qdf_mem_malloc failed for SAE");
189 return QDF_STATUS_E_FAILURE;
190 }
191
192 roam_info->sae_info = sae_info;
193
194 csr_roam_call_callback(mac_ctx, session_id, roam_info,
195 0, eCSR_ROAM_SAE_COMPUTE,
196 eCSR_ROAM_RESULT_NONE);
197 qdf_mem_free(roam_info);
198
199 return QDF_STATUS_SUCCESS;
200}
201#else
202static inline QDF_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx,
203 tSirSmeRsp *msg_ptr)
204{
205 return QDF_STATUS_SUCCESS;
206}
207#endif
208
209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Krunal Soni4b6c9462018-03-09 15:56:56 -0800211enum mgmt_auth_type diag_auth_type_from_csr_type(eCsrAuthType authtype)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212{
213 int n = AUTH_OPEN;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530214
Krunal Soni4b6c9462018-03-09 15:56:56 -0800215 switch (authtype) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216 case eCSR_AUTH_TYPE_SHARED_KEY:
217 n = AUTH_SHARED;
218 break;
219 case eCSR_AUTH_TYPE_WPA:
220 n = AUTH_WPA_EAP;
221 break;
222 case eCSR_AUTH_TYPE_WPA_PSK:
223 n = AUTH_WPA_PSK;
224 break;
225 case eCSR_AUTH_TYPE_RSN:
226#ifdef WLAN_FEATURE_11W
227 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
228#endif
229 n = AUTH_WPA2_EAP;
230 break;
231 case eCSR_AUTH_TYPE_RSN_PSK:
232#ifdef WLAN_FEATURE_11W
233 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
234#endif
235 n = AUTH_WPA2_PSK;
236 break;
237#ifdef FEATURE_WLAN_WAPI
238 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
239 n = AUTH_WAPI_CERT;
240 break;
241 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
242 n = AUTH_WAPI_PSK;
243 break;
244#endif /* FEATURE_WLAN_WAPI */
245 default:
246 break;
247 }
248 return n;
249}
250
Krunal Soni4b6c9462018-03-09 15:56:56 -0800251enum mgmt_encrypt_type diag_enc_type_from_csr_type(eCsrEncryptionType enctype)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252{
253 int n = ENC_MODE_OPEN;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530254
Krunal Soni4b6c9462018-03-09 15:56:56 -0800255 switch (enctype) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
257 case eCSR_ENCRYPT_TYPE_WEP40:
258 n = ENC_MODE_WEP40;
259 break;
260 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
261 case eCSR_ENCRYPT_TYPE_WEP104:
262 n = ENC_MODE_WEP104;
263 break;
264 case eCSR_ENCRYPT_TYPE_TKIP:
265 n = ENC_MODE_TKIP;
266 break;
267 case eCSR_ENCRYPT_TYPE_AES:
268 n = ENC_MODE_AES;
269 break;
Mukul Sharma05504ac2017-06-08 12:35:53 +0530270 case eCSR_ENCRYPT_TYPE_AES_GCMP:
271 n = ENC_MODE_AES_GCMP;
272 break;
273 case eCSR_ENCRYPT_TYPE_AES_GCMP_256:
274 n = ENC_MODE_AES_GCMP_256;
275 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276#ifdef FEATURE_WLAN_WAPI
277 case eCSR_ENCRYPT_TYPE_WPI:
278 n = ENC_MODE_SMS4;
279 break;
280#endif /* FEATURE_WLAN_WAPI */
281 default:
282 break;
283 }
284 return n;
285}
Krunal Soni4b6c9462018-03-09 15:56:56 -0800286
287enum mgmt_dot11_mode
288diag_dot11_mode_from_csr_type(enum csr_cfgdot11mode dot11mode)
289{
290 switch (dot11mode) {
291 case eCSR_CFG_DOT11_MODE_ABG:
292 return DOT11_MODE_ABG;
293 case eCSR_CFG_DOT11_MODE_11A:
294 return DOT11_MODE_11A;
295 case eCSR_CFG_DOT11_MODE_11B:
296 return DOT11_MODE_11B;
297 case eCSR_CFG_DOT11_MODE_11G:
298 return DOT11_MODE_11G;
299 case eCSR_CFG_DOT11_MODE_11N:
300 return DOT11_MODE_11N;
301 case eCSR_CFG_DOT11_MODE_11AC:
302 return DOT11_MODE_11AC;
303 case eCSR_CFG_DOT11_MODE_11G_ONLY:
304 return DOT11_MODE_11G_ONLY;
305 case eCSR_CFG_DOT11_MODE_11N_ONLY:
306 return DOT11_MODE_11N_ONLY;
307 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
308 return DOT11_MODE_11AC_ONLY;
309 case eCSR_CFG_DOT11_MODE_AUTO:
310 return DOT11_MODE_AUTO;
311 case eCSR_CFG_DOT11_MODE_11AX:
312 return DOT11_MODE_11AX;
313 case eCSR_CFG_DOT11_MODE_11AX_ONLY:
314 return DOT11_MODE_11AX_ONLY;
315 default:
316 return DOT11_MODE_MAX;
317 }
318}
319
320enum mgmt_ch_width diag_ch_width_from_csr_type(enum phy_ch_width ch_width)
321{
322 switch (ch_width) {
323 case CH_WIDTH_20MHZ:
324 return BW_20MHZ;
325 case CH_WIDTH_40MHZ:
326 return BW_40MHZ;
327 case CH_WIDTH_80MHZ:
328 return BW_80MHZ;
329 case CH_WIDTH_160MHZ:
330 return BW_160MHZ;
331 case CH_WIDTH_80P80MHZ:
332 return BW_80P80MHZ;
333 case CH_WIDTH_5MHZ:
334 return BW_5MHZ;
335 case CH_WIDTH_10MHZ:
336 return BW_10MHZ;
337 default:
338 return BW_MAX;
339 }
340}
341
342enum mgmt_bss_type diag_persona_from_csr_type(enum QDF_OPMODE persona)
343{
344 switch (persona) {
345 case QDF_STA_MODE:
346 return STA_PERSONA;
347 case QDF_SAP_MODE:
348 return SAP_PERSONA;
349 case QDF_P2P_CLIENT_MODE:
350 return P2P_CLIENT_PERSONA;
351 case QDF_P2P_GO_MODE:
352 return P2P_GO_PERSONA;
353 case QDF_FTM_MODE:
354 return FTM_PERSONA;
355 case QDF_IBSS_MODE:
356 return IBSS_PERSONA;
357 case QDF_MONITOR_MODE:
358 return MONITOR_PERSONA;
359 case QDF_P2P_DEVICE_MODE:
360 return P2P_DEVICE_PERSONA;
361 case QDF_OCB_MODE:
362 return OCB_PERSONA;
363 case QDF_EPPING_MODE:
364 return EPPING_PERSONA;
365 case QDF_QVIT_MODE:
366 return QVIT_PERSONA;
367 case QDF_NDI_MODE:
368 return NDI_PERSONA;
369 case QDF_WDS_MODE:
370 return WDS_PERSONA;
371 case QDF_BTAMP_MODE:
372 return BTAMP_PERSONA;
373 case QDF_AHDEMO_MODE:
374 return AHDEMO_PERSONA;
375 default:
376 return MAX_PERSONA;
377 }
378}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379#endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */
Krunal Soni4b6c9462018-03-09 15:56:56 -0800380
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381static const uint8_t
Sandeep Puligilla80038de2017-05-10 10:43:29 -0700382csr_start_ibss_channels50[CSR_NUM_IBSS_START_CHAN_50] = { 36, 44, 52, 56, 140 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383static const uint8_t
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530384csr_start_ibss_channels24[CSR_NUM_IBSS_START_CHANNELS_24] = { 1, 6, 11 };
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +0530385
386static const uint8_t
387social_channel[MAX_SOCIAL_CHANNELS] = { 1, 6, 11 };
388
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389static void init_config_param(tpAniSirGlobal pMac);
390static bool csr_roam_process_results(tpAniSirGlobal pMac, tSmeCmd *pCommand,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +0530391 enum csr_roamcomplete_result Result,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392 void *Context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530393static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -0700394 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 bool *pfSameIbss);
396static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
397 uint32_t sessionId,
398 tSirSmeNewBssInfo *
399 pNewBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
401 uint8_t primaryChn,
402 tDot11fBeaconIEs *pIes);
403
404static void csr_roaming_state_config_cnf_processor(tpAniSirGlobal pMac,
Krunal Sonia8270f52017-02-23 19:51:25 -0800405 tSmeCmd *pCommand, uint32_t result, uint8_t session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530406static QDF_STATUS csr_roam_open(tpAniSirGlobal pMac);
407static QDF_STATUS csr_roam_close(tpAniSirGlobal pMac);
408static bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 tCsrRoamConnectedProfile *pConnProfile,
Jeff Johnson66ee8a92018-03-17 15:24:26 -0700410 struct csr_roam_profile *pProfile2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530412static QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800413 uint32_t sessionId,
414 uint32_t interval);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530415static QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 uint32_t sessionId);
417static void csr_roam_roaming_timer_handler(void *pv);
Yingying Tang87f01392017-03-22 17:29:54 +0800418#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -0700419static void csr_roam_roaming_offload_timer_action(tpAniSirGlobal mac_ctx,
420 uint32_t interval, uint8_t session_id, uint8_t action);
Yingying Tang87f01392017-03-22 17:29:54 +0800421#endif
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -0700422static void csr_roam_roaming_offload_timeout_handler(void *timer_data);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530423static QDF_STATUS csr_roam_start_wait_for_key_timer(tpAniSirGlobal pMac,
424 uint32_t interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425static void csr_roam_wait_for_key_time_out_handler(void *pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530426static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
427static QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 tCsr11dinfo *ps11dinfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530429static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530430 struct csr_roam_connectedinfo *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 pConnectedInfo);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530432static QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac,
433 uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530434 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -0800435 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436 tAniEdType edType, bool fUnicast,
437 tAniKeyDirection aniKeyDirection,
438 uint8_t keyId, uint8_t keyLength,
439 uint8_t *pKey, uint8_t paeRole,
440 uint8_t *pKeyRsc);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530441static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId);
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700443#ifndef QCA_SUPPORT_CP_STATS
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530444static QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac,
445 uint32_t statsMask, uint8_t staId,
446 uint8_t sessionId);
447/* pStaEntry is no longer invalid upon the return of this function. */
448static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac,
449 tListElem *pEntry);
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530450struct csr_statsclient_reqinfo *csr_roam_insert_entry_into_list(
451 tpAniSirGlobal pMac, tDblLinkList *pStaList,
452 struct csr_statsclient_reqinfo *
453 pStaEntry);
454static void csr_roam_report_statistics(tpAniSirGlobal pMac,
455 uint32_t statsMask, tCsrStatsCallback callback, uint8_t staId,
456 void *pContext);
457tListElem *csr_roam_check_client_req_list(
458 tpAniSirGlobal pMac, uint32_t statsMask);
459static void csr_roam_remove_entry_from_pe_stats_req_list(
460 tpAniSirGlobal pMac, struct csr_pestats_reqinfo *pPeStaEntry);
461tListElem *csr_roam_find_in_pe_stats_req_list(
462 tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530463 uint32_t statsMask);
464static QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac);
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700465#else
466static QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac)
467{
468 return QDF_STATUS_SUCCESS;
469}
470#endif
471static enum csr_cfgdot11mode
472csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal pMac,
473 struct csr_roam_profile *pProfile,
474 uint8_t operationChn,
475 enum band_info *pBand);
476static QDF_STATUS csr_roam_get_qos_info_from_bss(
477tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac);
Peng Xuf5d60c82015-10-02 17:17:03 -0700479static uint32_t csr_find_session_by_type(tpAniSirGlobal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -0800480 enum QDF_OPMODE);
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530481static bool csr_is_conn_allow_2g_band(tpAniSirGlobal pMac,
482 uint32_t chnl);
483static bool csr_is_conn_allow_5g_band(tpAniSirGlobal pMac,
484 uint32_t chnl);
485static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac,
486 uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -0700487 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488 tSirBssDescription *pBssDesc);
489static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530490static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800491 uint32_t sessionId,
492 tCsrRoamSetKey *pSetKey,
493 uint32_t roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530494static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495 tSirBssDescription *pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf,
497 tSirSmeDisassocRsp *pRsp);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530498static void csr_init_operating_classes(tHalHandle hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +0530500static void csr_add_len_of_social_channels(tpAniSirGlobal mac,
501 uint8_t *num_chan);
502static void csr_add_social_channels(tpAniSirGlobal mac,
503 tSirUpdateChanList *chan_list, struct csr_scanstruct *pScan,
504 uint8_t *num_chan);
505
Qiwei Cai16b98582018-08-07 15:56:31 +0800506#ifdef WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY
507static struct csr_roam_session *csr_roam_roam_session;
508
509/* Allocate and initialize global variables */
510static QDF_STATUS csr_roam_init_globals(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511{
Qiwei Cai16b98582018-08-07 15:56:31 +0800512 uint32_t buf_size;
513 QDF_STATUS status = QDF_STATUS_E_FAILURE;
514
515 buf_size = CSR_ROAM_SESSION_MAX
516 * sizeof(struct csr_roam_session);
517
518 csr_roam_roam_session = qdf_mem_malloc(buf_size);
519
520 if (csr_roam_roam_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 pMac->roam.roamSession = csr_roam_roam_session;
Qiwei Cai16b98582018-08-07 15:56:31 +0800522 status = QDF_STATUS_SUCCESS;
523 } else {
524 sme_err("%s: Failed to allocate %d bytes",
525 __func__, buf_size);
526 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 }
Qiwei Cai16b98582018-08-07 15:56:31 +0800528
529 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530}
531
Qiwei Cai16b98582018-08-07 15:56:31 +0800532/* Free memory allocated dynamically */
533static inline void csr_roam_free_globals(void)
534{
535 qdf_mem_free(csr_roam_roam_session);
536 csr_roam_roam_session = NULL;
537}
538
539#else /* WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY */
540static struct csr_roam_session csr_roam_roam_session[CSR_ROAM_SESSION_MAX];
541
542/* Initialize global variables */
543static QDF_STATUS csr_roam_init_globals(tpAniSirGlobal pMac)
544{
545 qdf_mem_zero(&csr_roam_roam_session,
546 sizeof(csr_roam_roam_session));
547 pMac->roam.roamSession = csr_roam_roam_session;
548
549 return QDF_STATUS_SUCCESS;
550}
551
552static inline void csr_roam_free_globals(void)
553{
554}
555#endif /* WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY */
556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800557static void csr_roam_de_init_globals(tpAniSirGlobal pMac)
558{
Naveen Rawat20969542017-01-27 18:01:17 -0800559 uint8_t i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530560
Qiwei Cai16b98582018-08-07 15:56:31 +0800561 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
562 if (pMac->roam.roamSession[i].pCurRoamProfile)
Naveen Rawat20969542017-01-27 18:01:17 -0800563 csr_release_profile(pMac,
Qiwei Cai16b98582018-08-07 15:56:31 +0800564 pMac->roam.roamSession[i].
565 pCurRoamProfile);
566 csr_release_profile(pMac,
567 &pMac->roam.roamSession[i].
568 stored_roam_profile.profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569 }
Qiwei Cai16b98582018-08-07 15:56:31 +0800570 csr_roam_free_globals();
571 pMac->roam.roamSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800572}
573
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700574#ifdef QCA_SUPPORT_CP_STATS
575static QDF_STATUS csr_open_stats_ll(struct sAniSirGlobal *mac_ctx)
576{
577 return QDF_STATUS_SUCCESS;
578}
579
580static void csr_close_stats_ll(struct sAniSirGlobal *mac_ctx) {}
581#else
582static QDF_STATUS csr_open_stats_ll(struct sAniSirGlobal *mac_ctx)
583{
584 QDF_STATUS status;
585
Jeff Johnson616417f2018-06-27 10:20:53 -0700586 status = csr_ll_open(&mac_ctx->roam.statsClientReqList);
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700587 if (QDF_IS_STATUS_ERROR(status))
588 return status;
589
Jeff Johnson616417f2018-06-27 10:20:53 -0700590 return csr_ll_open(&mac_ctx->roam.peStatsReqList);
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700591}
592
593static void csr_close_stats_ll(struct sAniSirGlobal *mac_ctx)
594{
595 csr_ll_close(&mac_ctx->roam.statsClientReqList);
596 csr_ll_close(&mac_ctx->roam.peStatsReqList);
597}
598#endif
599
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530600QDF_STATUS csr_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530602 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603 uint32_t i;
604
605 do {
606 /* Initialize CSR Roam Globals */
Qiwei Cai16b98582018-08-07 15:56:31 +0800607 status = csr_roam_init_globals(pMac);
608 if (!QDF_IS_STATUS_SUCCESS(status))
609 break;
610
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
612 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, i);
613
614 init_config_param(pMac);
615 status = csr_scan_open(pMac);
Qiwei Cai16b98582018-08-07 15:56:31 +0800616 if (!QDF_IS_STATUS_SUCCESS(status)) {
617 csr_roam_free_globals();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 break;
Qiwei Cai16b98582018-08-07 15:56:31 +0800619 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 status = csr_roam_open(pMac);
Qiwei Cai16b98582018-08-07 15:56:31 +0800621 if (!QDF_IS_STATUS_SUCCESS(status)) {
622 csr_roam_free_globals();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 break;
Qiwei Cai16b98582018-08-07 15:56:31 +0800624 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 pMac->roam.nextRoamId = 1; /* Must not be 0 */
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700626 status = csr_open_stats_ll(pMac);
Qiwei Cai16b98582018-08-07 15:56:31 +0800627 if (QDF_IS_STATUS_ERROR(status)) {
628 csr_roam_free_globals();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800629 break;
Qiwei Cai16b98582018-08-07 15:56:31 +0800630 }
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530631 qdf_list_create(&pMac->roam.rssi_disallow_bssid,
632 MAX_RSSI_AVOID_BSSID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 } while (0);
634
635 return status;
636}
637
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530638QDF_STATUS csr_init_chan_list(tpAniSirGlobal mac, uint8_t *alpha2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530640 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641
642 mac->scan.countryCodeDefault[0] = alpha2[0];
643 mac->scan.countryCodeDefault[1] = alpha2[1];
644 mac->scan.countryCodeDefault[2] = alpha2[2];
645
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700646 sme_debug("init time country code %.2s", mac->scan.countryCodeDefault);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647
Amar Singhale4f28ee2015-10-21 14:36:56 -0700648 mac->scan.domainIdDefault = 0;
649 mac->scan.domainIdCurrent = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530651 qdf_mem_copy(mac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530653 qdf_mem_copy(mac->scan.countryCodeElected,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
655 status = csr_get_channel_and_power_list(mac);
656 csr_clear_votes_for_country_info(mac);
657 return status;
658}
659
Jeff Johnsonff26c612018-06-10 20:57:13 -0700660QDF_STATUS csr_set_channels(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530662 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 uint8_t index = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530664
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530665 qdf_mem_copy(pParam->Csr11dinfo.countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
667 for (index = 0; index < pMac->scan.base_channels.numChannels;
668 index++) {
669 pParam->Csr11dinfo.Channels.channelList[index] =
670 pMac->scan.base_channels.channelList[index];
671 pParam->Csr11dinfo.ChnPower[index].firstChannel =
672 pMac->scan.base_channels.channelList[index];
673 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
674 pParam->Csr11dinfo.ChnPower[index].maxtxPower =
Amar Singhal5cccafe2017-02-15 12:42:58 -0800675 pMac->scan.defaultPowerTable[index].tx_power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 }
677 pParam->Csr11dinfo.Channels.numChannels =
678 pMac->scan.base_channels.numChannels;
679
680 return status;
681}
682
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530683/**
684 * csr_assoc_rej_free_rssi_disallow_list() - Free the rssi diallowed
685 * BSSID entries and destroy the list
686 * @list: rssi based disallowed list entry
687 *
688 * Return: void
689 */
690static void csr_assoc_rej_free_rssi_disallow_list(qdf_list_t *list)
691{
692 QDF_STATUS status;
693 struct sir_rssi_disallow_lst *cur_node;
694 qdf_list_node_t *cur_lst = NULL, *next_lst = NULL;
695
696 qdf_list_peek_front(list, &cur_lst);
697 while (cur_lst) {
698 qdf_list_peek_next(list, cur_lst, &next_lst);
699 cur_node = qdf_container_of(cur_lst,
700 struct sir_rssi_disallow_lst, node);
701 status = qdf_list_remove_node(list, cur_lst);
702 if (QDF_IS_STATUS_SUCCESS(status))
703 qdf_mem_free(cur_node);
704 cur_lst = next_lst;
705 next_lst = NULL;
706 }
707 qdf_list_destroy(list);
708}
709
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530710QDF_STATUS csr_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800711{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530712 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713
714 csr_roam_close(pMac);
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530715 csr_assoc_rej_free_rssi_disallow_list(
716 &pMac->roam.rssi_disallow_bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717 csr_scan_close(pMac);
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700718 csr_close_stats_ll(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719 /* DeInit Globals */
720 csr_roam_de_init_globals(pMac);
721 return status;
722}
723
Amar Singhala297bfa2015-10-15 15:07:29 -0700724static int8_t csr_find_channel_pwr(struct channel_power *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 pdefaultPowerTable,
726 uint8_t ChannelNum)
727{
728 uint8_t i;
729 /* TODO: if defaultPowerTable is guaranteed to be in ascending */
730 /* order of channel numbers, we can employ binary search */
731 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -0700732 if (pdefaultPowerTable[i].chan_num == ChannelNum)
Amar Singhal5cccafe2017-02-15 12:42:58 -0800733 return pdefaultPowerTable[i].tx_power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 }
735 /* could not find the channel list in default list */
Jeff Johnson11d7c9d2018-05-06 15:44:09 -0700736 /* this should not have occurred */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530737 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 return 0;
739}
Naveen Rawat16b82872015-12-14 17:59:16 -0800740
741/**
742 * csr_roam_arrange_ch_list() - Updates the channel list modified with greedy
743 * order for 5 Ghz preference and DFS channels.
744 * @mac_ctx: pointer to mac context.
745 * @chan_list: channel list updated with greedy channel order.
746 * @num_channel: Number of channels in list
747 *
748 * To allow Early Stop Roaming Scan feature to co-exist with 5G preference,
749 * this function moves 5G channels ahead of 2G channels. This function can
750 * also move 2G channels, ahead of DFS channel or vice versa. Order is
751 * maintained among same category channels
752 *
753 * Return: None
754 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -0700755static void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx,
Naveen Rawat16b82872015-12-14 17:59:16 -0800756 tSirUpdateChanParam *chan_list, uint8_t num_channel)
757{
758 bool prefer_5g = CSR_IS_ROAM_PREFER_5GHZ(mac_ctx);
759 bool prefer_dfs = CSR_IS_DFS_CH_ROAM_ALLOWED(mac_ctx);
760 int i, j = 0;
761 tSirUpdateChanParam *tmp_list = NULL;
762
763 if (!prefer_5g)
764 return;
765
766 tmp_list = (tSirUpdateChanParam *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530767 qdf_mem_malloc(sizeof(tSirUpdateChanParam) * num_channel);
Naveen Rawat16b82872015-12-14 17:59:16 -0800768 if (tmp_list == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700769 sme_err("Memory allocation failed");
Naveen Rawat16b82872015-12-14 17:59:16 -0800770 return;
771 }
772
773 /* Fist copy Non-DFS 5g channels */
774 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700775 if (WLAN_REG_IS_5GHZ_CH(chan_list[i].chanId) &&
776 !wlan_reg_is_dfs_ch(mac_ctx->pdev,
777 chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530778 qdf_mem_copy(&tmp_list[j++],
Naveen Rawat16b82872015-12-14 17:59:16 -0800779 &chan_list[i], sizeof(tSirUpdateChanParam));
780 chan_list[i].chanId = INVALID_CHANNEL_ID;
781 }
782 }
783 if (prefer_dfs) {
784 /* next copy DFS channels (remaining channels in 5G) */
785 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700786 if (WLAN_REG_IS_5GHZ_CH(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530787 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800788 sizeof(tSirUpdateChanParam));
789 chan_list[i].chanId = INVALID_CHANNEL_ID;
790 }
791 }
792 } else {
793 /* next copy 2G channels */
794 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700795 if (WLAN_REG_IS_24GHZ_CH(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530796 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800797 sizeof(tSirUpdateChanParam));
798 chan_list[i].chanId = INVALID_CHANNEL_ID;
799 }
800 }
801 }
802 /* copy rest of the channels in same order to tmp list */
803 for (i = 0; i < num_channel; i++) {
804 if (chan_list[i].chanId != INVALID_CHANNEL_ID) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530805 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800806 sizeof(tSirUpdateChanParam));
807 chan_list[i].chanId = INVALID_CHANNEL_ID;
808 }
809 }
810 /* copy tmp list to original channel list buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530811 qdf_mem_copy(chan_list, tmp_list,
Naveen Rawat16b82872015-12-14 17:59:16 -0800812 sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530813 qdf_mem_free(tmp_list);
Naveen Rawat16b82872015-12-14 17:59:16 -0800814}
815
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700816/**
817 * csr_roam_sort_channel_for_early_stop() - Sort the channels
Naveen Rawat16b82872015-12-14 17:59:16 -0800818 * @mac_ctx: mac global context
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700819 * @chan_list: Original channel list from the upper layers
820 * @num_channel: Number of original channels
821 *
822 * For Early stop scan feature, the channel list should be in an order,
823 * where-in there is a maximum chance to detect an AP in the initial
824 * channels in the list so that the scanning can be stopped early as the
825 * feature demands.
826 * Below fixed greedy channel list has been provided
827 * based on most of the enterprise wifi installations across the globe.
828 *
829 * Identify all the greedy channels within the channel list from user space.
830 * Identify all the non-greedy channels in the user space channel list.
831 * Merge greedy channels followed by non-greedy channels back into the
832 * chan_list.
833 *
834 * Return: None
835 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -0700836static void csr_roam_sort_channel_for_early_stop(tpAniSirGlobal mac_ctx,
Naveen Rawat16b82872015-12-14 17:59:16 -0800837 tSirUpdateChanList *chan_list, uint8_t num_channel)
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700838{
839 tSirUpdateChanList *chan_list_greedy, *chan_list_non_greedy;
840 uint8_t i, j;
841 static const uint8_t fixed_greedy_chan_list[] = {1, 6, 11, 36, 48, 40,
842 44, 10, 2, 9, 149, 157, 161, 3, 4, 8, 153, 165, 7, 5, 136, 140,
843 52, 116, 56, 104, 64, 60, 100, 120, 13, 14, 112, 132, 151, 155};
844 uint8_t num_fixed_greedy_chan;
845 uint8_t num_greedy_chan = 0;
846 uint8_t num_non_greedy_chan = 0;
847 uint8_t match_found = false;
848 uint32_t buf_size;
849
850 buf_size = sizeof(tSirUpdateChanList) +
851 (sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530852 chan_list_greedy = qdf_mem_malloc(buf_size);
853 chan_list_non_greedy = qdf_mem_malloc(buf_size);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700854 if (!chan_list_greedy || !chan_list_non_greedy) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530855 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700856 "Failed to allocate memory for tSirUpdateChanList");
857 return;
858 }
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700859 /*
860 * fixed_greedy_chan_list is an evaluated channel list based on most of
861 * the enterprise wifi deployments and the order of the channels
862 * determines the highest possibility of finding an AP.
863 * chan_list is the channel list provided by upper layers based on the
864 * regulatory domain.
865 */
866 num_fixed_greedy_chan = sizeof(fixed_greedy_chan_list)/sizeof(uint8_t);
867 /*
868 * Browse through the chan_list and put all the non-greedy channels
Jeff Johnsonfa7d9602018-05-06 11:25:31 -0700869 * into a separate list by name chan_list_non_greedy
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700870 */
871 for (i = 0; i < num_channel; i++) {
872 for (j = 0; j < num_fixed_greedy_chan; j++) {
873 if (chan_list->chanParam[i].chanId ==
874 fixed_greedy_chan_list[j]) {
875 match_found = true;
876 break;
877 }
878 }
879 if (!match_found) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530880 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700881 &chan_list_non_greedy->chanParam[num_non_greedy_chan],
882 &chan_list->chanParam[i],
883 sizeof(tSirUpdateChanParam));
884 num_non_greedy_chan++;
885 } else {
886 match_found = false;
887 }
888 }
889 /*
890 * Browse through the fixed_greedy_chan_list and put all the greedy
Jeff Johnsonfa7d9602018-05-06 11:25:31 -0700891 * channels in the chan_list into a separate list by name
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700892 * chan_list_greedy
893 */
894 for (i = 0; i < num_fixed_greedy_chan; i++) {
895 for (j = 0; j < num_channel; j++) {
896 if (fixed_greedy_chan_list[i] ==
897 chan_list->chanParam[j].chanId) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530898 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700899 &chan_list_greedy->chanParam[num_greedy_chan],
900 &chan_list->chanParam[j],
901 sizeof(tSirUpdateChanParam));
902 num_greedy_chan++;
903 break;
904 }
905 }
906 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530907 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700908 "greedy=%d, non-greedy=%d, tot=%d",
909 num_greedy_chan, num_non_greedy_chan, num_channel);
910 if ((num_greedy_chan + num_non_greedy_chan) != num_channel) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530911 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700912 "incorrect sorting of channels");
913 goto scan_list_sort_error;
914 }
915 /* Copy the Greedy channels first */
916 i = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530917 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700918 &chan_list_greedy->chanParam[i],
919 num_greedy_chan * sizeof(tSirUpdateChanParam));
920 /* Copy the remaining Non Greedy channels */
921 i = num_greedy_chan;
922 j = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530923 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700924 &chan_list_non_greedy->chanParam[j],
925 num_non_greedy_chan * sizeof(tSirUpdateChanParam));
Naveen Rawat16b82872015-12-14 17:59:16 -0800926
927 /* Update channel list for 5g preference and allow DFS roam */
928 csr_roam_arrange_ch_list(mac_ctx, chan_list->chanParam, num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700929scan_list_sort_error:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530930 qdf_mem_free(chan_list_greedy);
931 qdf_mem_free(chan_list_non_greedy);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700932}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700934/**
935 * csr_emu_chan_req() - update the required channel list for emulation
936 * @channel: channel number to check
937 *
938 * To reduce scan time during emulation platforms, this function
939 * restricts the scanning to be done on selected channels
940 *
941 * Return: QDF_STATUS enumeration
942 */
943#ifdef QCA_WIFI_NAPIER_EMULATION
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700944#define SCAN_CHAN_LIST_5G_LEN 6
945#define SCAN_CHAN_LIST_2G_LEN 3
946static const uint8_t
947csr_scan_chan_list_5g[SCAN_CHAN_LIST_5G_LEN] = { 36, 44, 52, 56, 140, 149 };
948static const uint8_t
949csr_scan_chan_list_2g[SCAN_CHAN_LIST_2G_LEN] = { 1, 6, 11 };
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700950static QDF_STATUS csr_emu_chan_req(uint32_t channel)
951{
952 int i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700953
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700954 if (WLAN_REG_IS_24GHZ_CH(channel)) {
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700955 for (i = 0; i < QDF_ARRAY_SIZE(csr_scan_chan_list_2g); i++) {
956 if (csr_scan_chan_list_2g[i] == channel)
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700957 return QDF_STATUS_SUCCESS;
958 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700959 } else if (WLAN_REG_IS_5GHZ_CH(channel)) {
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700960 for (i = 0; i < QDF_ARRAY_SIZE(csr_scan_chan_list_5g); i++) {
961 if (csr_scan_chan_list_5g[i] == channel)
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700962 return QDF_STATUS_SUCCESS;
963 }
964 }
965 return QDF_STATUS_E_FAILURE;
966}
967#else
968static QDF_STATUS csr_emu_chan_req(uint32_t channel_num)
969{
970 return QDF_STATUS_SUCCESS;
971}
972#endif
973
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +0530974#ifdef WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY
975static void csr_add_len_of_social_channels(tpAniSirGlobal mac,
976 uint8_t *num_chan)
977{
978 uint8_t i;
979 uint8_t no_chan = *num_chan;
980
981 sme_debug("add len of social channels, before adding - num_chan:%hu",
982 *num_chan);
983 if (CSR_IS_5G_BAND_ONLY(mac)) {
984 for (i = 0; i < MAX_SOCIAL_CHANNELS; i++) {
985 if (wlan_reg_get_channel_state(
986 mac->pdev, social_channel[i]) ==
987 CHANNEL_STATE_ENABLE)
988 no_chan++;
989 }
990 }
991 *num_chan = no_chan;
992 sme_debug("after adding - num_chan:%hu", *num_chan);
993}
994
995static void csr_add_social_channels(tpAniSirGlobal mac,
996 tSirUpdateChanList *chan_list, struct csr_scanstruct *pScan,
997 uint8_t *num_chan)
998{
999 uint8_t i;
1000 uint8_t no_chan = *num_chan;
1001
1002 sme_debug("add social channels chan_list %pK, num_chan %hu", chan_list,
1003 *num_chan);
1004 if (CSR_IS_5G_BAND_ONLY(mac)) {
1005 for (i = 0; i < MAX_SOCIAL_CHANNELS; i++) {
1006 if (wlan_reg_get_channel_state(mac->pdev,
1007 social_channel[i]) != CHANNEL_STATE_ENABLE)
1008 continue;
1009 chan_list->chanParam[no_chan].chanId =
1010 social_channel[i];
1011 chan_list->chanParam[no_chan].pwr =
1012 csr_find_channel_pwr(pScan->defaultPowerTable,
1013 social_channel[i]);
1014 chan_list->chanParam[no_chan].dfsSet = false;
1015 if (cds_is_5_mhz_enabled())
1016 chan_list->chanParam[no_chan].quarter_rate
1017 = 1;
1018 else if (cds_is_10_mhz_enabled())
1019 chan_list->chanParam[no_chan].half_rate = 1;
1020 no_chan++;
1021 }
1022 sme_debug("after adding -num_chan %hu", no_chan);
1023 }
1024 *num_chan = no_chan;
1025}
1026#else
1027static void csr_add_len_of_social_channels(tpAniSirGlobal mac,
1028 uint8_t *num_chan)
1029{
1030 sme_debug("skip adding len of social channels");
1031}
1032static void csr_add_social_channels(tpAniSirGlobal mac,
1033 tSirUpdateChanList *chan_list, struct csr_scanstruct *pScan,
1034 uint8_t *num_chan)
1035{
1036 sme_debug("skip social channels");
1037}
1038#endif
1039
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301040QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041{
1042 tSirUpdateChanList *pChanList;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301043 struct csr_scanstruct *pScan = &pMac->scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 uint8_t numChan = pScan->base_channels.numChannels;
1045 uint8_t num_channel = 0;
1046 uint32_t bufLen;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001047 struct scheduler_msg msg = {0};
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +05301048 uint8_t i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 uint8_t channel_state;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301050 uint16_t unsafe_chan[NUM_CHANNELS];
1051 uint16_t unsafe_chan_cnt = 0;
1052 uint16_t cnt = 0;
1053 uint8_t channel;
1054 bool is_unsafe_chan;
1055 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
1056
1057 if (!qdf_ctx) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001058 sme_err("qdf_ctx is NULL");
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301059 return QDF_STATUS_E_FAILURE;
1060 }
1061
1062 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
1063 &unsafe_chan_cnt,
1064 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +05301066 csr_add_len_of_social_channels(pMac, &numChan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067
1068 bufLen = sizeof(tSirUpdateChanList) +
1069 (sizeof(tSirUpdateChanParam) * (numChan));
1070
1071 csr_init_operating_classes((tHalHandle) pMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301072 pChanList = (tSirUpdateChanList *) qdf_mem_malloc(bufLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 if (!pChanList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301074 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 "Failed to allocate memory for tSirUpdateChanList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301076 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078
1079 for (i = 0; i < pScan->base_channels.numChannels; i++) {
Agrawal, Ashish9f84c402016-11-30 16:19:44 +05301080 struct csr_sta_roam_policy_params *roam_policy =
1081 &pMac->roam.configParam.sta_roam_policy;
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -07001082 if (QDF_STATUS_SUCCESS !=
1083 csr_emu_chan_req(pScan->base_channels.channelList[i]))
1084 continue;
1085
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 /* Scan is not performed on DSRC channels*/
Kiran Kumar Lokere1a43bcf2018-05-15 15:51:58 -07001087 if (wlan_reg_is_dsrc_chan(pMac->pdev,
1088 pScan->base_channels.channelList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 continue;
Amar Singhal5cccafe2017-02-15 12:42:58 -08001090
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301091 channel = pScan->base_channels.channelList[i];
Amar Singhal7c1e8982016-05-19 15:08:09 -07001092
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001093 channel_state = wlan_reg_get_channel_state(pMac->pdev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 pScan->base_channels.channelList[i]);
1095 if ((CHANNEL_STATE_ENABLE == channel_state) ||
1096 pMac->scan.fEnableDFSChnlScan) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301097 if ((pMac->roam.configParam.sta_roam_policy.dfs_mode ==
1098 CSR_STA_ROAM_POLICY_DFS_DISABLED) &&
1099 (channel_state == CHANNEL_STATE_DFS)) {
1100 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh245182f2017-08-10 17:41:09 +05301101 QDF_TRACE_LEVEL_DEBUG,
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301102 FL("skip dfs channel %d"),
1103 channel);
1104 continue;
1105 }
1106 if (pMac->roam.configParam.sta_roam_policy.
1107 skip_unsafe_channels &&
1108 unsafe_chan_cnt) {
1109 is_unsafe_chan = false;
1110 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
1111 if (unsafe_chan[cnt] == channel) {
1112 is_unsafe_chan = true;
1113 break;
1114 }
1115 }
Agrawal, Ashish9f84c402016-11-30 16:19:44 +05301116 if ((is_unsafe_chan) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001117 ((WLAN_REG_IS_24GHZ_CH(channel) &&
Agrawal, Ashish9f84c402016-11-30 16:19:44 +05301118 roam_policy->sap_operating_band ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001119 BAND_2G) ||
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001120 (WLAN_REG_IS_5GHZ_CH(channel) &&
Agrawal, Ashish9f84c402016-11-30 16:19:44 +05301121 roam_policy->sap_operating_band ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001122 BAND_5G))) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301123 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh245182f2017-08-10 17:41:09 +05301124 QDF_TRACE_LEVEL_DEBUG,
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301125 FL("ignoring unsafe channel %d"),
1126 channel);
1127 continue;
1128 }
1129 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 pChanList->chanParam[num_channel].chanId =
1131 pScan->base_channels.channelList[i];
1132 pChanList->chanParam[num_channel].pwr =
1133 csr_find_channel_pwr(pScan->defaultPowerTable,
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301134 pChanList->chanParam[num_channel].chanId);
Amar Singhal7c1e8982016-05-19 15:08:09 -07001135
1136 if (pScan->fcc_constraint) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301137 if (12 == pChanList->chanParam[num_channel].
1138 chanId) {
Amar Singhal7c1e8982016-05-19 15:08:09 -07001139 pChanList->chanParam[num_channel].pwr =
1140 MAX_PWR_FCC_CHAN_12;
1141 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh245182f2017-08-10 17:41:09 +05301142 QDF_TRACE_LEVEL_DEBUG,
Amar Singhal83a047a2016-05-19 15:56:11 -07001143 "txpow for channel 12 is %d",
1144 MAX_PWR_FCC_CHAN_12);
Amar Singhal7c1e8982016-05-19 15:08:09 -07001145 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301146 if (13 == pChanList->chanParam[num_channel].
1147 chanId) {
Amar Singhal7c1e8982016-05-19 15:08:09 -07001148 pChanList->chanParam[num_channel].pwr =
1149 MAX_PWR_FCC_CHAN_13;
1150 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh245182f2017-08-10 17:41:09 +05301151 QDF_TRACE_LEVEL_DEBUG,
Amar Singhal83a047a2016-05-19 15:56:11 -07001152 "txpow for channel 13 is %d",
1153 MAX_PWR_FCC_CHAN_13);
Amar Singhal7c1e8982016-05-19 15:08:09 -07001154 }
1155 }
1156
1157
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 if (CHANNEL_STATE_ENABLE == channel_state)
1159 pChanList->chanParam[num_channel].dfsSet =
1160 false;
1161 else
1162 pChanList->chanParam[num_channel].dfsSet =
1163 true;
Naveen Rawat64e477e2016-05-20 10:34:56 -07001164 if (cds_is_5_mhz_enabled())
1165 pChanList->chanParam[num_channel].quarter_rate
1166 = 1;
1167 else if (cds_is_10_mhz_enabled())
1168 pChanList->chanParam[num_channel].half_rate = 1;
Abhishek Singh245182f2017-08-10 17:41:09 +05301169 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singh562aad62017-01-05 16:24:23 +05301170 "channel:%d, pwr=%d, DFS=%d qrate %d hrate %d ",
1171 pChanList->chanParam[num_channel].chanId,
1172 pChanList->chanParam[num_channel].pwr,
1173 pChanList->chanParam[num_channel].dfsSet,
1174 pChanList->chanParam[num_channel].quarter_rate,
1175 pChanList->chanParam[num_channel].half_rate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176 num_channel++;
1177 }
1178 }
1179
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +05301180 csr_add_social_channels(pMac, pChanList, pScan, &num_channel);
1181
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07001182 if (pMac->roam.configParam.early_stop_scan_enable)
Naveen Rawat16b82872015-12-14 17:59:16 -08001183 csr_roam_sort_channel_for_early_stop(pMac, pChanList,
1184 num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07001185 else
Abhishek Singh245182f2017-08-10 17:41:09 +05301186 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07001187 FL("Early Stop Scan Feature not supported"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001189 if ((pMac->roam.configParam.uCfgDot11Mode ==
1190 eCSR_CFG_DOT11_MODE_AUTO) ||
1191 (pMac->roam.configParam.uCfgDot11Mode ==
1192 eCSR_CFG_DOT11_MODE_11AC) ||
1193 (pMac->roam.configParam.uCfgDot11Mode ==
1194 eCSR_CFG_DOT11_MODE_11AC_ONLY)) {
1195 pChanList->vht_en = true;
1196 if (pMac->roam.configParam.enableVhtFor24GHz)
1197 pChanList->vht_24_en = true;
1198 }
1199 if ((pMac->roam.configParam.uCfgDot11Mode ==
1200 eCSR_CFG_DOT11_MODE_AUTO) ||
1201 (pMac->roam.configParam.uCfgDot11Mode ==
1202 eCSR_CFG_DOT11_MODE_11N) ||
1203 (pMac->roam.configParam.uCfgDot11Mode ==
1204 eCSR_CFG_DOT11_MODE_11N_ONLY)) {
1205 pChanList->ht_en = true;
1206 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207 msg.type = WMA_UPDATE_CHAN_LIST_REQ;
1208 msg.reserved = 0;
1209 msg.bodyptr = pChanList;
1210 pChanList->numChan = num_channel;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05301211 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
1212 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001213 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08001214 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301215 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 "%s: Failed to post msg to WMA", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301217 qdf_mem_free(pChanList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301218 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 }
1220
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301221 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222}
1223
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001224#ifdef QCA_SUPPORT_CP_STATS
1225static void csr_init_tl_stats(struct sAniSirGlobal *mac_ctx) {}
1226#else
1227static void csr_init_tl_stats(struct sAniSirGlobal *mac_ctx)
1228{
1229 mac_ctx->roam.tlStatsReqInfo.numClient = 0;
1230}
1231#endif /* QCA_SUPPORT_CP_STATS */
1232
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301233QDF_STATUS csr_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301235 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 uint32_t i;
1237
1238 do {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
1240 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_IDLE, i);
1241
1242 status = csr_roam_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301243 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 break;
1245
1246 pMac->roam.sPendingCommands = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
1248 status = csr_neighbor_roam_init(pMac, i);
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001249 csr_init_tl_stats(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301250 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001251 sme_warn("csr_start: Couldn't Init HO control blk ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 break;
1253 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -08001254 /* Register with scan component */
1255 pMac->scan.requester_id = ucfg_scan_register_requester(
1256 pMac->psoc,
1257 "CSR", csr_scan_callback, pMac);
wadesongd5477662018-04-25 17:00:47 +08001258 ucfg_scan_set_enable(pMac->psoc, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 } while (0);
1260 return status;
1261}
1262
Jeff Johnson62cd6802018-07-20 12:38:25 -07001263QDF_STATUS csr_stop(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264{
1265 uint32_t sessionId;
1266
wadesongd5477662018-04-25 17:00:47 +08001267 ucfg_scan_set_enable(pMac->psoc, false);
1268 ucfg_scan_unregister_requester(pMac->psoc, pMac->scan.requester_id);
1269
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301270 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
Krunal Soni8d184fa2017-11-20 21:52:05 -08001271 csr_roam_close_session(pMac, sessionId, true);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301272
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
1274 csr_neighbor_roam_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
1276 if (CSR_IS_SESSION_VALID(pMac, sessionId))
1277 csr_scan_flush_result(pMac);
1278
1279 /* Reset the domain back to the deault */
1280 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
1281
1282 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
1283 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, sessionId);
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +05301284 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
1285 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 }
1287
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301288 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289}
1290
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301291QDF_STATUS csr_ready(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301293 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 /* If the gScanAgingTime is set to '0' then scan results aging timeout
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301295 * based on timer feature is not enabled
1296 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 status = csr_apply_channel_and_power_list(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301298 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001299 sme_err("csr_apply_channel_and_power_list failed during csr_ready with status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 status);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301301
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 return status;
1303}
1304
1305void csr_set_default_dot11_mode(tpAniSirGlobal pMac)
1306{
1307 uint32_t wniDot11mode = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301308
1309 wniDot11mode = csr_translate_to_wni_cfg_dot11_mode(pMac,
1310 pMac->roam.configParam.uCfgDot11Mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 cfg_set_int(pMac, WNI_CFG_DOT11_MODE, wniDot11mode);
1312}
1313
1314void csr_set_global_cfgs(tpAniSirGlobal pMac)
1315{
1316
1317 cfg_set_int(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD,
1318 csr_get_frag_thresh(pMac));
1319 cfg_set_int(pMac, WNI_CFG_RTS_THRESHOLD, csr_get_rts_thresh(pMac));
1320 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301321 ((pMac->roam.configParam.Is11hSupportEnabled) ?
1322 pMac->roam.configParam.Is11dSupportEnabled :
1323 pMac->roam.configParam.Is11dSupportEnabled));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 cfg_set_int(pMac, WNI_CFG_11H_ENABLED,
1325 pMac->roam.configParam.Is11hSupportEnabled);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301326 /* For now we will just use the 5GHz CB mode ini parameter to decide
1327 * whether CB supported or not in Probes when there is no session
1328 * Once session is established we will use the session related params
1329 * stored in PE session for CB mode
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 */
1331 cfg_set_int(pMac, WNI_CFG_CHANNEL_BONDING_MODE,
1332 !!(pMac->roam.configParam.channelBondingMode5GHz));
1333 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
1334 pMac->roam.configParam.HeartbeatThresh24);
1335
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301336 /* Update the operating mode to configured value during
1337 * initialization, So that client can advertise full
1338 * capabilities in Probe request frame.
1339 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 csr_set_default_dot11_mode(pMac);
1341}
1342
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301343/**
1344 * csr_packetdump_timer_handler() - packet dump timer
1345 * handler
1346 * @pv: user data
1347 *
1348 * This function is used to handle packet dump timer
1349 *
1350 * Return: None
1351 *
1352 */
1353static void csr_packetdump_timer_handler(void *pv)
1354{
Abhishek Singh245182f2017-08-10 17:41:09 +05301355 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301356 "%s Invoking packetdump deregistration API", __func__);
1357 wlan_deregister_txrx_packetdump();
1358}
1359
1360/**
1361 * csr_packetdump_timer_stop() - stops packet dump timer
1362 *
1363 * This function is used to stop packet dump timer
1364 *
1365 * Return: None
1366 *
1367 */
1368void csr_packetdump_timer_stop(void)
1369{
1370 QDF_STATUS status;
1371 tHalHandle hal;
1372 tpAniSirGlobal mac;
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301373
1374 hal = cds_get_context(QDF_MODULE_ID_SME);
1375 if (hal == NULL) {
1376 QDF_ASSERT(0);
1377 return;
1378 }
1379
1380 mac = PMAC_STRUCT(hal);
1381 status = qdf_mc_timer_stop(&mac->roam.packetdump_timer);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301382 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001383 sme_err("cannot stop packetdump timer");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301384}
1385
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301386static QDF_STATUS csr_roam_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301388 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 uint32_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301390 struct csr_roam_session *pSession;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 do {
1393 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
1394 pSession = CSR_GET_SESSION(pMac, i);
1395 pSession->roamingTimerInfo.pMac = pMac;
1396 pSession->roamingTimerInfo.sessionId =
1397 CSR_SESSION_ID_INVALID;
1398 }
1399 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
1400 pMac->roam.WaitForKeyTimerInfo.sessionId =
1401 CSR_SESSION_ID_INVALID;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301402 status = qdf_mc_timer_init(&pMac->roam.hTimerWaitForKey,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301403 QDF_TIMER_TYPE_SW,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301404 csr_roam_wait_for_key_time_out_handler,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 &pMac->roam.WaitForKeyTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301406 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001407 sme_err("cannot allocate memory for WaitForKey time out timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 break;
1409 }
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301410 status = qdf_mc_timer_init(&pMac->roam.packetdump_timer,
1411 QDF_TIMER_TYPE_SW, csr_packetdump_timer_handler,
1412 pMac);
1413 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001414 sme_err("cannot allocate memory for packetdump timer");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301415 break;
1416 }
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +05301417 spin_lock_init(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418 } while (0);
1419 return status;
1420}
1421
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301422static QDF_STATUS csr_roam_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423{
1424 uint32_t sessionId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301425
1426 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
Krunal Soni8d184fa2017-11-20 21:52:05 -08001427 csr_roam_close_session(pMac, sessionId, true);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301428
Anurag Chouhan210db072016-02-22 18:42:15 +05301429 qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
1430 qdf_mc_timer_destroy(&pMac->roam.hTimerWaitForKey);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301431 qdf_mc_timer_stop(&pMac->roam.packetdump_timer);
1432 qdf_mc_timer_destroy(&pMac->roam.packetdump_timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301433 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434}
1435
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301436QDF_STATUS csr_roam_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437{
1438 (void)pMac;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301439 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440}
1441
1442void csr_roam_stop(tpAniSirGlobal pMac, uint32_t sessionId)
1443{
1444 csr_roam_stop_roaming_timer(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301445 /* deregister the clients requesting stats from PE/TL & also stop
1446 * the corresponding timers
1447 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 csr_roam_dereg_statistics_req(pMac);
1449}
1450
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301451QDF_STATUS csr_roam_get_connect_state(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 eCsrConnectState *pState)
1453{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301454 QDF_STATUS status = QDF_STATUS_E_INVAL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 if (CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301457 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 *pState = pMac->roam.roamSession[sessionId].connectState;
1459 }
1460 return status;
1461}
1462
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301463QDF_STATUS csr_roam_copy_connect_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 uint32_t sessionId, tCsrRoamConnectedProfile *pProfile)
1465{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301466 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 uint32_t size = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301468 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 tCsrRoamConnectedProfile *connected_prof;
1470
1471 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001472 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301473 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 }
1475 if (!pProfile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001476 sme_err("profile not found");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301477 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 }
1479
1480 if (pSession->pConnectBssDesc) {
1481 size = pSession->pConnectBssDesc->length +
1482 sizeof(pSession->pConnectBssDesc->length);
1483 if (size) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301484 pProfile->pBssDesc = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 if (NULL != pProfile->pBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301486 qdf_mem_copy(pProfile->pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 pSession->pConnectBssDesc,
1488 size);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301489 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301491 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 }
1493 } else {
1494 pProfile->pBssDesc = NULL;
1495 }
1496 connected_prof = &(pSession->connectedProfile);
1497 pProfile->AuthType = connected_prof->AuthType;
1498 pProfile->EncryptionType = connected_prof->EncryptionType;
1499 pProfile->mcEncryptionType = connected_prof->mcEncryptionType;
1500 pProfile->BSSType = connected_prof->BSSType;
1501 pProfile->operationChannel = connected_prof->operationChannel;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301502 qdf_mem_copy(&pProfile->bssid, &connected_prof->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301503 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301504 qdf_mem_copy(&pProfile->SSID, &connected_prof->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 if (connected_prof->MDID.mdiePresent) {
1507 pProfile->MDID.mdiePresent = 1;
1508 pProfile->MDID.mobilityDomain =
1509 connected_prof->MDID.mobilityDomain;
1510 } else {
1511 pProfile->MDID.mdiePresent = 0;
1512 pProfile->MDID.mobilityDomain = 0;
1513 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514#ifdef FEATURE_WLAN_ESE
1515 pProfile->isESEAssoc = connected_prof->isESEAssoc;
1516 if (csr_is_auth_type_ese(connected_prof->AuthType)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301517 qdf_mem_copy(pProfile->eseCckmInfo.krk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 connected_prof->eseCckmInfo.krk,
1519 SIR_KRK_KEY_LEN);
1520#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301521 qdf_mem_copy(pProfile->eseCckmInfo.btk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 connected_prof->eseCckmInfo.btk,
1523 SIR_BTK_KEY_LEN);
1524#endif
1525 pProfile->eseCckmInfo.reassoc_req_num =
1526 connected_prof->eseCckmInfo.reassoc_req_num;
1527 pProfile->eseCckmInfo.krk_plumbed =
1528 connected_prof->eseCckmInfo.krk_plumbed;
1529 }
1530#endif
Krunal Sonib2f13042015-11-02 18:41:08 -08001531#ifdef WLAN_FEATURE_11W
1532 pProfile->MFPEnabled = connected_prof->MFPEnabled;
1533 pProfile->MFPRequired = connected_prof->MFPRequired;
1534 pProfile->MFPCapable = connected_prof->MFPCapable;
1535#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 }
1537 return status;
1538}
1539
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301540QDF_STATUS csr_roam_get_connect_profile(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 tCsrRoamConnectedProfile *pProfile)
1542{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301543 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544
1545 if ((csr_is_conn_state_connected(pMac, sessionId)) ||
1546 (csr_is_conn_state_ibss(pMac, sessionId))) {
1547 if (pProfile) {
1548 status =
1549 csr_roam_copy_connect_profile(pMac, sessionId,
1550 pProfile);
1551 }
1552 }
1553 return status;
1554}
1555
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001556void csr_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557{
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001558 if (profile->pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301559 qdf_mem_free(profile->pBssDesc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001560 if (profile->pAddIEAssoc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301561 qdf_mem_free(profile->pAddIEAssoc);
1562 qdf_mem_set(profile, sizeof(tCsrRoamConnectedProfile), 0);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001563 profile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564}
1565
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301566static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301567 struct csr_roam_connectedinfo *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 pConnectedInfo)
1569{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301570 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 if (pConnectedInfo->pbFrames) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301573 qdf_mem_free(pConnectedInfo->pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 pConnectedInfo->pbFrames = NULL;
1575 }
1576 pConnectedInfo->nBeaconLength = 0;
1577 pConnectedInfo->nAssocReqLength = 0;
1578 pConnectedInfo->nAssocRspLength = 0;
1579 pConnectedInfo->staId = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 pConnectedInfo->nRICRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581#ifdef FEATURE_WLAN_ESE
1582 pConnectedInfo->nTspecIeLength = 0;
1583#endif
1584 return status;
1585}
1586
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587void csr_release_command_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1588{
1589 csr_reinit_roam_cmd(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590}
1591
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301592void csr_release_command_wm_status_change(tpAniSirGlobal pMac,
1593 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594{
1595 csr_reinit_wm_status_change_cmd(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596}
1597
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301598void csr_roam_substate_change(tpAniSirGlobal pMac,
1599 enum csr_roam_substate NewSubstate, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600{
Abhinav Kumar43ab01b2018-06-26 19:06:56 +05301601 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1602 sme_err("Invalid no of concurrent sessions %d",
1603 sessionId);
1604 return;
1605 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001606 sme_debug("CSR RoamSubstate: [ %s <== %s ]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 mac_trace_getcsr_roam_sub_state(NewSubstate),
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301608 mac_trace_getcsr_roam_sub_state(pMac->roam.
1609 curSubState[sessionId]));
1610 if (pMac->roam.curSubState[sessionId] == NewSubstate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 return;
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +05301612 spin_lock(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 pMac->roam.curSubState[sessionId] = NewSubstate;
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +05301614 spin_unlock(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615}
1616
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301617enum csr_roam_state csr_roam_state_change(tpAniSirGlobal pMac,
1618 enum csr_roam_state NewRoamState,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301619 uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301621 enum csr_roam_state PreviousState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001623 sme_debug("CSR RoamState[%hu]: [ %s <== %s ]", sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 mac_trace_getcsr_roam_state(NewRoamState),
1625 mac_trace_getcsr_roam_state(pMac->roam.curState[sessionId]));
1626 PreviousState = pMac->roam.curState[sessionId];
1627
1628 if (NewRoamState != pMac->roam.curState[sessionId]) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301629 /* Whenever we transition OUT of the Roaming state,
1630 * clear the Roaming substate.
1631 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 if (CSR_IS_ROAM_JOINING(pMac, sessionId)) {
1633 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
1634 sessionId);
1635 }
1636
1637 pMac->roam.curState[sessionId] = NewRoamState;
1638 }
1639 return PreviousState;
1640}
1641
1642void csr_assign_rssi_for_category(tpAniSirGlobal pMac, int8_t bestApRssi,
1643 uint8_t catOffset)
1644{
1645 int i;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001646
1647 sme_debug("best AP RSSI: %d cat offset: %d", bestApRssi, catOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 if (catOffset) {
1649 pMac->roam.configParam.bCatRssiOffset = catOffset;
1650 for (i = 0; i < CSR_NUM_RSSI_CAT; i++) {
1651 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i -
1652 1] =
1653 (int)bestApRssi -
1654 pMac->roam.configParam.nSelect5GHzMargin -
1655 (int)(i * catOffset);
1656 }
1657 }
1658}
1659
1660static void init_config_param(tpAniSirGlobal pMac)
1661{
1662 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301663
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
1665 pMac->roam.configParam.channelBondingMode24GHz =
1666 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1667 pMac->roam.configParam.channelBondingMode5GHz =
1668 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
1669
1670 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_AUTO;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001671 pMac->roam.configParam.eBand = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
1673 pMac->roam.configParam.FragmentationThreshold =
1674 eCSR_DOT11_FRAG_THRESH_DEFAULT;
1675 pMac->roam.configParam.HeartbeatThresh24 = 40;
1676 pMac->roam.configParam.HeartbeatThresh50 = 40;
1677 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 pMac->roam.configParam.Is11eSupportEnabled = true;
1679 pMac->roam.configParam.Is11hSupportEnabled = true;
1680 pMac->roam.configParam.RTSThreshold = 2346;
1681 pMac->roam.configParam.shortSlotTime = true;
1682 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1683 pMac->roam.configParam.ProprietaryRatesEnabled = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301684 for (i = 0; i < CSR_NUM_RSSI_CAT; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 pMac->roam.configParam.BssPreferValue[i] = i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 csr_assign_rssi_for_category(pMac, CSR_BEST_RSSI_VALUE,
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08001687 CSR_DEFAULT_RSSI_DB_GAP);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = false;
1689 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 pMac->roam.configParam.nPassiveMaxChnTime =
1691 CSR_PASSIVE_MAX_CHANNEL_TIME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 pMac->roam.configParam.nActiveMaxChnTimeConc =
1693 CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1694 pMac->roam.configParam.nActiveMinChnTimeConc =
1695 CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1696 pMac->roam.configParam.nPassiveMaxChnTimeConc =
1697 CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1698 pMac->roam.configParam.nPassiveMinChnTimeConc =
1699 CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1700 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301701 pMac->roam.configParam.min_rest_time_conc = CSR_MIN_REST_TIME_CONC;
1702 pMac->roam.configParam.idle_time_conc = CSR_IDLE_TIME_CONC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301704 pMac->roam.configParam.allow_tpc_from_ap = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 pMac->roam.configParam.statsReqPeriodicity =
1706 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1707 pMac->roam.configParam.statsReqPeriodicityInPS =
1708 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1710 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
1711 120;
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -07001712 pMac->roam.configParam.neighborRoamConfig.rssi_thresh_offset_5g = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 pMac->roam.configParam.neighborRoamConfig.nOpportunisticThresholdDiff =
1714 30;
1715 pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff = 5;
1716 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1717 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1718 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod =
1719 200;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05301720 pMac->roam.configParam.neighborRoamConfig.
1721 neighbor_scan_min_timer_period = 200;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1723 numChannels = 3;
1724 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1725 channelList[0] = 1;
1726 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1727 channelList[1] = 6;
1728 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1729 channelList[2] = 11;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301730 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod
1731 = 20000; /* 20 seconds */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
1733 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt = 10;
1734 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt = 10;
1735 pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight = 14;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 pMac->roam.configParam.nVhtChannelWidth =
1737 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738
1739 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1740 pMac->roam.configParam.fScanTwice = false;
1741
1742 /* Remove this code once SLM_Sessionization is supported */
1743 /* BMPS_WORKAROUND_NOT_NEEDED */
1744 pMac->roam.configParam.doBMPSWorkaround = 0;
1745
1746 pMac->roam.configParam.nInitialDwellTime = 0;
1747 pMac->roam.configParam.initial_scan_no_dfs_chnl = 0;
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07001748 pMac->roam.configParam.csr_mawc_config.mawc_enabled = true;
1749 pMac->roam.configParam.csr_mawc_config.mawc_roam_enabled = true;
1750 pMac->roam.configParam.csr_mawc_config.mawc_roam_traffic_threshold =
1751 MAWC_ROAM_TRAFFIC_THRESHOLD_DEFAULT;
1752 pMac->roam.configParam.csr_mawc_config.mawc_roam_ap_rssi_threshold =
1753 MAWC_ROAM_AP_RSSI_THRESHOLD_DEFAULT;
1754 pMac->roam.configParam.csr_mawc_config.mawc_roam_rssi_high_adjust =
1755 MAWC_ROAM_RSSI_HIGH_ADJUST_DEFAULT;
1756 pMac->roam.configParam.csr_mawc_config.mawc_roam_rssi_low_adjust =
1757 MAWC_ROAM_RSSI_LOW_ADJUST_DEFAULT;
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05301758
1759 qdf_mem_zero(&pMac->roam.configParam.bss_score_params,
1760 sizeof(struct sir_score_config));
1761 pMac->roam.configParam.bss_score_params.weight_cfg.rssi_weightage =
1762 RSSI_WEIGHTAGE;
1763 pMac->roam.configParam.bss_score_params.weight_cfg.ht_caps_weightage =
1764 HT_CAPABILITY_WEIGHTAGE;
1765 pMac->roam.configParam.bss_score_params.weight_cfg.vht_caps_weightage =
1766 VHT_CAP_WEIGHTAGE;
1767 pMac->roam.configParam.bss_score_params.
1768 weight_cfg.chan_width_weightage = CHAN_WIDTH_WEIGHTAGE;
1769 pMac->roam.configParam.bss_score_params.
1770 weight_cfg.chan_band_weightage = CHAN_BAND_WEIGHTAGE;
1771 pMac->roam.configParam.bss_score_params.weight_cfg.nss_weightage =
1772 NSS_WEIGHTAGE;
1773 pMac->roam.configParam.bss_score_params.weight_cfg.
1774 beamforming_cap_weightage = BEAMFORMING_CAP_WEIGHTAGE;
1775 pMac->roam.configParam.bss_score_params.weight_cfg.pcl_weightage =
1776 PCL_WEIGHT;
1777 pMac->roam.configParam.bss_score_params.weight_cfg.
1778 channel_congestion_weightage = CHANNEL_CONGESTION_WEIGHTAGE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779}
1780
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001781enum band_info csr_get_current_band(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782{
1783 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 return pMac->roam.configParam.bandCapability;
1786}
1787
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301788/* This function flushes the roam scan cache */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301789QDF_STATUS csr_flush_cfg_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 uint8_t sessionId)
1791{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301792 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1795 &pMac->roam.neighborRoamInfo[sessionId];
1796
1797 /* Free up the memory first (if required) */
1798 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301799 qdf_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 ChannelList);
1801 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
1802 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1803 }
1804 return status;
1805}
1806
1807/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301808 * This function flushes the roam scan cache and creates fresh cache
1809 * based on the input channel list
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301811QDF_STATUS csr_create_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 uint8_t sessionId,
1813 const uint8_t *pChannelList,
1814 const uint8_t numChannels)
1815{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301816 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1818 &pMac->roam.neighborRoamInfo[sessionId];
1819
1820 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1821
1822 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301823 qdf_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824 numOfChannels);
1825
1826 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001827 sme_err("Memory Allocation for CFG Channel List failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301829 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 }
1831
1832 /* Update the roam global structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301833 qdf_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 pChannelList,
1835 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1836 return status;
1837}
1838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001840#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001841/**
1842 * csr_create_roam_scan_channel_list() - create roam scan channel list
1843 * @pMac: Global mac pointer
1844 * @sessionId: session id
1845 * @pChannelList: pointer to channel list
1846 * @numChannels: number of channels
1847 * @eBand: band enumeration
1848 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 * This function modifies the roam scan channel list as per AP neighbor
1850 * report; AP neighbor report may be empty or may include only other AP
1851 * channels; in any case, we merge the channel list with the learned occupied
1852 * channels list.
1853 * if the band is 2.4G, then make sure channel list contains only 2.4G
1854 * valid channels if the band is 5G, then make sure channel list contains
1855 * only 5G valid channels
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001856 *
1857 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301859QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 uint8_t sessionId,
1861 uint8_t *pChannelList,
1862 uint8_t numChannels,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001863 const enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301865 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 tpCsrNeighborRoamControlInfo pNeighborRoamInfo
1868 = &pMac->roam.neighborRoamInfo[sessionId];
1869 uint8_t outNumChannels = 0;
1870 uint8_t inNumChannels = numChannels;
1871 uint8_t *inPtr = pChannelList;
1872 uint8_t i = 0;
1873 uint8_t ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1874 uint8_t tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1875 uint8_t mergedOutputNumOfChannels = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 tpCsrChannelInfo currChannelListInfo
1878 = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1879 /*
1880 * Create a Union of occupied channel list learnt by the DUT along
1881 * with the Neighbor report Channels. This increases the chances of
1882 * the DUT to get a candidate AP while roaming even if the Neighbor
1883 * Report is not able to provide sufficient information.
1884 */
1885 if (pMac->scan.occupiedChannels[sessionId].numChannels) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301886 csr_neighbor_roam_merge_channel_lists(pMac, &pMac->scan.
1887 occupiedChannels[sessionId].
1888 channelList[0], pMac->scan.
1889 occupiedChannels[sessionId].
1890 numChannels, inPtr,
1891 inNumChannels,
1892 &mergedOutputNumOfChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 inNumChannels = mergedOutputNumOfChannels;
1894 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001895 if (BAND_2G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 for (i = 0; i < inNumChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001897 if (WLAN_REG_IS_24GHZ_CH(inPtr[i])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 && csr_roam_is_channel_valid(pMac, inPtr[i])) {
1899 ChannelList[outNumChannels++] = inPtr[i];
1900 }
1901 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001902 } else if (BAND_5G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 for (i = 0; i < inNumChannels; i++) {
1904 /* Add 5G Non-DFS channel */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001905 if (WLAN_REG_IS_5GHZ_CH(inPtr[i]) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 csr_roam_is_channel_valid(pMac, inPtr[i]) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001907 !wlan_reg_is_dfs_ch(pMac->pdev, inPtr[i])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 ChannelList[outNumChannels++] = inPtr[i];
1909 }
1910 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001911 } else if (BAND_ALL == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 for (i = 0; i < inNumChannels; i++) {
1913 if (csr_roam_is_channel_valid(pMac, inPtr[i]) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001914 !wlan_reg_is_dfs_ch(pMac->pdev, inPtr[i])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 ChannelList[outNumChannels++] = inPtr[i];
1916 }
1917 }
1918 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301919 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920 "Invalid band, No operation carried out (Band %d)",
1921 eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301922 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 }
1924 /*
1925 * if roaming within band is enabled, then select only the
1926 * in band channels .
1927 * This is required only if the band capability is set to ALL,
1928 * E.g., if band capability is only 2.4G then all the channels in the
1929 * list are already filtered for 2.4G channels, hence ignore this check
1930 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001931 if ((BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 csr_neighbor_roam_channels_filter_by_current_band(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301933 sessionId,
1934 ChannelList,
1935 outNumChannels,
1936 tmpChannelList,
1937 &outNumChannels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301938 qdf_mem_copy(ChannelList, tmpChannelList, outNumChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 }
1940 /* Prepare final roam scan channel list */
1941 if (outNumChannels) {
1942 /* Clear the channel list first */
1943 if (NULL != currChannelListInfo->ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301944 qdf_mem_free(currChannelListInfo->ChannelList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 currChannelListInfo->ChannelList = NULL;
1946 currChannelListInfo->numOfChannels = 0;
1947 }
1948 currChannelListInfo->ChannelList
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301949 = qdf_mem_malloc(outNumChannels * sizeof(uint8_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 if (NULL == currChannelListInfo->ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301951 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 "Failed to allocate memory for roam scan channel list");
1953 currChannelListInfo->numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301954 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301956 qdf_mem_copy(currChannelListInfo->ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 ChannelList, outNumChannels);
1958 }
1959 return status;
1960}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001961
1962/**
1963 * csr_roam_is_ese_assoc() - is this ese association
1964 * @mac_ctx: Global MAC context
1965 * @session_id: session identifier
1966 *
1967 * Returns whether the current association is a ESE assoc or not.
1968 *
1969 * Return: true if ese association; false otherwise
1970 */
Selvaraj, Sridharbc950df2016-07-05 15:35:47 +05301971bool csr_roam_is_ese_assoc(tpAniSirGlobal mac_ctx, uint32_t session_id)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001972{
Srinivas Girigowda18dcf3d2015-12-16 18:11:48 -08001973 return mac_ctx->roam.neighborRoamInfo[session_id].isESEAssoc;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001974}
1975
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001976
1977/**
1978 * csr_roam_is_ese_ini_feature_enabled() - is ese feature enabled
1979 * @mac_ctx: Global MAC context
1980 *
1981 * Return: true if ese feature is enabled; false otherwise
1982 */
1983bool csr_roam_is_ese_ini_feature_enabled(tpAniSirGlobal pMac)
1984{
1985 return pMac->roam.configParam.isEseIniFeatureEnabled;
1986}
1987
1988/**
1989 * csr_tsm_stats_rsp_processor() - tsm stats response processor
1990 * @pMac: Global MAC context
1991 * @pMsg: Message pointer
1992 *
1993 * Return: None
1994 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07001995static void csr_tsm_stats_rsp_processor(tpAniSirGlobal pMac, void *pMsg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001996{
1997 tAniGetTsmStatsRsp *pTsmStatsRsp = (tAniGetTsmStatsRsp *) pMsg;
1998
1999 if (NULL != pTsmStatsRsp) {
2000 /*
2001 * Get roam Rssi request is backed up and passed back
2002 * to the response, Extract the request message
2003 * to fetch callback.
2004 */
2005 tpAniGetTsmStatsReq reqBkp
2006 = (tAniGetTsmStatsReq *) pTsmStatsRsp->tsmStatsReq;
2007
2008 if (NULL != reqBkp) {
2009 if (NULL != reqBkp->tsmStatsCallback) {
2010 ((tCsrTsmStatsCallback)
2011 (reqBkp->tsmStatsCallback))(pTsmStatsRsp->
2012 tsmMetrics,
2013 pTsmStatsRsp->
2014 staId,
2015 reqBkp->
2016 pDevContext);
2017 reqBkp->tsmStatsCallback = NULL;
2018 }
2019 qdf_mem_free(reqBkp);
2020 pTsmStatsRsp->tsmStatsReq = NULL;
2021 } else {
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002022 if (NULL != reqBkp) {
2023 qdf_mem_free(reqBkp);
2024 pTsmStatsRsp->tsmStatsReq = NULL;
2025 }
2026 }
2027 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002028 sme_err("pTsmStatsRsp is NULL");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002029 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002030}
2031
2032/**
2033 * csr_send_ese_adjacent_ap_rep_ind() - ese send adjacent ap report
2034 * @pMac: Global MAC context
2035 * @pSession: Session pointer
2036 *
2037 * Return: None
2038 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07002039static void csr_send_ese_adjacent_ap_rep_ind(tpAniSirGlobal pMac,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302040 struct csr_roam_session *pSession)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002041{
2042 uint32_t roamTS2 = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08002043 struct csr_roam_info roamInfo;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002044 tpPESession pSessionEntry = NULL;
2045 uint8_t sessionId = CSR_SESSION_ID_INVALID;
2046
2047 if (NULL == pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002048 sme_err("pSession is NULL");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002049 return;
2050 }
2051
2052 roamTS2 = qdf_mc_timer_get_system_time();
2053 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002054 sme_debug("Bssid(" MAC_ADDRESS_STR ") Roaming Delay(%u ms)",
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002055 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid.bytes),
2056 roamInfo.tsmRoamDelay);
2057
2058 pSessionEntry = pe_find_session_by_bssid(pMac,
2059 pSession->connectedProfile.bssid.bytes,
2060 &sessionId);
2061 if (NULL == pSessionEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002062 sme_err("session %d not found", sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002063 return;
2064 }
2065
2066 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly
2067 = roamInfo.tsmRoamDelay;
2068
2069 csr_roam_call_callback(pMac, pSession->sessionId, &roamInfo,
2070 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
2071}
2072
2073/**
2074 * csr_get_tsm_stats() - get tsm stats
2075 * @pMac: Global MAC context
2076 * @callback: TSM stats callback
2077 * @staId: Station id
2078 * @bssId: bssid
2079 * @pContext: pointer to context
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002080 * @tid: traffic id
2081 *
2082 * Return: QDF_STATUS enumeration
2083 */
2084QDF_STATUS csr_get_tsm_stats(tpAniSirGlobal pMac,
2085 tCsrTsmStatsCallback callback,
2086 uint8_t staId,
2087 struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07002088 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002089{
2090 QDF_STATUS status = QDF_STATUS_SUCCESS;
2091 tAniGetTsmStatsReq *pMsg = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302092
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002093 pMsg = qdf_mem_malloc(sizeof(tAniGetTsmStatsReq));
2094 if (!pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002095 sme_err(
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002096 "csr_get_tsm_stats: failed to allocate mem for req");
2097 return QDF_STATUS_E_NOMEM;
2098 }
2099 /* need to initiate a stats request to PE */
2100 pMsg->msgType = eWNI_SME_GET_TSM_STATS_REQ;
2101 pMsg->msgLen = (uint16_t) sizeof(tAniGetTsmStatsReq);
2102 pMsg->staId = staId;
2103 pMsg->tid = tid;
2104 qdf_copy_macaddr(&pMsg->bssId, &bssId);
2105 pMsg->tsmStatsCallback = callback;
2106 pMsg->pDevContext = pContext;
Rajeev Kumard138ac52017-01-30 18:38:37 -08002107 status = umac_send_mb_message_to_mac(pMsg);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002108 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002109 sme_debug("csr_get_tsm_stats: failed to send down the rssi req");
2110 /* pMsg is freed by cds_send_mb_message_to_mac */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002111 status = QDF_STATUS_E_FAILURE;
2112 }
2113 return status;
2114}
2115
Paul Zhangc3fc0a82018-01-09 16:38:20 +08002116
2117#if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002118/**
2119 * csr_fetch_ch_lst_from_received_list() - fetch channel list from received list
2120 * and update req msg
Jeff Johnson60ed45a2018-05-06 15:28:49 -07002121 * parameters
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002122 * @mac_ctx: global mac ctx
2123 * @roam_info: roam info struct
2124 * @curr_ch_lst_info: current channel list info
2125 * @req_buf: out param, roam offload scan request packet
2126 *
2127 * Return: void
2128 */
2129static void
2130csr_fetch_ch_lst_from_received_list(tpAniSirGlobal mac_ctx,
2131 tpCsrNeighborRoamControlInfo roam_info,
2132 tpCsrChannelInfo curr_ch_lst_info,
2133 tSirRoamOffloadScanReq *req_buf)
2134{
2135 uint8_t i = 0;
2136 uint8_t num_channels = 0;
2137 uint8_t *ch_lst = NULL;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302138 uint16_t unsafe_chan[NUM_CHANNELS];
2139 uint16_t unsafe_chan_cnt = 0;
2140 uint16_t cnt = 0;
2141 bool is_unsafe_chan;
2142 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
2143
2144 if (!qdf_ctx) {
2145 cds_err("qdf_ctx is NULL");
2146 return;
2147 }
2148 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
2149 &unsafe_chan_cnt,
2150 sizeof(unsafe_chan));
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002151
2152 if (curr_ch_lst_info->numOfChannels == 0)
2153 return;
2154
2155 ch_lst = curr_ch_lst_info->ChannelList;
2156 for (i = 0; i < curr_ch_lst_info->numOfChannels; i++) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302157 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
2158 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
2159 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002160 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002161 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
2162 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302163 ch_lst++;
2164 continue;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002165 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302166
2167 if (mac_ctx->roam.configParam.sta_roam_policy.
2168 skip_unsafe_channels &&
2169 unsafe_chan_cnt) {
2170 is_unsafe_chan = false;
2171 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
2172 if (unsafe_chan[cnt] == *ch_lst) {
2173 is_unsafe_chan = true;
2174 break;
2175 }
2176 }
2177 if (is_unsafe_chan) {
2178 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002179 QDF_TRACE_LEVEL_DEBUG,
2180 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302181 *ch_lst);
2182 ch_lst++;
2183 continue;
2184 }
2185 }
2186 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
2187 *ch_lst;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002188 ch_lst++;
2189 }
2190 req_buf->ConnectedNetwork.ChannelCount = num_channels;
Himanshu Agarwalb23aa572018-06-14 17:04:44 +05302191 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002192}
Paul Zhangc3fc0a82018-01-09 16:38:20 +08002193#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002194
2195/**
2196 * csr_set_cckm_ie() - set CCKM IE
2197 * @pMac: Global MAC context
2198 * @sessionId: session identifier
2199 * @pCckmIe: Pointer to input CCKM IE data
2200 * @ccKmIeLen: Length of @pCckmIe
2201 *
2202 * This function stores the CCKM IE passed by the supplicant
2203 * in a place holder data structure and this IE will be packed inside
2204 * reassociation request
2205 *
2206 * Return: QDF_STATUS enumeration
2207 */
2208QDF_STATUS csr_set_cckm_ie(tpAniSirGlobal pMac, const uint8_t sessionId,
2209 const uint8_t *pCckmIe, const uint8_t ccKmIeLen)
2210{
2211 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302212 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302213
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002214 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002215 sme_err("session %d not found", sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002216 return QDF_STATUS_E_FAILURE;
2217 }
2218 qdf_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
2219 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
2220 return status;
2221}
2222
2223/**
2224 * csr_roam_read_tsf() - read TSF
2225 * @pMac: Global MAC context
2226 * @sessionId: session identifier
2227 * @pTimestamp: output TSF timestamp
2228 *
2229 * This function reads the TSF; and also add the time elapsed since
2230 * last beacon or probe response reception from the hand off AP to arrive at
2231 * the latest TSF value.
2232 *
2233 * Return: QDF_STATUS enumeration
2234 */
2235QDF_STATUS csr_roam_read_tsf(tpAniSirGlobal pMac, uint8_t *pTimestamp,
2236 uint8_t sessionId)
2237{
2238 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar258594c2016-07-31 15:17:45 +05302239 tCsrNeighborRoamBSSInfo handoffNode = {{0} };
Arun Khandavalli8a711cb2017-01-03 20:23:56 +05302240 uint64_t timer_diff = 0;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002241 uint32_t timeStamp[2];
2242 tpSirBssDescription pBssDescription = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302243
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002244 csr_neighbor_roam_get_handoff_ap_info(pMac, &handoffNode, sessionId);
gaurank kathpalia2b6f5072018-07-03 11:45:06 +05302245 if (!handoffNode.pBssDescription) {
2246 sme_err("Invalid BSS Description");
2247 return QDF_STATUS_E_INVAL;
2248 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002249 pBssDescription = handoffNode.pBssDescription;
Arun Khandavalli8a711cb2017-01-03 20:23:56 +05302250 /* Get the time diff in nano seconds */
2251 timer_diff = (qdf_get_monotonic_boottime_ns() -
2252 pBssDescription->scansystimensec);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002253 /* Convert msec to micro sec timer */
Sarada Prasanna Garnayakf21c2962017-03-08 20:42:38 +05302254 timer_diff = do_div(timer_diff, SYSTEM_TIME_NSEC_TO_USEC);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002255 timeStamp[0] = pBssDescription->timeStamp[0];
2256 timeStamp[1] = pBssDescription->timeStamp[1];
2257 update_cckmtsf(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
2258 qdf_mem_copy(pTimestamp, (void *)&timeStamp[0], sizeof(uint32_t) * 2);
2259 return status;
2260}
2261
2262#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263
Mahesh Kumar Kalikot Veetil40575112016-09-09 16:57:08 -07002264/**
2265 * csr_roam_is_roam_offload_scan_enabled() - is roam offload enabled
2266 * @mac_ctx: Global MAC context
2267 *
2268 * Returns whether firmware based background scan is currently enabled or not.
2269 *
2270 * Return: true if roam offload scan enabled; false otherwise
2271 */
2272bool csr_roam_is_roam_offload_scan_enabled(tpAniSirGlobal mac_ctx)
2273{
2274 return mac_ctx->roam.configParam.isRoamOffloadScanEnabled;
2275}
2276
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002277QDF_STATUS csr_set_band(tHalHandle hHal, uint8_t sessionId,
2278 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279{
2280 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302281 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302282
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002283 if (CSR_IS_PHY_MODE_A_ONLY(pMac) && (eBand == BAND_2G)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 /* DOT11 mode configured to 11a only and received
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302285 * request to change the band to 2.4 GHz
2286 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302287 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288 "failed to set band cfg80211 = %u, band = %u",
2289 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302290 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 }
2292 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002293 CSR_IS_PHY_MODE_G_ONLY(pMac)) && (eBand == BAND_5G)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 /* DOT11 mode configured to 11b/11g only and received
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302295 * request to change the band to 5 GHz
2296 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302297 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 "failed to set band dot11mode = %u, band = %u",
2299 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302300 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 }
Abhishek Singh245182f2017-08-10 17:41:09 +05302302 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
2304 pMac->roam.configParam.eBand = eBand;
2305 pMac->roam.configParam.bandCapability = eBand;
2306
2307 status = csr_get_channel_and_power_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302308 if (QDF_STATUS_SUCCESS == status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 csr_apply_channel_and_power_list(pMac);
2310 return status;
2311}
2312
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302313/* The funcns csr_convert_cb_ini_value_to_phy_cb_state and
2314 * csr_convert_phy_cb_state_to_ini_value have been introduced
2315 * to convert the ini value to the ENUM used in csr and MAC for CB state
2316 * Ideally we should have kept the ini value and enum value same and
2317 * representing the same cb values as in 11n standard i.e.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 * Set to 1 (SCA) if the secondary channel is above the primary channel
2319 * Set to 3 (SCB) if the secondary channel is below the primary channel
2320 * Set to 0 (SCN) if no secondary channel is present
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302321 * However, since our driver is already distributed we will keep the ini
2322 * definition as it is which is:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 * 0 - secondary none
2324 * 1 - secondary LOW
2325 * 2 - secondary HIGH
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302326 * and convert to enum value used within the driver in
2327 * csr_change_default_config_param using this funcn
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 * The enum values are as follows:
2329 * PHY_SINGLE_CHANNEL_CENTERED = 0
2330 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
2331 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
2332 */
2333ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue)
2334{
2335
2336 ePhyChanBondState phyCbState;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302337
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338 switch (cbIniValue) {
2339 /* secondary none */
2340 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
2341 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
2342 break;
2343 /* secondary LOW */
2344 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
2345 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2346 break;
2347 /* secondary HIGH */
2348 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
2349 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2350 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
2352 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
2353 break;
2354 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
2355 phyCbState =
2356 PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
2357 break;
2358 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
2359 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
2360 break;
2361 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
2362 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
2363 break;
2364 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
2365 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
2366 break;
2367 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
2368 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
2369 break;
2370 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
2371 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
2372 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373 default:
2374 /* If an invalid value is passed, disable CHANNEL BONDING */
2375 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
2376 break;
2377 }
2378 return phyCbState;
2379}
2380
Jeff Johnson29e2ca12016-10-14 12:50:38 -07002381static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382uint32_t csr_convert_phy_cb_state_to_ini_value(ePhyChanBondState phyCbState)
2383{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 uint32_t cbIniValue;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302385
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 switch (phyCbState) {
2387 /* secondary none */
2388 case PHY_SINGLE_CHANNEL_CENTERED:
2389 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
2390 break;
2391 /* secondary LOW */
2392 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
2393 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
2394 break;
2395 /* secondary HIGH */
2396 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
2397 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
2398 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
2400 cbIniValue =
2401 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
2402 break;
2403 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
2404 cbIniValue =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302405 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 break;
2407 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
2408 cbIniValue =
2409 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
2410 break;
2411 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
2412 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
2413 break;
2414 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
2415 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
2416 break;
2417 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
2418 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
2419 break;
2420 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
2421 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
2422 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 default:
2424 /* return some invalid value */
2425 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
2426 break;
2427 }
2428 return cbIniValue;
2429}
2430
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002431#ifdef WLAN_FEATURE_11AX
Jinwei Chen998a1a02018-06-20 17:20:34 +08002432#define CSR_REVISE_REQ_HE_CAP_PER_BAND(_req, _pmac, _channelid) \
2433 (_req)->he_config.bfee_sts_lt_80 = WLAN_CHAN_IS_2GHZ((_channelid)) ? \
2434 (_pmac)->he_cap_2g.bfee_sts_lt_80 : \
2435 (_pmac)->he_cap_5g.bfee_sts_lt_80
2436
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002437/**
2438 * csr_update_he_config_param() - Update MAC context with HE config param
2439 * @mac_ctx: pointer to MAC context
2440 * @param: pointer to CSR config params
2441 *
2442 * Return: None
2443 */
2444static void csr_update_he_config_param(tpAniSirGlobal mac_ctx,
2445 tCsrConfigParam *param)
2446{
2447 mac_ctx->roam.configParam.enable_ul_ofdma = param->enable_ul_ofdma;
2448 mac_ctx->roam.configParam.enable_ul_mimo = param->enable_ul_mimo;
2449}
2450
2451/**
2452 * csr_get_he_config_param() - Get HE config param from MAC context
2453 * @param: pointer to CSR config params
2454 * @mac_ctx: pointer to MAC context
2455 *
2456 * Return: None
2457 */
2458static void csr_get_he_config_param(tCsrConfigParam *param,
2459 tpAniSirGlobal mac_ctx)
2460{
2461 param->enable_ul_ofdma = mac_ctx->roam.configParam.enable_ul_ofdma;
2462 param->enable_ul_mimo = mac_ctx->roam.configParam.enable_ul_mimo;
2463}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002464
2465
2466/**
2467 * csr_join_req_copy_he_cap() - Copy HE cap into CSR Join Req
2468 * @csr_join_req: pointer to CSR Join Req
2469 * @session: pointer to CSR session
2470 *
2471 * Return: None
2472 */
2473static void csr_join_req_copy_he_cap(tSirSmeJoinReq *csr_join_req,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302474 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002475{
2476 qdf_mem_copy(&csr_join_req->he_config, &session->he_config,
2477 sizeof(session->he_config));
2478}
2479
2480/**
2481 * csr_start_bss_copy_he_cap() - Copy HE cap into CSR Join Req
2482 * @req: pointer to START BSS Req
2483 * @session: pointer to CSR session
2484 *
2485 * Return: None
2486 */
2487static void csr_start_bss_copy_he_cap(tSirSmeStartBssReq *req,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302488 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002489{
2490 qdf_mem_copy(&req->he_config, &session->he_config,
2491 sizeof(session->he_config));
2492}
2493
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -08002494void csr_update_session_he_cap(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302495 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002496{
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002497 mac_handle_t mac_hdl = MAC_HANDLE(mac_ctx);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002498 uint32_t value = 0;
Naveen Rawatd8feac12017-09-08 15:08:39 -07002499 tDot11fIEhe_cap *he_cap = &session->he_config;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002500 he_cap->present = true;
2501
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002502 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_CONTROL, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002503 he_cap->htc_he = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002504 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_TWT_REQUESTOR, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002505 he_cap->twt_request = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002506 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_TWT_RESPONDER, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002507 he_cap->twt_responder = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002508 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_FRAGMENTATION, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002509 he_cap->fragmentation = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002510 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MAX_FRAG_MSDU, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002511 he_cap->max_num_frag_msdu = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002512 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MIN_FRAG_SIZE, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002513 he_cap->min_frag_size = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002514 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_TRIG_PAD, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002515 he_cap->trigger_frm_mac_pad = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002516 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MTID_AGGR, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002517 he_cap->multi_tid_aggr = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002518 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_LINK_ADAPTATION, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002519 he_cap->he_link_adaptation = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002520 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_ALL_ACK, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002521 he_cap->all_ack = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002522 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_UL_MU_RSP_SCHEDULING, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002523 he_cap->ul_mu_rsp_sched = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002524 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_BUFFER_STATUS_RPT, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002525 he_cap->a_bsr = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002526 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_BCAST_TWT, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002527 he_cap->broadcast_twt = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002528 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_BA_32BIT, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002529 he_cap->ba_32bit_bitmap = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002530 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MU_CASCADING, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002531 he_cap->mu_cascade = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002532 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MULTI_TID, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002533 he_cap->ack_enabled_multitid = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002534 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_DL_MU_BA, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002535 he_cap->dl_mu_ba = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002536 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_OMI, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002537 he_cap->omi_a_ctrl = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002538 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_OFDMA_RA, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002539 he_cap->ofdma_ra = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002540 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MAX_AMPDU_LEN, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002541 he_cap->max_ampdu_len = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002542 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_AMSDU_FRAG, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002543 he_cap->amsdu_frag = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002544 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_FLEX_TWT_SCHED, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002545 he_cap->flex_twt_sched = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002546 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_RX_CTRL, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002547 he_cap->rx_ctrl_frame = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002548 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_BSRP_AMPDU_AGGR, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002549 he_cap->bsrp_ampdu_aggr = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002550 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_QTP, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002551 he_cap->qtp = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002552 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_A_BQR, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002553 he_cap->a_bqr = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002554 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_SR_RESPONDER, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002555 he_cap->sr_responder = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002556 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_NDP_FEEDBACK_SUPP, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002557 he_cap->ndp_feedback_supp = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002558 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_OPS_SUPP, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002559 he_cap->ops_supp = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002560 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_AMSDU_IN_AMPDU, &value);
Naveen Rawatfc530312017-10-23 14:34:12 -07002561 he_cap->amsdu_in_ampdu = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002562
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002563 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_DUAL_BAND, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002564 he_cap->dual_band = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002565 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_CHAN_WIDTH, &value);
Naveen Rawataeca1b92017-10-16 16:55:31 -07002566 he_cap->chan_width_0 = HE_CH_WIDTH_GET_BIT(value, 0);
2567 he_cap->chan_width_1 = HE_CH_WIDTH_GET_BIT(value, 1);
2568 he_cap->chan_width_2 = HE_CH_WIDTH_GET_BIT(value, 2);
2569 he_cap->chan_width_3 = HE_CH_WIDTH_GET_BIT(value, 3);
2570 he_cap->chan_width_4 = HE_CH_WIDTH_GET_BIT(value, 4);
2571 he_cap->chan_width_5 = HE_CH_WIDTH_GET_BIT(value, 5);
2572 he_cap->chan_width_6 = HE_CH_WIDTH_GET_BIT(value, 6);
2573
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002574 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_RX_PREAM_PUNC, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002575 he_cap->rx_pream_puncturing = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002576 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_CLASS_OF_DEVICE, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002577 he_cap->device_class = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002578 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_LDPC, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002579 he_cap->ldpc_coding = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002580 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_LTF_PPDU, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002581 he_cap->he_1x_ltf_800_gi_ppdu = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002582 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MIDAMBLE_RX_MAX_NSTS, &value);
Naveen Rawatfc530312017-10-23 14:34:12 -07002583 he_cap->midamble_rx_max_nsts = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002584 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_LTF_NDP, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002585 he_cap->he_4x_ltf_3200_gi_ndp = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002586 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_TX_STBC_LT80, &value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08002587 he_cap->tx_stbc_lt_80mhz = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002588 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_RX_STBC_LT80, &value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08002589 he_cap->rx_stbc_lt_80mhz = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002590 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_DOPPLER, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002591 he_cap->doppler = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002592 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_UL_MUMIMO, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002593 he_cap->ul_mu = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002594 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_DCM_TX, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002595 he_cap->dcm_enc_tx = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002596 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_DCM_RX, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002597 he_cap->dcm_enc_rx = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002598 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MU_PPDU, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002599 he_cap->ul_he_mu = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002600 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_SU_BEAMFORMEE, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002601 he_cap->su_beamformee = value;
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -07002602 if (he_cap->su_beamformee) {
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002603 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_BFEE_STS_LT80, &value);
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -07002604 he_cap->bfee_sts_lt_80 = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002605 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_BFEE_STS_GT80, &value);
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -07002606 he_cap->bfee_sts_gt_80 = value;
2607 } else {
2608 he_cap->bfee_sts_lt_80 = 0;
2609 he_cap->bfee_sts_gt_80 = 0;
2610 }
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002611 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_SU_BEAMFORMER, &value);
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -07002612 he_cap->su_beamformer = value;
2613 if (he_cap->su_beamformer) {
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002614 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MU_BEAMFORMER, &value);
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -07002615 he_cap->mu_beamformer = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002616 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_NUM_SOUND_LT80, &value);
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -07002617 he_cap->num_sounding_lt_80 = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002618 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_NUM_SOUND_GT80, &value);
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -07002619 he_cap->num_sounding_gt_80 = value;
2620 } else {
2621 he_cap->mu_beamformer = 0;
2622 he_cap->num_sounding_lt_80 = 0;
2623 he_cap->num_sounding_gt_80 = 0;
2624 }
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002625 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_SU_FEED_TONE16, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002626 he_cap->su_feedback_tone16 = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002627 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MU_FEED_TONE16, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002628 he_cap->mu_feedback_tone16 = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002629 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_CODEBOOK_SU, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002630 he_cap->codebook_su = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002631 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_CODEBOOK_MU, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002632 he_cap->codebook_mu = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002633 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_BFRM_FEED, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002634 he_cap->beamforming_feedback = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002635 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_ER_SU_PPDU, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002636 he_cap->he_er_su_ppdu = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002637 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_DL_PART_BW, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002638 he_cap->dl_mu_mimo_part_bw = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002639 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_PPET_PRESENT, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002640 he_cap->ppet_present = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002641 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_SRP, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002642 he_cap->srp = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002643 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_POWER_BOOST, &value);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002644 he_cap->power_boost = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002645 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_4x_LTF_GI, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002646 he_cap->he_ltf_800_gi_4x = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002647 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MAX_NC, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002648 he_cap->max_nc = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002649 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_TX_STBC_GT80, &value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08002650 he_cap->tx_stbc_gt_80mhz = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002651 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_RX_STBC_GT80, &value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08002652 he_cap->rx_stbc_gt_80mhz = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002653 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_ER_4x_LTF_GI, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002654 he_cap->er_he_ltf_800_gi_4x = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002655 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_PPDU_20_IN_40MHZ_2G, &value);
Naveen Rawatfc530312017-10-23 14:34:12 -07002656 he_cap->he_ppdu_20_in_40Mhz_2G = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002657 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_PPDU_20_IN_160_80P80MHZ, &value);
Naveen Rawatfc530312017-10-23 14:34:12 -07002658 he_cap->he_ppdu_20_in_160_80p80Mhz = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002659 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_PPDU_80_IN_160_80P80MHZ, &value);
Naveen Rawatfc530312017-10-23 14:34:12 -07002660 he_cap->he_ppdu_80_in_160_80p80Mhz = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002661 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_ER_1X_HE_LTF_GI, &value);
Naveen Rawatfc530312017-10-23 14:34:12 -07002662 he_cap->er_1x_he_ltf_gi = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002663 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_MIDAMBLE_RX_1X_HE_LTF, &value);
Naveen Rawatfc530312017-10-23 14:34:12 -07002664 he_cap->midamble_rx_1x_he_ltf = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002665 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_RX_MCS_MAP_LT_80, &value);
Naveen Rawataeca1b92017-10-16 16:55:31 -07002666 he_cap->rx_he_mcs_map_lt_80 = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002667 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_TX_MCS_MAP_LT_80, &value);
Naveen Rawataeca1b92017-10-16 16:55:31 -07002668 he_cap->tx_he_mcs_map_lt_80 = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002669 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_RX_MCS_MAP_160, &value);
Naveen Rawataeca1b92017-10-16 16:55:31 -07002670 *((uint16_t *)he_cap->rx_he_mcs_map_160) = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002671 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_TX_MCS_MAP_160, &value);
Naveen Rawataeca1b92017-10-16 16:55:31 -07002672 *((uint16_t *)he_cap->tx_he_mcs_map_160) = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002673 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_RX_MCS_MAP_80_80, &value);
Naveen Rawataeca1b92017-10-16 16:55:31 -07002674 *((uint16_t *)he_cap->rx_he_mcs_map_80_80) = value;
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002675 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_TX_MCS_MAP_80_80, &value);
Naveen Rawataeca1b92017-10-16 16:55:31 -07002676 *((uint16_t *)he_cap->tx_he_mcs_map_80_80) = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002677
Krishna Kumaar Natarajanbc594592017-04-12 19:02:39 -07002678 if (he_cap->ppet_present) {
2679 value = WNI_CFG_HE_PPET_LEN;
Naveen Rawat01213762018-01-04 17:25:31 -08002680 /* till now operating channel is not decided yet, use 5g cap */
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002681 sme_cfg_get_str(mac_hdl, WNI_CFG_HE_PPET_5G,
Naveen Rawat819158d2018-01-16 10:56:45 -08002682 he_cap->ppet.ppe_threshold.ppe_th, &value);
2683 he_cap->ppet.ppe_threshold.num_ppe_th =
2684 lim_truncate_ppet(he_cap->ppet.ppe_threshold.ppe_th,
2685 value);
Krishna Kumaar Natarajanbc594592017-04-12 19:02:39 -07002686 } else {
Naveen Rawat819158d2018-01-16 10:56:45 -08002687 he_cap->ppet.ppe_threshold.num_ppe_th = 0;
Krishna Kumaar Natarajanbc594592017-04-12 19:02:39 -07002688 }
Jeff Johnsonc18469b2018-06-11 06:48:59 -07002689 sme_cfg_get_int(mac_hdl, WNI_CFG_HE_STA_OBSSPD, &value);
Manikandan Mohan39accff2017-05-02 16:09:00 -07002690 session->he_sta_obsspd = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002691}
2692
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002693#else
Jinwei Chen998a1a02018-06-20 17:20:34 +08002694#define CSR_REVISE_REQ_HE_CAP_PER_BAND(_req, _pmac, _channelid) /* no op */
2695
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002696static inline void csr_update_he_config_param(tpAniSirGlobal mac_ctx,
2697 tCsrConfigParam *param)
2698{
2699}
2700
2701static inline void csr_get_he_config_param(tCsrConfigParam *param,
2702 tpAniSirGlobal mac_ctx)
2703{
2704}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002705
2706static inline void csr_join_req_copy_he_cap(tSirSmeJoinReq *csr_join_req,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302707 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002708{
2709}
2710
2711static inline void csr_start_bss_copy_he_cap(tSirSmeStartBssReq *req,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302712 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002713{
2714}
2715
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002716#endif
2717
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05302718/**
2719 * csr_set_11k_offload_config_param() - Update 11k neighbor report config
2720 *
2721 * @csr_config: pointer to csr_config in MAC context
2722 * @pParam: pointer to config params from HDD
2723 *
2724 * Return: none
2725 */
2726static
2727void csr_set_11k_offload_config_param(struct csr_config *csr_config,
2728 tCsrConfigParam *param)
2729{
2730 csr_config->offload_11k_enable_bitmask =
2731 param->offload_11k_enable_bitmask;
2732 csr_config->neighbor_report_offload.params_bitmask =
2733 param->neighbor_report_offload.params_bitmask;
2734 csr_config->neighbor_report_offload.time_offset =
2735 param->neighbor_report_offload.time_offset;
2736 csr_config->neighbor_report_offload.low_rssi_offset =
2737 param->neighbor_report_offload.low_rssi_offset;
2738 csr_config->neighbor_report_offload.bmiss_count_trigger =
2739 param->neighbor_report_offload.bmiss_count_trigger;
2740 csr_config->neighbor_report_offload.per_threshold_offset =
2741 param->neighbor_report_offload.per_threshold_offset;
2742 csr_config->neighbor_report_offload.
2743 neighbor_report_cache_timeout =
2744 param->neighbor_report_offload.
2745 neighbor_report_cache_timeout;
2746 csr_config->neighbor_report_offload.
2747 max_neighbor_report_req_cap =
2748 param->neighbor_report_offload.
2749 max_neighbor_report_req_cap;
2750}
2751
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302752QDF_STATUS csr_change_default_config_param(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002753 tCsrConfigParam *pParam)
2754{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302755 QDF_STATUS status = QDF_STATUS_SUCCESS;
Paul Zhang99fe8842017-12-08 14:43:46 +08002756 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757
2758 if (pParam) {
Naveen Rawat2b6e3c92017-03-20 13:59:07 -07002759 pMac->roam.configParam.pkt_err_disconn_th =
2760 pParam->pkt_err_disconn_th;
Naveen Rawatb2fc4132017-05-10 20:42:05 -07002761 pMac->roam.configParam.is_force_1x1 =
2762 pParam->is_force_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
2764 cfg_set_int(pMac, WNI_CFG_WME_ENABLED,
2765 (pParam->WMMSupportMode == eCsrRoamWmmNoQos) ? 0 : 1);
2766 pMac->roam.configParam.Is11eSupportEnabled =
2767 pParam->Is11eSupportEnabled;
2768 pMac->roam.configParam.FragmentationThreshold =
2769 pParam->FragmentationThreshold;
2770 pMac->roam.configParam.Is11dSupportEnabled =
2771 pParam->Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002772 pMac->roam.configParam.Is11hSupportEnabled =
2773 pParam->Is11hSupportEnabled;
2774
2775 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
2776 pMac->roam.configParam.mcc_rts_cts_prot_enable =
2777 pParam->mcc_rts_cts_prot_enable;
2778 pMac->roam.configParam.mcc_bcast_prob_resp_enable =
2779 pParam->mcc_bcast_prob_resp_enable;
2780 pMac->roam.configParam.fAllowMCCGODiffBI =
2781 pParam->fAllowMCCGODiffBI;
2782
2783 /* channelBondingMode5GHz plays a dual role right now
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302784 * INFRA STA will use this non zero value as CB enabled
2785 * and SOFTAP will use this non-zero value to determine
2786 * the secondary channel offset. This is how
2787 * channelBondingMode5GHz works now and this is kept intact
2788 * to avoid any cfg.ini change.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302790 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
2791 sme_warn("Invalid CB value from ini in 2.4GHz band %d, CB DISABLED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 pParam->channelBondingMode24GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 pMac->roam.configParam.channelBondingMode24GHz =
2794 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302795 channelBondingMode24GHz);
2796 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
2797 sme_warn("Invalid CB value from ini in 5GHz band %d, CB DISABLED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 pParam->channelBondingMode5GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 pMac->roam.configParam.channelBondingMode5GHz =
2800 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302801 channelBondingMode5GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
2803 pMac->roam.configParam.phyMode = pParam->phyMode;
2804 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
2805 pMac->roam.configParam.HeartbeatThresh24 =
2806 pParam->HeartbeatThresh24;
2807 pMac->roam.configParam.HeartbeatThresh50 =
2808 pParam->HeartbeatThresh50;
2809 pMac->roam.configParam.ProprietaryRatesEnabled =
2810 pParam->ProprietaryRatesEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
2812 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
2813 pMac->roam.configParam.bandCapability = pParam->bandCapability;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002814 pMac->roam.configParam.wep_tkip_in_he = pParam->wep_tkip_in_he;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 pMac->roam.configParam.neighborRoamConfig.
2816 delay_before_vdev_stop =
2817 pParam->neighborRoamConfig.delay_before_vdev_stop;
2818
2819 /* if HDD passed down non zero values then only update, */
2820 /* otherwise keep using the defaults */
2821 if (pParam->initial_scan_no_dfs_chnl) {
2822 pMac->roam.configParam.initial_scan_no_dfs_chnl =
2823 pParam->initial_scan_no_dfs_chnl;
2824 }
2825 if (pParam->nInitialDwellTime) {
2826 pMac->roam.configParam.nInitialDwellTime =
2827 pParam->nInitialDwellTime;
2828 }
2829 if (pParam->nActiveMaxChnTime) {
2830 pMac->roam.configParam.nActiveMaxChnTime =
2831 pParam->nActiveMaxChnTime;
2832 cfg_set_int(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
2833 pParam->nActiveMaxChnTime);
2834 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 if (pParam->nPassiveMaxChnTime) {
2836 pMac->roam.configParam.nPassiveMaxChnTime =
2837 pParam->nPassiveMaxChnTime;
2838 cfg_set_int(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
2839 pParam->nPassiveMaxChnTime);
2840 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 if (pParam->nActiveMaxChnTimeConc) {
2842 pMac->roam.configParam.nActiveMaxChnTimeConc =
2843 pParam->nActiveMaxChnTimeConc;
2844 }
2845 if (pParam->nActiveMinChnTimeConc) {
2846 pMac->roam.configParam.nActiveMinChnTimeConc =
2847 pParam->nActiveMinChnTimeConc;
2848 }
2849 if (pParam->nPassiveMaxChnTimeConc) {
2850 pMac->roam.configParam.nPassiveMaxChnTimeConc =
2851 pParam->nPassiveMaxChnTimeConc;
2852 }
2853 if (pParam->nPassiveMinChnTimeConc) {
2854 pMac->roam.configParam.nPassiveMinChnTimeConc =
2855 pParam->nPassiveMinChnTimeConc;
2856 }
Agrawal Ashish17bb3902016-05-05 13:29:40 +05302857 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
2858 pMac->roam.configParam.min_rest_time_conc =
2859 pParam->min_rest_time_conc;
2860 pMac->roam.configParam.idle_time_conc = pParam->idle_time_conc;
2861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 pMac->roam.configParam.eBand = pParam->eBand;
2863 pMac->roam.configParam.uCfgDot11Mode =
2864 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302865 pMac->roam.configParam.
2866 phyMode,
2867 pMac->roam.configParam.
2868 ProprietaryRatesEnabled);
2869 /* if HDD passed down non zero values for age params,
2870 * then only update, otherwise keep using the defaults
2871 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 if (pParam->nScanResultAgeCount) {
2873 pMac->roam.configParam.agingCount =
2874 pParam->nScanResultAgeCount;
2875 }
Sandeep Puligillae0875662016-02-12 16:09:21 -08002876 if (pParam->obss_width_interval) {
2877 pMac->roam.configParam.obss_width_interval =
2878 pParam->obss_width_interval;
2879 cfg_set_int(pMac,
2880 WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
2881 pParam->obss_width_interval);
2882 }
2883 if (pParam->obss_active_dwelltime) {
2884 pMac->roam.configParam.obss_active_dwelltime =
2885 pParam->obss_active_dwelltime;
2886 cfg_set_int(pMac,
2887 WNI_CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME,
2888 pParam->obss_active_dwelltime);
2889 }
2890 if (pParam->obss_passive_dwelltime) {
2891 pMac->roam.configParam.obss_passive_dwelltime =
2892 pParam->obss_passive_dwelltime;
2893 cfg_set_int(pMac,
2894 WNI_CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME,
2895 pParam->obss_passive_dwelltime);
2896 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08002898 pMac->first_scan_bucket_threshold =
2899 pParam->first_scan_bucket_threshold;
2900 csr_assign_rssi_for_category(pMac,
2901 pMac->first_scan_bucket_threshold,
2902 pParam->bCatRssiOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 pMac->roam.configParam.fSupplicantCountryCodeHasPriority =
2904 pParam->fSupplicantCountryCodeHasPriority;
2905 pMac->roam.configParam.vccRssiThreshold =
2906 pParam->vccRssiThreshold;
2907 pMac->roam.configParam.vccUlMacLossThreshold =
2908 pParam->vccUlMacLossThreshold;
2909 pMac->roam.configParam.statsReqPeriodicity =
2910 pParam->statsReqPeriodicity;
2911 pMac->roam.configParam.statsReqPeriodicityInPS =
2912 pParam->statsReqPeriodicityInPS;
2913 /* Assign this before calling csr_init11d_info */
2914 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05302915 pMac->roam.configParam.allow_tpc_from_ap =
2916 pParam->allow_tpc_from_ap;
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07002917 if (wlan_reg_11d_enabled_on_host(pMac->psoc))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 status = csr_init11d_info(pMac, &pParam->Csr11dinfo);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302919 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302922 /* Initialize the power + channel information if 11h is
2923 * enabled. If 11d is enabled this information has already
2924 * been initialized
2925 */
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07002926 if (csr_is11h_supported(pMac) &&
2927 !wlan_reg_11d_enabled_on_host(pMac->psoc))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 csr_init_channel_power_list(pMac, &pParam->Csr11dinfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 pMac->roam.configParam.isFastTransitionEnabled =
2931 pParam->isFastTransitionEnabled;
2932 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Abhishek Singh34c0e632017-09-28 14:39:29 +05302933 pMac->roam.configParam.rssi_abs_thresh =
2934 pParam->rssi_abs_thresh;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 pMac->roam.configParam.nRoamPrefer5GHz =
2936 pParam->nRoamPrefer5GHz;
2937 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
2938 pMac->roam.configParam.isWESModeEnabled =
2939 pParam->isWESModeEnabled;
2940 pMac->roam.configParam.nProbes = pParam->nProbes;
2941 pMac->roam.configParam.nRoamScanHomeAwayTime =
2942 pParam->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 pMac->roam.configParam.isRoamOffloadScanEnabled =
2944 pParam->isRoamOffloadScanEnabled;
2945 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
2946 pParam->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
2948 pParam->isFastRoamIniFeatureEnabled;
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07002949 qdf_mem_copy(&pMac->roam.configParam.csr_mawc_config,
2950 &pParam->csr_mawc_config,
2951 sizeof(pParam->csr_mawc_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952#ifdef FEATURE_WLAN_ESE
2953 pMac->roam.configParam.isEseIniFeatureEnabled =
2954 pParam->isEseIniFeatureEnabled;
2955#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302956 qdf_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 &pParam->neighborRoamConfig,
2958 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002959 sme_debug("nNeighborScanTimerPerioid: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 pMac->roam.configParam.neighborRoamConfig.
2961 nNeighborScanTimerPeriod);
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05302962 sme_debug("neighbor_scan_min_timer_period: %d",
2963 pMac->roam.configParam.neighborRoamConfig.
2964 neighbor_scan_min_timer_period);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002965 sme_debug("nNeighborLookupRssiThreshold: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 pMac->roam.configParam.neighborRoamConfig.
2967 nNeighborLookupRssiThreshold);
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -07002968 sme_debug("rssi_thresh_offset_5g: %d",
2969 pMac->roam.configParam.neighborRoamConfig.rssi_thresh_offset_5g);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002970 sme_debug("nOpportunisticThresholdDiff: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 pMac->roam.configParam.neighborRoamConfig.
2972 nOpportunisticThresholdDiff);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002973 sme_debug("nRoamRescanRssiDiff: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 pMac->roam.configParam.neighborRoamConfig.
2975 nRoamRescanRssiDiff);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002976 sme_debug("nNeighborScanMinChanTime: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 pMac->roam.configParam.neighborRoamConfig.
2978 nNeighborScanMinChanTime);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002979 sme_debug("nNeighborScanMaxChanTime: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002980 pMac->roam.configParam.neighborRoamConfig.
2981 nNeighborScanMaxChanTime);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002982 sme_debug("nMaxNeighborRetries: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 pMac->roam.configParam.neighborRoamConfig.
2984 nMaxNeighborRetries);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002985 sme_debug("nNeighborResultsRefreshPeriod: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 pMac->roam.configParam.neighborRoamConfig.
2987 nNeighborResultsRefreshPeriod);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002988 sme_debug("nEmptyScanRefreshPeriod: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 pMac->roam.configParam.neighborRoamConfig.
2990 nEmptyScanRefreshPeriod);
2991 {
2992 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302993
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002994 sme_debug("Num of Channels in CFG Channel List: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 pMac->roam.configParam.neighborRoamConfig.
2996 neighborScanChanList.numChannels);
2997 for (i = 0;
2998 i <
2999 pMac->roam.configParam.neighborRoamConfig.
3000 neighborScanChanList.numChannels; i++) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003001 sme_debug("%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 pMac->roam.configParam.
3003 neighborRoamConfig.neighborScanChanList.
3004 channelList[i]);
3005 }
3006 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003007 sme_debug("nRoamBmissFirstBcnt: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 pMac->roam.configParam.neighborRoamConfig.
3009 nRoamBmissFirstBcnt);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003010 sme_debug("nRoamBmissFinalBcnt: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 pMac->roam.configParam.neighborRoamConfig.
3012 nRoamBmissFinalBcnt);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003013 sme_debug("nRoamBeaconRssiWeight: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 pMac->roam.configParam.neighborRoamConfig.
3015 nRoamBeaconRssiWeight);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 pMac->roam.configParam.addTSWhenACMIsOff =
3017 pParam->addTSWhenACMIsOff;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
3019 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
3020 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
3021 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
3022 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
3023 pMac->scan.max_scan_count = pParam->max_scan_count;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303024 /* This parameter is not available in cfg and not passed from
Jeff Johnson810596a2018-05-06 17:01:22 -07003025 * upper layers. Instead it is initialized here This parametere
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303026 * is used in concurrency to determine if there are concurrent
3027 * active sessions. Is used as a temporary fix to disconnect
3028 * all active sessions when BMPS enabled so the active session
3029 * if Infra STA will automatically connect back and resume BMPS
3030 * since resume BMPS is not working when moving from concurrent
3031 * to single session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 */
3033 /* Remove this code once SLM_Sessionization is supported */
3034 /* BMPS_WORKAROUND_NOT_NEEDED */
3035 pMac->roam.configParam.doBMPSWorkaround = 0;
3036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 pMac->roam.configParam.nVhtChannelWidth =
3038 pParam->nVhtChannelWidth;
Abhishek Singh68844282018-01-25 16:48:41 +05303039 pMac->roam.configParam.enable_subfee_vendor_vhtie =
3040 pParam->enable_subfee_vendor_vhtie;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08003041 pMac->roam.configParam.enable_txbf_sap_mode =
3042 pParam->enable_txbf_sap_mode;
Kiran Kumar Lokere0e255172018-03-30 18:54:25 -07003043 pMac->roam.configParam.enable_vht20_mcs9 =
3044 pParam->enable_vht20_mcs9;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 pMac->roam.configParam.enable2x2 = pParam->enable2x2;
3046 pMac->roam.configParam.enableVhtFor24GHz =
3047 pParam->enableVhtFor24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 pMac->roam.configParam.enableVhtpAid = pParam->enableVhtpAid;
3049 pMac->roam.configParam.enableVhtGid = pParam->enableVhtGid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 pMac->roam.configParam.enableAmpduPs = pParam->enableAmpduPs;
3051 pMac->roam.configParam.enableHtSmps = pParam->enableHtSmps;
3052 pMac->roam.configParam.htSmps = pParam->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08003053 pMac->roam.configParam.send_smps_action =
3054 pParam->send_smps_action;
Krunal Sonia2c0e412017-05-04 14:12:41 +05303055 pMac->roam.configParam.tx_ldpc_enable = pParam->enable_tx_ldpc;
3056 pMac->roam.configParam.rx_ldpc_enable = pParam->enable_rx_ldpc;
Krunal Soni158bfe62017-08-02 12:33:08 -07003057 pMac->roam.configParam.disable_high_ht_mcs_2x2 =
3058 pParam->disable_high_ht_mcs_2x2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 pMac->roam.configParam.ignore_peer_erp_info =
3060 pParam->ignore_peer_erp_info;
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07003061 pMac->roam.configParam.max_amsdu_num =
3062 pParam->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 pMac->roam.configParam.nSelect5GHzMargin =
3064 pParam->nSelect5GHzMargin;
Abhinav Kumara083f212018-04-05 18:49:45 +05303065 pMac->roam.configParam.ho_delay_for_rx =
3066 pParam->ho_delay_for_rx;
Abhinav Kumara95af7c2018-04-06 17:08:00 +05303067 pMac->roam.configParam.min_delay_btw_roam_scans =
3068 pParam->min_delay_btw_roam_scans;
3069 pMac->roam.configParam.roam_trigger_reason_bitmask =
3070 pParam->roam_trigger_reason_bitmask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 pMac->roam.configParam.isCoalesingInIBSSAllowed =
3072 pParam->isCoalesingInIBSSAllowed;
3073#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
3074 pMac->roam.configParam.cc_switch_mode = pParam->cc_switch_mode;
3075#endif
3076 pMac->roam.configParam.allowDFSChannelRoam =
3077 pParam->allowDFSChannelRoam;
3078#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3079 pMac->roam.configParam.isRoamOffloadEnabled =
3080 pParam->isRoamOffloadEnabled;
3081#endif
3082 pMac->roam.configParam.obssEnabled = pParam->obssEnabled;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303083 pMac->roam.configParam.vendor_vht_sap =
3084 pParam->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 pMac->roam.configParam.conc_custom_rule1 =
3086 pParam->conc_custom_rule1;
3087 pMac->roam.configParam.conc_custom_rule2 =
3088 pParam->conc_custom_rule2;
3089 pMac->roam.configParam.is_sta_connection_in_5gz_enabled =
3090 pParam->is_sta_connection_in_5gz_enabled;
Jeff Johnson1ad3fbd2017-11-03 08:00:02 -07003091 pMac->roam.configParam.send_deauth_before_con =
3092 pParam->send_deauth_before_con;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093
3094 pMac->enable_dot11p = pParam->enable_dot11p;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07003095 pMac->roam.configParam.early_stop_scan_enable =
3096 pParam->early_stop_scan_enable;
3097 pMac->roam.configParam.early_stop_scan_min_threshold =
3098 pParam->early_stop_scan_min_threshold;
3099 pMac->roam.configParam.early_stop_scan_max_threshold =
3100 pParam->early_stop_scan_max_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003101 pMac->isCoalesingInIBSSAllowed =
3102 pParam->isCoalesingInIBSSAllowed;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07003103
Gupta, Kapilc68ad462016-02-01 19:17:23 +05303104 pMac->roam.configParam.roam_params.dense_rssi_thresh_offset =
3105 pParam->roam_dense_rssi_thresh_offset;
3106 pMac->roam.configParam.roam_params.dense_min_aps_cnt =
3107 pParam->roam_dense_min_aps;
3108 pMac->roam.configParam.roam_params.traffic_threshold =
3109 pParam->roam_dense_traffic_thresh;
3110
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -07003111 pMac->roam.configParam.roam_params.bg_scan_bad_rssi_thresh =
3112 pParam->roam_bg_scan_bad_rssi_thresh;
3113 pMac->roam.configParam.roam_params.bg_scan_client_bitmap =
3114 pParam->roam_bg_scan_client_bitmap;
Vignesh Viswanathanc018e982017-09-07 18:49:19 +05303115 pMac->roam.configParam.roam_params.
3116 roam_bad_rssi_thresh_offset_2g =
3117 pParam->roam_bad_rssi_thresh_offset_2g;
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -07003118
Abhinav Kumar271f0632018-03-29 16:01:30 +05303119 pMac->roam.configParam.enable_ftopen =
3120 pParam->enable_ftopen;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05303121 pMac->roam.configParam.scan_adaptive_dwell_mode =
3122 pParam->scan_adaptive_dwell_mode;
Paul Zhang72697bd2017-12-20 09:24:25 +08003123 pMac->roam.configParam.scan_adaptive_dwell_mode_nc =
3124 pParam->scan_adaptive_dwell_mode_nc;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05303125 pMac->roam.configParam.roamscan_adaptive_dwell_mode =
3126 pParam->roamscan_adaptive_dwell_mode;
3127
Kapil Gupta5cda2252016-12-29 18:44:26 +05303128 pMac->roam.configParam.per_roam_config.enable =
3129 pParam->per_roam_config.enable;
3130 pMac->roam.configParam.per_roam_config.tx_high_rate_thresh =
3131 pParam->per_roam_config.tx_high_rate_thresh;
3132 pMac->roam.configParam.per_roam_config.rx_high_rate_thresh =
3133 pParam->per_roam_config.rx_high_rate_thresh;
3134 pMac->roam.configParam.per_roam_config.tx_low_rate_thresh =
3135 pParam->per_roam_config.tx_low_rate_thresh;
3136 pMac->roam.configParam.per_roam_config.rx_low_rate_thresh =
3137 pParam->per_roam_config.rx_low_rate_thresh;
3138 pMac->roam.configParam.per_roam_config.tx_rate_thresh_percnt =
3139 pParam->per_roam_config.tx_rate_thresh_percnt;
3140 pMac->roam.configParam.per_roam_config.rx_rate_thresh_percnt =
3141 pParam->per_roam_config.rx_rate_thresh_percnt;
3142 pMac->roam.configParam.per_roam_config.per_rest_time =
3143 pParam->per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +05303144 pMac->roam.configParam.per_roam_config.tx_per_mon_time =
3145 pParam->per_roam_config.tx_per_mon_time;
3146 pMac->roam.configParam.per_roam_config.rx_per_mon_time =
3147 pParam->per_roam_config.rx_per_mon_time;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +05303148 pMac->roam.configParam.per_roam_config.min_candidate_rssi =
3149 pParam->per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +05303150
Krunal Soni1878d3a2016-01-14 13:00:44 -08003151 pMac->fEnableDebugLog = pParam->fEnableDebugLog;
3152
3153 /* update interface configuration */
3154 pMac->sme.max_intf_count = pParam->max_intf_count;
3155
3156 pMac->enable5gEBT = pParam->enable5gEBT;
3157 pMac->sme.enableSelfRecovery = pParam->enableSelfRecovery;
3158
3159 pMac->f_sta_miracast_mcc_rest_time_val =
3160 pParam->f_sta_miracast_mcc_rest_time_val;
3161#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
3162 pMac->sap.sap_channel_avoidance =
3163 pParam->sap_channel_avoidance;
3164#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
gaoleze5108942017-03-31 16:56:42 +08003165 pMac->sap.acs_with_more_param =
3166 pParam->acs_with_more_param;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003167
3168 pMac->f_prefer_non_dfs_on_radar =
3169 pParam->f_prefer_non_dfs_on_radar;
3170
3171 pMac->sme.ps_global_info.ps_enabled =
3172 pParam->is_ps_enabled;
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08003173 pMac->sme.ps_global_info.auto_bmps_timer_val =
3174 pParam->auto_bmps_timer_val;
Abhishek Singh165bc602016-03-21 12:43:00 +05303175 pMac->roam.configParam.ignore_peer_ht_opmode =
3176 pParam->ignore_peer_ht_opmode;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003177 pMac->dual_mac_feature_disable =
3178 pParam->dual_mac_feature_disable;
Ganesh Kondabattini930304c2017-10-10 15:25:36 +05303179 pMac->sta_sap_scc_on_dfs_chan =
3180 pParam->sta_sap_scc_on_dfs_chan;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003181 pMac->roam.configParam.early_stop_scan_enable =
3182 pParam->early_stop_scan_enable;
3183 pMac->roam.configParam.early_stop_scan_min_threshold =
3184 pParam->early_stop_scan_min_threshold;
3185 pMac->roam.configParam.early_stop_scan_max_threshold =
3186 pParam->early_stop_scan_max_threshold;
Abhishek Singh10ecf582016-05-04 17:48:59 +05303187 pMac->roam.configParam.enable_edca_params =
3188 pParam->enable_edca_params;
3189 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
3190 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
3191 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
3192 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
3193
3194 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
3195 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
3196 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
3197 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
3198
3199 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
3200 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
3201 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
3202 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
3203
Abhishek Singh5ea86532016-04-27 14:10:53 +05303204 pMac->roam.configParam.enable_fatal_event =
3205 pParam->enable_fatal_event;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05303206 pMac->roam.configParam.sta_roam_policy.dfs_mode =
3207 pParam->sta_roam_policy_params.dfs_mode;
3208 pMac->roam.configParam.sta_roam_policy.skip_unsafe_channels =
3209 pParam->sta_roam_policy_params.skip_unsafe_channels;
Zhang Qian65e2e8d2017-07-11 11:56:43 +08003210 pMac->roam.configParam.sta_roam_policy.sap_operating_band =
3211 pParam->sta_roam_policy_params.sap_operating_band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303213 pMac->roam.configParam.tx_aggregation_size =
3214 pParam->tx_aggregation_size;
Paul Zhangee09f8e2018-04-23 16:11:32 +08003215 pMac->roam.configParam.tx_aggregation_size_be =
3216 pParam->tx_aggregation_size_be;
3217 pMac->roam.configParam.tx_aggregation_size_bk =
3218 pParam->tx_aggregation_size_bk;
3219 pMac->roam.configParam.tx_aggregation_size_vi =
3220 pParam->tx_aggregation_size_vi;
3221 pMac->roam.configParam.tx_aggregation_size_vo =
3222 pParam->tx_aggregation_size_vo;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303223 pMac->roam.configParam.rx_aggregation_size =
3224 pParam->rx_aggregation_size;
Paul Zhang33fae272018-04-23 16:19:00 +08003225 pMac->roam.configParam.tx_aggr_sw_retry_threshold_be =
3226 pParam->tx_aggr_sw_retry_threshold_be;
3227 pMac->roam.configParam.tx_aggr_sw_retry_threshold_bk =
3228 pParam->tx_aggr_sw_retry_threshold_bk;
3229 pMac->roam.configParam.tx_aggr_sw_retry_threshold_vi =
3230 pParam->tx_aggr_sw_retry_threshold_vi;
3231 pMac->roam.configParam.tx_aggr_sw_retry_threshold_vo =
3232 pParam->tx_aggr_sw_retry_threshold_vo;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +05303233 pMac->roam.configParam.enable_bcast_probe_rsp =
3234 pParam->enable_bcast_probe_rsp;
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05303235 pMac->roam.configParam.is_fils_enabled =
3236 pParam->is_fils_enabled;
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05303237 pMac->roam.configParam.qcn_ie_support =
3238 pParam->qcn_ie_support;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +05303239 pMac->roam.configParam.fils_max_chan_guard_time =
3240 pParam->fils_max_chan_guard_time;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +05303241 pMac->roam.configParam.disallow_duration =
3242 pParam->disallow_duration;
3243 pMac->roam.configParam.rssi_channel_penalization =
3244 pParam->rssi_channel_penalization;
3245 pMac->roam.configParam.num_disallowed_aps =
3246 pParam->num_disallowed_aps;
Paul Zhang99fe8842017-12-08 14:43:46 +08003247 pMac->roam.configParam.wlm_latency_enable =
3248 pParam->wlm_latency_enable;
3249 pMac->roam.configParam.wlm_latency_level =
3250 pParam->wlm_latency_level;
3251 for (i = 0; i < CSR_NUM_WLM_LATENCY_LEVEL; i++) {
3252 pMac->roam.configParam.wlm_latency_flags[i] =
3253 pParam->wlm_latency_flags[i];
3254 }
Yeshwanth Sriram Guntuka2ba6fe92017-10-04 14:40:45 +05303255 pMac->roam.configParam.oce_feature_bitmap =
3256 pParam->oce_feature_bitmap;
Abhinav Kumaredd1d372018-05-11 15:33:35 +05303257 pMac->roam.configParam.roam_force_rssi_trigger =
3258 pParam->roam_force_rssi_trigger;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303259
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05303260 pMac->roam.configParam.mbo_thresholds.
3261 mbo_candidate_rssi_thres =
3262 pParam->mbo_thresholds.mbo_candidate_rssi_thres;
3263 pMac->roam.configParam.mbo_thresholds.
3264 mbo_current_rssi_thres =
3265 pParam->mbo_thresholds.mbo_current_rssi_thres;
3266 pMac->roam.configParam.mbo_thresholds.
3267 mbo_current_rssi_mcc_thres =
3268 pParam->mbo_thresholds.mbo_current_rssi_mcc_thres;
3269 pMac->roam.configParam.mbo_thresholds.
3270 mbo_candidate_rssi_btc_thres =
3271 pParam->mbo_thresholds.mbo_candidate_rssi_btc_thres;
3272
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05303273 qdf_mem_copy(&pMac->roam.configParam.bss_score_params,
3274 &pParam->bss_score_params,
3275 sizeof(struct sir_score_config));
yeshwanth sriram guntuka41f936c2017-09-01 17:53:49 +05303276 pMac->roam.configParam.btm_offload_config =
3277 pParam->btm_offload_config;
Jiachao Wu84bb2ea2018-01-08 16:17:33 +08003278 pMac->roam.configParam.btm_solicited_timeout =
3279 pParam->btm_solicited_timeout;
3280 pMac->roam.configParam.btm_max_attempt_cnt =
3281 pParam->btm_max_attempt_cnt;
3282 pMac->roam.configParam.btm_sticky_time =
3283 pParam->btm_sticky_time;
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05303284
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08003285 csr_update_he_config_param(pMac, pParam);
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05303286 csr_set_11k_offload_config_param(&pMac->roam.configParam,
3287 pParam);
Gupta, Kapilc68ad462016-02-01 19:17:23 +05303288 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 return status;
3290}
3291
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05303292/**
3293 * csr_get_11k_offload_config_param() - Get 11k neighbor report config
3294 *
3295 * @csr_config: pointer to csr_config in MAC context
3296 * @pParam: pointer to config params from HDD
3297 *
3298 * Return: none
3299 */
3300static
3301void csr_get_11k_offload_config_param(struct csr_config *csr_config,
3302 tCsrConfigParam *param)
3303{
3304 param->offload_11k_enable_bitmask =
3305 csr_config->offload_11k_enable_bitmask;
3306 param->neighbor_report_offload.params_bitmask =
3307 csr_config->neighbor_report_offload.params_bitmask;
3308 param->neighbor_report_offload.time_offset =
3309 csr_config->neighbor_report_offload.time_offset;
3310 param->neighbor_report_offload.low_rssi_offset =
3311 csr_config->neighbor_report_offload.low_rssi_offset;
3312 param->neighbor_report_offload.bmiss_count_trigger =
3313 csr_config->neighbor_report_offload.bmiss_count_trigger;
3314 param->neighbor_report_offload.per_threshold_offset =
3315 csr_config->neighbor_report_offload.per_threshold_offset;
3316 param->neighbor_report_offload.neighbor_report_cache_timeout =
3317 csr_config->neighbor_report_offload.
3318 neighbor_report_cache_timeout;
3319 param->neighbor_report_offload.max_neighbor_report_req_cap =
3320 csr_config->neighbor_report_offload.
3321 max_neighbor_report_req_cap;
3322}
3323
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303324QDF_STATUS csr_get_config_param(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325{
3326 int i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303327 struct csr_config *cfg_params = &pMac->roam.configParam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328
3329 if (!pParam)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303330 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331
Naveen Rawat2b6e3c92017-03-20 13:59:07 -07003332 pParam->pkt_err_disconn_th = cfg_params->pkt_err_disconn_th;
Naveen Rawatb2fc4132017-05-10 20:42:05 -07003333 pParam->is_force_1x1 = cfg_params->is_force_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 pParam->WMMSupportMode = cfg_params->WMMSupportMode;
3335 pParam->Is11eSupportEnabled = cfg_params->Is11eSupportEnabled;
3336 pParam->FragmentationThreshold = cfg_params->FragmentationThreshold;
3337 pParam->Is11dSupportEnabled = cfg_params->Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 pParam->Is11hSupportEnabled = cfg_params->Is11hSupportEnabled;
3339 pParam->channelBondingMode24GHz = csr_convert_phy_cb_state_to_ini_value(
3340 cfg_params->channelBondingMode24GHz);
3341 pParam->channelBondingMode5GHz = csr_convert_phy_cb_state_to_ini_value(
3342 cfg_params->channelBondingMode5GHz);
3343 pParam->RTSThreshold = cfg_params->RTSThreshold;
3344 pParam->phyMode = cfg_params->phyMode;
3345 pParam->shortSlotTime = cfg_params->shortSlotTime;
3346 pParam->HeartbeatThresh24 = cfg_params->HeartbeatThresh24;
3347 pParam->HeartbeatThresh50 = cfg_params->HeartbeatThresh50;
3348 pParam->ProprietaryRatesEnabled = cfg_params->ProprietaryRatesEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 pParam->AdHocChannel24 = cfg_params->AdHocChannel24;
3350 pParam->AdHocChannel5G = cfg_params->AdHocChannel5G;
3351 pParam->bandCapability = cfg_params->bandCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 pParam->nActiveMaxChnTime = cfg_params->nActiveMaxChnTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 pParam->nPassiveMaxChnTime = cfg_params->nPassiveMaxChnTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354 pParam->nActiveMaxChnTimeConc = cfg_params->nActiveMaxChnTimeConc;
3355 pParam->nActiveMinChnTimeConc = cfg_params->nActiveMinChnTimeConc;
3356 pParam->nPassiveMaxChnTimeConc = cfg_params->nPassiveMaxChnTimeConc;
3357 pParam->nPassiveMinChnTimeConc = cfg_params->nPassiveMinChnTimeConc;
3358 pParam->nRestTimeConc = cfg_params->nRestTimeConc;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05303359 pParam->min_rest_time_conc = cfg_params->min_rest_time_conc;
3360 pParam->idle_time_conc = cfg_params->idle_time_conc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 pParam->eBand = cfg_params->eBand;
3362 pParam->nScanResultAgeCount = cfg_params->agingCount;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363 pParam->bCatRssiOffset = cfg_params->bCatRssiOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 pParam->fSupplicantCountryCodeHasPriority =
3365 cfg_params->fSupplicantCountryCodeHasPriority;
3366 pParam->vccRssiThreshold = cfg_params->vccRssiThreshold;
3367 pParam->vccUlMacLossThreshold = cfg_params->vccUlMacLossThreshold;
3368 pParam->nTxPowerCap = cfg_params->nTxPowerCap;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05303369 pParam->allow_tpc_from_ap = cfg_params->allow_tpc_from_ap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 pParam->statsReqPeriodicity = cfg_params->statsReqPeriodicity;
3371 pParam->statsReqPeriodicityInPS = cfg_params->statsReqPeriodicityInPS;
3372 pParam->addTSWhenACMIsOff = cfg_params->addTSWhenACMIsOff;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
3374 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
3375 pParam->fScanTwice = cfg_params->fScanTwice;
3376 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
3377 pParam->fEnableMCCMode = cfg_params->fenableMCCMode;
3378 pParam->fAllowMCCGODiffBI = cfg_params->fAllowMCCGODiffBI;
3379 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303380 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 &cfg_params->neighborRoamConfig,
3382 sizeof(tCsrNeighborRoamConfigParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 pParam->nVhtChannelWidth = cfg_params->nVhtChannelWidth;
Abhishek Singh68844282018-01-25 16:48:41 +05303384 pParam->enable_subfee_vendor_vhtie =
3385 cfg_params->enable_subfee_vendor_vhtie;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08003386 pParam->enable_txbf_sap_mode =
3387 cfg_params->enable_txbf_sap_mode;
Kiran Kumar Lokere0e255172018-03-30 18:54:25 -07003388 pParam->enable_vht20_mcs9 = cfg_params->enable_vht20_mcs9;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 pParam->enableVhtFor24GHz = cfg_params->enableVhtFor24GHz;
3390 pParam->ignore_peer_erp_info = cfg_params->ignore_peer_erp_info;
3391 pParam->enable2x2 = cfg_params->enable2x2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 pParam->isFastTransitionEnabled = cfg_params->isFastTransitionEnabled;
3393 pParam->RoamRssiDiff = cfg_params->RoamRssiDiff;
Abhishek Singh34c0e632017-09-28 14:39:29 +05303394 pParam->rssi_abs_thresh = cfg_params->rssi_abs_thresh;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 pParam->nRoamPrefer5GHz = cfg_params->nRoamPrefer5GHz;
3396 pParam->nRoamIntraBand = cfg_params->nRoamIntraBand;
3397 pParam->isWESModeEnabled = cfg_params->isWESModeEnabled;
3398 pParam->nProbes = cfg_params->nProbes;
3399 pParam->nRoamScanHomeAwayTime = cfg_params->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 pParam->isRoamOffloadScanEnabled = cfg_params->isRoamOffloadScanEnabled;
3401 pParam->bFastRoamInConIniFeatureEnabled =
3402 cfg_params->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 pParam->isFastRoamIniFeatureEnabled =
3404 cfg_params->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405#ifdef FEATURE_WLAN_ESE
3406 pParam->isEseIniFeatureEnabled = cfg_params->isEseIniFeatureEnabled;
3407#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303408 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 &cfg_params->neighborRoamConfig,
3410 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003411 sme_debug("Num of Channels in CFG Channel List: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003412 cfg_params->neighborRoamConfig.
3413 neighborScanChanList.numChannels);
3414 for (i = 0; i < cfg_params->neighborRoamConfig.
3415 neighborScanChanList.numChannels; i++) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003416 sme_debug("%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 cfg_params->neighborRoamConfig.
3418 neighborScanChanList.channelList[i]);
3419 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420
3421#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
3422 pParam->cc_switch_mode = cfg_params->cc_switch_mode;
3423#endif
Krunal Sonia2c0e412017-05-04 14:12:41 +05303424 pParam->enable_tx_ldpc = cfg_params->tx_ldpc_enable;
3425 pParam->enable_rx_ldpc = cfg_params->rx_ldpc_enable;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08003426 pParam->wep_tkip_in_he = cfg_params->wep_tkip_in_he;
Krunal Soni158bfe62017-08-02 12:33:08 -07003427 pParam->disable_high_ht_mcs_2x2 = cfg_params->disable_high_ht_mcs_2x2;
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07003428 pParam->max_amsdu_num = cfg_params->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 pParam->nSelect5GHzMargin = cfg_params->nSelect5GHzMargin;
Abhinav Kumara083f212018-04-05 18:49:45 +05303430 pParam->ho_delay_for_rx = cfg_params->ho_delay_for_rx;
Abhinav Kumara95af7c2018-04-06 17:08:00 +05303431 pParam->min_delay_btw_roam_scans = cfg_params->min_delay_btw_roam_scans;
3432 pParam->roam_trigger_reason_bitmask =
3433 cfg_params->roam_trigger_reason_bitmask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 pParam->isCoalesingInIBSSAllowed = cfg_params->isCoalesingInIBSSAllowed;
3435 pParam->allowDFSChannelRoam = cfg_params->allowDFSChannelRoam;
3436 pParam->nInitialDwellTime = cfg_params->nInitialDwellTime;
3437 pParam->initial_scan_no_dfs_chnl = cfg_params->initial_scan_no_dfs_chnl;
3438#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3439 pParam->isRoamOffloadEnabled = cfg_params->isRoamOffloadEnabled;
3440#endif
3441 pParam->enable_dot11p = pMac->enable_dot11p;
3442 csr_set_channels(pMac, pParam);
3443 pParam->obssEnabled = cfg_params->obssEnabled;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303444 pParam->vendor_vht_sap =
3445 pMac->roam.configParam.vendor_vht_sap;
Gupta, Kapilc68ad462016-02-01 19:17:23 +05303446 pParam->roam_dense_rssi_thresh_offset =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303447 cfg_params->roam_params.dense_rssi_thresh_offset;
Gupta, Kapilc68ad462016-02-01 19:17:23 +05303448 pParam->roam_dense_min_aps =
3449 cfg_params->roam_params.dense_min_aps_cnt;
3450 pParam->roam_dense_traffic_thresh =
3451 cfg_params->roam_params.traffic_threshold;
3452
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -07003453 pParam->roam_bg_scan_bad_rssi_thresh =
3454 cfg_params->roam_params.bg_scan_bad_rssi_thresh;
3455 pParam->roam_bg_scan_client_bitmap =
3456 cfg_params->roam_params.bg_scan_client_bitmap;
Vignesh Viswanathanc018e982017-09-07 18:49:19 +05303457 pParam->roam_bad_rssi_thresh_offset_2g =
3458 cfg_params->roam_params.roam_bad_rssi_thresh_offset_2g;
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -07003459
Abhinav Kumar271f0632018-03-29 16:01:30 +05303460 pParam->enable_ftopen = cfg_params->enable_ftopen;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05303461 pParam->scan_adaptive_dwell_mode =
3462 cfg_params->scan_adaptive_dwell_mode;
Paul Zhang72697bd2017-12-20 09:24:25 +08003463 pParam->scan_adaptive_dwell_mode_nc =
3464 cfg_params->scan_adaptive_dwell_mode_nc;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05303465 pParam->roamscan_adaptive_dwell_mode =
3466 cfg_params->roamscan_adaptive_dwell_mode;
Kapil Gupta5cda2252016-12-29 18:44:26 +05303467
3468 pParam->per_roam_config.enable = cfg_params->per_roam_config.enable;
3469 pParam->per_roam_config.tx_high_rate_thresh =
3470 cfg_params->per_roam_config.tx_high_rate_thresh;
3471 pParam->per_roam_config.rx_high_rate_thresh =
3472 cfg_params->per_roam_config.rx_high_rate_thresh;
3473 pParam->per_roam_config.tx_low_rate_thresh =
3474 cfg_params->per_roam_config.tx_low_rate_thresh;
3475 pParam->per_roam_config.rx_low_rate_thresh =
3476 cfg_params->per_roam_config.rx_low_rate_thresh;
3477 pParam->per_roam_config.tx_rate_thresh_percnt =
3478 cfg_params->per_roam_config.tx_rate_thresh_percnt;
3479 pParam->per_roam_config.rx_rate_thresh_percnt =
3480 cfg_params->per_roam_config.rx_rate_thresh_percnt;
3481 pParam->per_roam_config.per_rest_time =
3482 cfg_params->per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +05303483 pParam->per_roam_config.tx_per_mon_time =
3484 cfg_params->per_roam_config.tx_per_mon_time;
3485 pParam->per_roam_config.rx_per_mon_time =
3486 cfg_params->per_roam_config.rx_per_mon_time;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +05303487 pParam->per_roam_config.min_candidate_rssi =
3488 cfg_params->per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +05303489
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 pParam->conc_custom_rule1 = cfg_params->conc_custom_rule1;
3491 pParam->conc_custom_rule2 = cfg_params->conc_custom_rule2;
3492 pParam->is_sta_connection_in_5gz_enabled =
3493 cfg_params->is_sta_connection_in_5gz_enabled;
Jeff Johnson1ad3fbd2017-11-03 08:00:02 -07003494 pParam->send_deauth_before_con =
3495 cfg_params->send_deauth_before_con;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 pParam->max_scan_count = pMac->scan.max_scan_count;
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08003497 pParam->first_scan_bucket_threshold =
3498 pMac->first_scan_bucket_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003499#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
3500 pParam->sap_channel_avoidance = pMac->sap.sap_channel_avoidance;
3501#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
gaoleze5108942017-03-31 16:56:42 +08003502 pParam->acs_with_more_param = pMac->sap.acs_with_more_param;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003503 pParam->max_intf_count = pMac->sme.max_intf_count;
3504 pParam->enableSelfRecovery = pMac->sme.enableSelfRecovery;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003505 pParam->f_prefer_non_dfs_on_radar =
3506 pMac->f_prefer_non_dfs_on_radar;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003507 pParam->dual_mac_feature_disable =
3508 pMac->dual_mac_feature_disable;
Ganesh Kondabattini930304c2017-10-10 15:25:36 +05303509 pParam->sta_sap_scc_on_dfs_chan =
3510 pMac->sta_sap_scc_on_dfs_chan;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003511 pParam->is_ps_enabled = pMac->sme.ps_global_info.ps_enabled;
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08003512 pParam->auto_bmps_timer_val =
3513 pMac->sme.ps_global_info.auto_bmps_timer_val;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003514 pParam->fEnableDebugLog = pMac->fEnableDebugLog;
3515 pParam->enable5gEBT = pMac->enable5gEBT;
3516 pParam->f_sta_miracast_mcc_rest_time_val =
3517 pMac->f_sta_miracast_mcc_rest_time_val;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003518 pParam->early_stop_scan_enable =
3519 pMac->roam.configParam.early_stop_scan_enable;
3520 pParam->early_stop_scan_min_threshold =
3521 pMac->roam.configParam.early_stop_scan_min_threshold;
3522 pParam->early_stop_scan_max_threshold =
3523 pMac->roam.configParam.early_stop_scan_max_threshold;
Sandeep Puligillae0875662016-02-12 16:09:21 -08003524 pParam->obss_width_interval =
3525 pMac->roam.configParam.obss_width_interval;
3526 pParam->obss_active_dwelltime =
3527 pMac->roam.configParam.obss_active_dwelltime;
3528 pParam->obss_passive_dwelltime =
3529 pMac->roam.configParam.obss_passive_dwelltime;
Abhishek Singh165bc602016-03-21 12:43:00 +05303530 pParam->ignore_peer_ht_opmode =
3531 pMac->roam.configParam.ignore_peer_ht_opmode;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08003532 pParam->enableHtSmps = pMac->roam.configParam.enableHtSmps;
3533 pParam->htSmps = pMac->roam.configParam.htSmps;
3534 pParam->send_smps_action = pMac->roam.configParam.send_smps_action;
Abhishek Singh10ecf582016-05-04 17:48:59 +05303535
3536 pParam->enable_edca_params =
3537 pMac->roam.configParam.enable_edca_params;
3538 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
3539 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
3540 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
3541 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
3542
3543 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
3544 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
3545 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
3546 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
3547
3548 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
3549 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
3550 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
3551 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
Abhishek Singh5ea86532016-04-27 14:10:53 +05303552 pParam->enable_fatal_event =
3553 pMac->roam.configParam.enable_fatal_event;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05303554 pParam->sta_roam_policy_params.dfs_mode =
3555 pMac->roam.configParam.sta_roam_policy.dfs_mode;
3556 pParam->sta_roam_policy_params.skip_unsafe_channels =
3557 pMac->roam.configParam.sta_roam_policy.skip_unsafe_channels;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303558 pParam->tx_aggregation_size =
3559 pMac->roam.configParam.tx_aggregation_size;
Paul Zhangee09f8e2018-04-23 16:11:32 +08003560 pParam->tx_aggregation_size_be =
3561 pMac->roam.configParam.tx_aggregation_size_be;
3562 pParam->tx_aggregation_size_bk =
3563 pMac->roam.configParam.tx_aggregation_size_bk;
3564 pParam->tx_aggregation_size_vi =
3565 pMac->roam.configParam.tx_aggregation_size_vi;
3566 pParam->tx_aggregation_size_vo =
3567 pMac->roam.configParam.tx_aggregation_size_vo;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303568 pParam->rx_aggregation_size =
3569 pMac->roam.configParam.rx_aggregation_size;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +05303570 pParam->enable_bcast_probe_rsp =
3571 pMac->roam.configParam.enable_bcast_probe_rsp;
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05303572 pParam->is_fils_enabled =
3573 pMac->roam.configParam.is_fils_enabled;
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05303574 pParam->qcn_ie_support =
3575 pMac->roam.configParam.qcn_ie_support;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +05303576 pParam->fils_max_chan_guard_time =
3577 pMac->roam.configParam.fils_max_chan_guard_time;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +05303578 pParam->disallow_duration =
3579 pMac->roam.configParam.disallow_duration;
3580 pParam->rssi_channel_penalization =
3581 pMac->roam.configParam.rssi_channel_penalization;
3582 pParam->num_disallowed_aps =
3583 pMac->roam.configParam.num_disallowed_aps;
Yeshwanth Sriram Guntuka2ba6fe92017-10-04 14:40:45 +05303584 pParam->oce_feature_bitmap =
3585 pMac->roam.configParam.oce_feature_bitmap;
Abhinav Kumaredd1d372018-05-11 15:33:35 +05303586 pParam->roam_force_rssi_trigger = cfg_params->roam_force_rssi_trigger;
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07003587 qdf_mem_copy(&pParam->csr_mawc_config,
3588 &pMac->roam.configParam.csr_mawc_config,
3589 sizeof(pParam->csr_mawc_config));
Sandeep Puligillae0875662016-02-12 16:09:21 -08003590
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05303591 qdf_mem_copy(&pParam->bss_score_params,
3592 &pMac->roam.configParam.bss_score_params,
3593 sizeof(struct sir_score_config));
yeshwanth sriram guntuka41f936c2017-09-01 17:53:49 +05303594 pParam->btm_offload_config = pMac->roam.configParam.btm_offload_config;
Jiachao Wu84bb2ea2018-01-08 16:17:33 +08003595 pParam->btm_solicited_timeout =
3596 pMac->roam.configParam.btm_solicited_timeout;
3597 pParam->btm_max_attempt_cnt =
3598 pMac->roam.configParam.btm_max_attempt_cnt;
3599 pParam->btm_sticky_time = pMac->roam.configParam.btm_sticky_time;
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05303600
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05303601 pParam->mbo_thresholds.mbo_candidate_rssi_thres =
3602 pMac->roam.configParam.mbo_thresholds.
3603 mbo_candidate_rssi_thres;
3604 pParam->mbo_thresholds.mbo_current_rssi_thres =
3605 pMac->roam.configParam.mbo_thresholds.
3606 mbo_current_rssi_thres;
3607 pParam->mbo_thresholds.mbo_current_rssi_mcc_thres =
3608 pMac->roam.configParam.mbo_thresholds.
3609 mbo_current_rssi_mcc_thres;
3610 pParam->mbo_thresholds.mbo_candidate_rssi_btc_thres =
3611 pMac->roam.configParam.mbo_thresholds.
3612 mbo_candidate_rssi_btc_thres;
3613
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08003614 csr_get_he_config_param(pParam, pMac);
3615
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05303616 csr_get_11k_offload_config_param(&pMac->roam.configParam, pParam);
3617
Liangwei Dong81935512018-04-12 23:35:01 -04003618 pParam->wlm_latency_enable = pMac->roam.configParam.wlm_latency_enable;
3619 pParam->wlm_latency_level = pMac->roam.configParam.wlm_latency_level;
3620 for (i = 0; i < CSR_NUM_WLM_LATENCY_LEVEL; i++) {
3621 pParam->wlm_latency_flags[i] =
3622 pMac->roam.configParam.wlm_latency_flags[i];
3623 }
3624
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303625 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626}
3627
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003628QDF_STATUS csr_set_phy_mode(tHalHandle hHal, uint32_t phyMode,
3629 enum band_info eBand, bool *pfRestartNeeded)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303631 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3633 bool fRestartNeeded = false;
3634 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303635
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003636 if (BAND_2G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 if (CSR_IS_RADIO_A_ONLY(pMac))
3638 goto end;
3639 if (eCSR_DOT11_MODE_11a & phyMode)
3640 goto end;
3641 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003642 if (BAND_5G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 if (CSR_IS_RADIO_BG_ONLY(pMac))
3644 goto end;
3645 if ((eCSR_DOT11_MODE_11b & phyMode)
3646 || (eCSR_DOT11_MODE_11b_ONLY & phyMode)
3647 || (eCSR_DOT11_MODE_11g & phyMode)
3648 || (eCSR_DOT11_MODE_11g_ONLY & phyMode))
3649 goto end;
3650 }
3651 if (eCSR_DOT11_MODE_AUTO & phyMode)
3652 newPhyMode = eCSR_DOT11_MODE_AUTO;
3653 else {
3654 /* Check for dual band and higher capability first */
3655 if (eCSR_DOT11_MODE_11n_ONLY & phyMode) {
3656 if (eCSR_DOT11_MODE_11n_ONLY != phyMode)
3657 goto end;
3658 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
3659 } else if (eCSR_DOT11_MODE_11g_ONLY & phyMode) {
3660 if (eCSR_DOT11_MODE_11g_ONLY != phyMode)
3661 goto end;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003662 if (BAND_5G == eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 goto end;
3664 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003665 eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 } else if (eCSR_DOT11_MODE_11b_ONLY & phyMode) {
3667 if (eCSR_DOT11_MODE_11b_ONLY != phyMode)
3668 goto end;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003669 if (BAND_5G == eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 goto end;
3671 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003672 eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 } else if (eCSR_DOT11_MODE_11n & phyMode) {
3674 newPhyMode = eCSR_DOT11_MODE_11n;
3675 } else if (eCSR_DOT11_MODE_abg & phyMode) {
3676 newPhyMode = eCSR_DOT11_MODE_abg;
3677 } else if (eCSR_DOT11_MODE_11a & phyMode) {
3678 if ((eCSR_DOT11_MODE_11g & phyMode)
3679 || (eCSR_DOT11_MODE_11b & phyMode)) {
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003680 if (BAND_ALL == eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 newPhyMode = eCSR_DOT11_MODE_abg;
3682 else
3683 goto end;
3684 } else {
3685 newPhyMode = eCSR_DOT11_MODE_11a;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003686 eBand = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 }
3688 } else if (eCSR_DOT11_MODE_11g & phyMode) {
3689 newPhyMode = eCSR_DOT11_MODE_11g;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003690 eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 } else if (eCSR_DOT11_MODE_11b & phyMode) {
3692 newPhyMode = eCSR_DOT11_MODE_11b;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003693 eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003695 sme_err("can't recognize phymode 0x%08X", phyMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 newPhyMode = eCSR_DOT11_MODE_AUTO;
3697 }
3698 }
3699 /* Done validating */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303700 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 /* Now we need to check whether a restart is needed. */
3702 if (eBand != pMac->roam.configParam.eBand) {
3703 fRestartNeeded = true;
3704 goto end;
3705 }
3706 if (newPhyMode != pMac->roam.configParam.phyMode) {
3707 fRestartNeeded = true;
3708 goto end;
3709 }
3710end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303711 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712 pMac->roam.configParam.eBand = eBand;
3713 pMac->roam.configParam.phyMode = newPhyMode;
3714 if (pfRestartNeeded)
3715 *pfRestartNeeded = fRestartNeeded;
3716 }
3717 return status;
3718}
3719
3720/**
3721 * csr_prune_ch_list() - prunes the channel list to keep only a type of channels
3722 * @ch_lst: existing channel list
3723 * @is_24_GHz: indicates if 2.5 GHz or 5 GHz channels are required
3724 *
3725 * Return: void
3726 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303727static void csr_prune_ch_list(struct csr_channel *ch_lst, bool is_24_GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728{
3729 uint8_t idx = 0, num_channels = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 for ( ; idx < ch_lst->numChannels; idx++) {
3732 if (is_24_GHz) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003733 if (WLAN_REG_IS_24GHZ_CH(ch_lst->channelList[idx])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 ch_lst->channelList[num_channels] =
3735 ch_lst->channelList[idx];
3736 num_channels++;
3737 }
3738 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003739 if (WLAN_REG_IS_5GHZ_CH(ch_lst->channelList[idx])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740 ch_lst->channelList[num_channels] =
3741 ch_lst->channelList[idx];
3742 num_channels++;
3743 }
3744 }
3745 }
3746 /*
3747 * Cleanup the rest of channels. Note we only need to clean up the
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303748 * channels if we had to trim the list. Calling qdf_mem_set() with a 0
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749 * size is going to throw asserts on the debug builds so let's be a bit
3750 * smarter about that. Zero out the reset of the channels only if we
3751 * need to. The amount of memory to clear is the number of channesl that
3752 * we trimmed (ch_lst->numChannels - num_channels) times the size of a
3753 * channel in the structure.
3754 */
3755 if (ch_lst->numChannels > num_channels) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303756 qdf_mem_set(&ch_lst->channelList[num_channels],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003757 sizeof(ch_lst->channelList[0]) *
3758 (ch_lst->numChannels - num_channels), 0);
3759 }
3760 ch_lst->numChannels = num_channels;
3761}
3762
3763/**
3764 * csr_prune_channel_list_for_mode() - prunes the channel list
3765 * @mac_ctx: global mac context
3766 * @ch_lst: existing channel list
3767 *
3768 * Prunes the channel list according to band stored in mac_ctx
3769 *
3770 * Return: void
3771 */
3772void csr_prune_channel_list_for_mode(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303773 struct csr_channel *ch_lst)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774{
3775 /* for dual band NICs, don't need to trim the channel list.... */
3776 if (CSR_IS_OPEARTING_DUAL_BAND(mac_ctx))
3777 return;
3778 /*
3779 * 2.4 GHz band operation requires the channel list to be trimmed to
3780 * the 2.4 GHz channels only
3781 */
3782 if (CSR_IS_24_BAND_ONLY(mac_ctx))
3783 csr_prune_ch_list(ch_lst, true);
3784 else if (CSR_IS_5G_BAND_ONLY(mac_ctx))
3785 csr_prune_ch_list(ch_lst, false);
3786}
3787
3788#define INFRA_AP_DEFAULT_CHANNEL 6
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789QDF_STATUS csr_is_valid_channel(tpAniSirGlobal pMac, uint8_t chnNum)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790{
3791 uint8_t index = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303792 QDF_STATUS status = QDF_STATUS_E_NOSUPPORT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793
3794 /* regulatory check */
3795 for (index = 0; index < pMac->scan.base_channels.numChannels;
3796 index++) {
3797 if (pMac->scan.base_channels.channelList[index] == chnNum) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303798 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 break;
3800 }
3801 }
3802
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303803 if (status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 /* dfs nol */
3805 for (index = 0;
3806 index <
3807 pMac->sap.SapDfsInfo.numCurrentRegDomainDfsChannels;
3808 index++) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303809 tSapDfsNolInfo *dfsChan = &pMac->sap.SapDfsInfo.
3810 sapDfsChannelNolList[index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003811 if ((dfsChan->dfs_channel_number == chnNum)
3812 && (dfsChan->radar_status_flag ==
3813 eSAP_DFS_CHANNEL_UNAVAILABLE)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303814 QDF_TRACE(QDF_MODULE_ID_SME,
3815 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003816 FL("channel %d is in dfs nol"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 chnNum);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303818 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 break;
3820 }
3821 }
3822 }
3823
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303824 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303825 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003826 FL("channel %d is not available"), chnNum);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 }
3828
3829 return status;
3830}
3831
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303832QDF_STATUS csr_get_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303834 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835 uint8_t num20MHzChannelsFound = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303836 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837 uint8_t Index = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003838
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003839 qdf_status = wlan_reg_get_channel_list_with_power(pMac->pdev,
3840 pMac->scan.defaultPowerTable,
3841 &num20MHzChannelsFound);
Amar Singhal7ccdc4f2015-10-30 15:10:05 -07003842
3843 if ((QDF_STATUS_SUCCESS != qdf_status) ||
3844 (num20MHzChannelsFound == 0)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003845 sme_err("failed to get channels");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303846 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303848 if (num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
3851 /* Move the channel list to the global data */
3852 /* structure -- this will be used as the scan list */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303853 for (Index = 0; Index < num20MHzChannelsFound; Index++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 pMac->scan.base_channels.channelList[Index] =
Amar Singhala297bfa2015-10-15 15:07:29 -07003855 pMac->scan.defaultPowerTable[Index].chan_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 pMac->scan.base_channels.numChannels =
3857 num20MHzChannelsFound;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858 }
3859 return status;
3860}
3861
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303862QDF_STATUS csr_apply_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303864 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865
3866 csr_prune_channel_list_for_mode(pMac, &pMac->scan.base_channels);
3867 csr_save_channel_power_for_band(pMac, false);
3868 csr_save_channel_power_for_band(pMac, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 csr_apply_channel_power_info_to_fw(pMac,
3870 &pMac->scan.base_channels,
3871 pMac->scan.countryCodeCurrent);
3872
3873 csr_init_operating_classes((tHalHandle) pMac);
3874 return status;
3875}
3876
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303877static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303879 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880 uint8_t index;
3881 uint32_t count = 0;
3882 tSirMacChanInfo *pChanInfo;
3883 tSirMacChanInfo *pChanInfoStart;
3884 bool applyConfig = true;
3885
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303886 if (!ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 return status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303888
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 if (ps11dinfo->Channels.numChannels
3890 && (WNI_CFG_VALID_CHANNEL_LIST_LEN >=
3891 ps11dinfo->Channels.numChannels)) {
3892 pMac->scan.base_channels.numChannels =
3893 ps11dinfo->Channels.numChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303894 qdf_mem_copy(pMac->scan.base_channels.channelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 ps11dinfo->Channels.channelList,
3896 ps11dinfo->Channels.numChannels);
3897 } else {
3898 /* No change */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303899 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003900 }
3901 /* legacy maintenance */
3902
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303903 qdf_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904 WNI_CFG_COUNTRY_CODE_LEN);
3905
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303906 /* Tush: at csropen get this initialized with default,
3907 * during csr reset if this already set with some value
3908 * no need initilaize with default again
3909 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 if (0 == pMac->scan.countryCodeCurrent[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303911 qdf_mem_copy(pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
3913 }
3914 /* need to add the max power channel list */
3915 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303916 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 WNI_CFG_VALID_CHANNEL_LIST_LEN);
3918 if (pChanInfo != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 pChanInfoStart = pChanInfo;
3920 for (index = 0; index < ps11dinfo->Channels.numChannels;
3921 index++) {
3922 pChanInfo->firstChanNum =
3923 ps11dinfo->ChnPower[index].firstChannel;
3924 pChanInfo->numChannels =
3925 ps11dinfo->ChnPower[index].numChannels;
3926 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303927 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928 pMac->roam.configParam.nTxPowerCap);
3929 pChanInfo++;
3930 count++;
3931 }
3932 if (count) {
Ravi Kumar Bokkac20393f2017-07-27 12:49:52 +05303933 status = csr_save_to_channel_power2_g_5_g(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003934 count *
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303935 sizeof(tSirMacChanInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 pChanInfoStart);
3937 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303938 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303940 /* Only apply them to CFG when not in STOP state.
3941 * Otherwise they will be applied later
3942 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303943 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 for (index = 0; index < CSR_ROAM_SESSION_MAX; index++) {
3945 if ((CSR_IS_SESSION_VALID(pMac, index))
3946 && CSR_IS_ROAM_STOP(pMac, index)) {
3947 applyConfig = false;
3948 }
3949 }
3950
3951 if (true == applyConfig) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303952 /* Apply the base channel list, power info,
3953 * and set the Country code.
3954 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955 csr_apply_channel_power_info_to_fw(pMac,
3956 &pMac->scan.
3957 base_channels,
3958 pMac->scan.
3959 countryCodeCurrent);
3960 }
3961 }
3962 return status;
3963}
3964
3965/* Initialize the Channel + Power List in the local cache and in the CFG */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303966QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac,
3967 tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968{
3969 uint8_t index;
3970 uint32_t count = 0;
3971 tSirMacChanInfo *pChanInfo;
3972 tSirMacChanInfo *pChanInfoStart;
3973
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303974 if (!ps11dinfo || !pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303975 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976
3977 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303978 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 WNI_CFG_VALID_CHANNEL_LIST_LEN);
3980 if (pChanInfo != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981 pChanInfoStart = pChanInfo;
3982
3983 for (index = 0; index < ps11dinfo->Channels.numChannels;
3984 index++) {
3985 pChanInfo->firstChanNum =
3986 ps11dinfo->ChnPower[index].firstChannel;
3987 pChanInfo->numChannels =
3988 ps11dinfo->ChnPower[index].numChannels;
3989 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303990 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 pMac->roam.configParam.nTxPowerCap);
3992 pChanInfo++;
3993 count++;
3994 }
3995 if (count) {
3996 csr_save_to_channel_power2_g_5_g(pMac,
3997 count *
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303998 sizeof(tSirMacChanInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 pChanInfoStart);
4000 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304001 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 }
4003
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304004 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005}
4006
Abhishek Singhd86d9832015-12-30 17:18:13 +05304007/**
4008 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
4009 * list
4010 *
4011 * @mac_ctx: pointer to global mac
4012 * @session_id: session id for the cmd
4013 * @list: pending list from which cmd needs to be removed
4014 * @command: cmd to be removed, can be NULL
4015 * @roam_reason: cmd with reason to be removed
4016 *
4017 * Remove duplicate command from the pending list.
4018 *
4019 * Return: void
4020 */
Krunal Soni72dba662017-02-15 20:13:17 -08004021static void csr_roam_remove_duplicate_pending_cmd_from_list(
4022 tpAniSirGlobal mac_ctx,
4023 uint32_t session_id,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304024 tSmeCmd *command, enum csr_roam_reason roam_reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025{
Abhishek Singhd86d9832015-12-30 17:18:13 +05304026 tListElem *entry, *next_entry;
4027 tSmeCmd *dup_cmd;
4028 tDblLinkList local_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029
Abhishek Singhd86d9832015-12-30 17:18:13 +05304030 qdf_mem_zero(&local_list, sizeof(tDblLinkList));
Jeff Johnson616417f2018-06-27 10:20:53 -07004031 if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(&local_list))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004032 sme_err("failed to open list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 return;
4034 }
Krunal Soni72dba662017-02-15 20:13:17 -08004035 csr_nonscan_pending_ll_lock(mac_ctx);
Krunal Sonia8270f52017-02-23 19:51:25 -08004036 entry = csr_nonscan_pending_ll_peek_head(mac_ctx, LL_ACCESS_NOLOCK);
Abhishek Singhd86d9832015-12-30 17:18:13 +05304037 while (entry) {
Krunal Soni72dba662017-02-15 20:13:17 -08004038 next_entry = csr_nonscan_pending_ll_next(mac_ctx, entry,
4039 LL_ACCESS_NOLOCK);
Abhishek Singhd86d9832015-12-30 17:18:13 +05304040 dup_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
4041 /*
Abhinav Kumar74948192018-05-09 17:17:50 +05304042 * If command is not NULL remove the similar duplicate cmd for
4043 * same reason as command. If command is NULL then check if
4044 * roam_reason is eCsrForcedDisassoc (disconnect) and remove
4045 * all roam command for the sessionId, else if roam_reason is
4046 * eCsrHddIssued (connect) remove all connect (non disconenct)
4047 * commands.
Abhishek Singhd86d9832015-12-30 17:18:13 +05304048 */
4049 if ((command && (command->sessionId == dup_cmd->sessionId) &&
4050 ((command->command == dup_cmd->command) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 /*
Jeff Johnson265d6a72018-05-12 09:46:20 -07004052 * This peermac check is required for Softap/GO
Abhishek Singhd86d9832015-12-30 17:18:13 +05304053 * scenarios. for STA scenario below OR check will
4054 * suffice as command will always be NULL for
4055 * STA scenarios
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 */
Abhishek Singhd86d9832015-12-30 17:18:13 +05304057 (!qdf_mem_cmp(dup_cmd->u.roamCmd.peerMac,
4058 command->u.roamCmd.peerMac,
4059 sizeof(QDF_MAC_ADDR_SIZE))) &&
4060 ((command->u.roamCmd.roamReason ==
4061 dup_cmd->u.roamCmd.roamReason) ||
4062 (eCsrForcedDisassoc ==
4063 command->u.roamCmd.roamReason) ||
4064 (eCsrHddIssued ==
4065 command->u.roamCmd.roamReason)))) ||
4066 /* OR if pCommand is NULL */
4067 ((session_id == dup_cmd->sessionId) &&
4068 (eSmeCommandRoam == dup_cmd->command) &&
4069 ((eCsrForcedDisassoc == roam_reason) ||
Abhinav Kumar74948192018-05-09 17:17:50 +05304070 (eCsrHddIssued == roam_reason &&
4071 !CSR_IS_DISCONNECT_COMMAND(dup_cmd))))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304072 sme_debug("RoamReason: %d",
4073 dup_cmd->u.roamCmd.roamReason);
Abhishek Singhd86d9832015-12-30 17:18:13 +05304074 /* Remove the roam command from the pending list */
Krunal Soni72dba662017-02-15 20:13:17 -08004075 if (csr_nonscan_pending_ll_remove_entry(mac_ctx,
4076 entry, LL_ACCESS_NOLOCK))
Abhishek Singhd86d9832015-12-30 17:18:13 +05304077 csr_ll_insert_tail(&local_list, entry,
4078 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05304080 entry = next_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 }
Krunal Soni72dba662017-02-15 20:13:17 -08004082 csr_nonscan_pending_ll_unlock(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083
Abhishek Singhd86d9832015-12-30 17:18:13 +05304084 while ((entry = csr_ll_remove_head(&local_list, LL_ACCESS_NOLOCK))) {
4085 dup_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 /* Tell caller that the command is cancelled */
Abhishek Singhd86d9832015-12-30 17:18:13 +05304087 csr_roam_call_callback(mac_ctx, dup_cmd->sessionId, NULL,
4088 dup_cmd->u.roamCmd.roamId,
4089 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Krunal Sonidea45952017-02-15 11:58:15 -08004090 csr_release_command(mac_ctx, dup_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05304092 csr_ll_close(&local_list);
4093}
4094
4095/**
4096 * csr_roam_remove_duplicate_command()- Remove duplicate roam cmd
4097 * from pending lists.
4098 *
4099 * @mac_ctx: pointer to global mac
4100 * @session_id: session id for the cmd
4101 * @command: cmd to be removed, can be null
4102 * @roam_reason: cmd with reason to be removed
4103 *
4104 * Remove duplicate command from the sme and roam pending list.
4105 *
4106 * Return: void
4107 */
4108void csr_roam_remove_duplicate_command(tpAniSirGlobal mac_ctx,
4109 uint32_t session_id, tSmeCmd *command,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304110 enum csr_roam_reason roam_reason)
Abhishek Singhd86d9832015-12-30 17:18:13 +05304111{
4112 /* Always lock active list before locking pending lists */
Krunal Soni20126cb2017-02-15 16:26:57 -08004113 csr_nonscan_active_ll_lock(mac_ctx);
Krunal Soni72dba662017-02-15 20:13:17 -08004114 csr_roam_remove_duplicate_pending_cmd_from_list(mac_ctx,
4115 session_id, command, roam_reason);
Krunal Soni20126cb2017-02-15 16:26:57 -08004116 csr_nonscan_active_ll_unlock(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117}
4118
4119/**
4120 * csr_roam_populate_channels() - Helper function to populate channels
4121 * @beacon_ies: pointer to beacon ie
4122 * @roam_info: Roaming related information
4123 * @chan1: center freq 1
4124 * @chan2: center freq2
4125 *
4126 * This function will issue populate chan1 and chan2 based on beacon ie
4127 *
4128 * Return: none.
4129 */
4130static void csr_roam_populate_channels(tDot11fBeaconIEs *beacon_ies,
Jeff Johnson172237b2017-11-07 15:32:59 -08004131 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 uint8_t *chan1, uint8_t *chan2)
4133{
4134 ePhyChanBondState phy_state;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 if (beacon_ies->VHTOperation.present) {
4137 *chan1 = beacon_ies->VHTOperation.chanCenterFreqSeg1;
4138 *chan2 = beacon_ies->VHTOperation.chanCenterFreqSeg2;
4139 roam_info->chan_info.info = MODE_11AC_VHT80;
4140 } else if (beacon_ies->HTInfo.present) {
4141 if (beacon_ies->HTInfo.recommendedTxWidthSet ==
4142 eHT_CHANNEL_WIDTH_40MHZ) {
4143 phy_state = beacon_ies->HTInfo.secondaryChannelOffset;
4144 if (phy_state == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
4145 *chan1 = beacon_ies->HTInfo.primaryChannel +
4146 CSR_CB_CENTER_CHANNEL_OFFSET;
4147 else if (phy_state == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
4148 *chan1 = beacon_ies->HTInfo.primaryChannel -
4149 CSR_CB_CENTER_CHANNEL_OFFSET;
4150 else
4151 *chan1 = beacon_ies->HTInfo.primaryChannel;
4152
4153 roam_info->chan_info.info = MODE_11NA_HT40;
4154 } else {
4155 *chan1 = beacon_ies->HTInfo.primaryChannel;
4156 roam_info->chan_info.info = MODE_11NA_HT20;
4157 }
4158 *chan2 = 0;
4159 } else {
4160 *chan1 = 0;
4161 *chan2 = 0;
4162 roam_info->chan_info.info = MODE_11A;
4163 }
4164}
4165
Krunal Soni4b6c9462018-03-09 15:56:56 -08004166#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4167static const char *csr_get_ch_width_str(uint8_t ch_width)
4168{
4169 switch (ch_width) {
4170 CASE_RETURN_STRING(BW_20MHZ);
4171 CASE_RETURN_STRING(BW_40MHZ);
4172 CASE_RETURN_STRING(BW_80MHZ);
4173 CASE_RETURN_STRING(BW_160MHZ);
4174 CASE_RETURN_STRING(BW_80P80MHZ);
4175 CASE_RETURN_STRING(BW_5MHZ);
4176 CASE_RETURN_STRING(BW_10MHZ);
4177 default:
4178 return "Unknown";
4179 }
4180}
4181
4182static const char *csr_get_dot11_mode_str(enum csr_cfgdot11mode dot11mode)
4183{
4184 switch (dot11mode) {
4185 CASE_RETURN_STRING(DOT11_MODE_AUTO);
4186 CASE_RETURN_STRING(DOT11_MODE_ABG);
4187 CASE_RETURN_STRING(DOT11_MODE_11A);
4188 CASE_RETURN_STRING(DOT11_MODE_11B);
4189 CASE_RETURN_STRING(DOT11_MODE_11G);
4190 CASE_RETURN_STRING(DOT11_MODE_11N);
4191 CASE_RETURN_STRING(DOT11_MODE_11AC);
4192 CASE_RETURN_STRING(DOT11_MODE_11G_ONLY);
4193 CASE_RETURN_STRING(DOT11_MODE_11N_ONLY);
4194 CASE_RETURN_STRING(DOT11_MODE_11AC_ONLY);
4195 CASE_RETURN_STRING(DOT11_MODE_11AX);
4196 CASE_RETURN_STRING(DOT11_MODE_11AX_ONLY);
4197 default:
4198 return "Unknown";
4199 }
4200}
4201
4202static const char *csr_get_auth_type_str(uint8_t auth_type)
4203{
4204 switch (auth_type) {
4205 CASE_RETURN_STRING(AUTH_OPEN);
4206 CASE_RETURN_STRING(AUTH_SHARED);
4207 CASE_RETURN_STRING(AUTH_WPA_EAP);
4208 CASE_RETURN_STRING(AUTH_WPA_PSK);
4209 CASE_RETURN_STRING(AUTH_WPA2_EAP);
4210 CASE_RETURN_STRING(AUTH_WPA2_PSK);
4211 CASE_RETURN_STRING(AUTH_WAPI_CERT);
4212 CASE_RETURN_STRING(AUTH_WAPI_PSK);
4213 default:
4214 return "Unknown";
4215 }
4216}
4217
4218static const char *csr_get_encr_type_str(uint8_t encr_type)
4219{
4220 switch (encr_type) {
4221 CASE_RETURN_STRING(ENC_MODE_OPEN);
4222 CASE_RETURN_STRING(ENC_MODE_WEP40);
4223 CASE_RETURN_STRING(ENC_MODE_WEP104);
4224 CASE_RETURN_STRING(ENC_MODE_TKIP);
4225 CASE_RETURN_STRING(ENC_MODE_AES);
4226 CASE_RETURN_STRING(ENC_MODE_AES_GCMP);
4227 CASE_RETURN_STRING(ENC_MODE_AES_GCMP_256);
4228 CASE_RETURN_STRING(ENC_MODE_SMS4);
4229 default:
4230 return "Unknown";
4231 }
4232}
4233
4234static void csr_dump_connection_stats(tpAniSirGlobal mac_ctx,
4235 struct csr_roam_session *session,
4236 struct csr_roam_info *roam_info,
4237 eRoamCmdStatus u1, eCsrRoamResult u2)
4238{
4239 struct tagCsrRoamConnectedProfile *conn_profile;
4240 struct csr_roam_profile *profile;
4241 WLAN_HOST_DIAG_EVENT_DEF(conn_stats,
4242 struct host_event_wlan_connection_stats);
4243
4244 if (!session || !session->pCurRoamProfile || !roam_info)
4245 return;
4246
4247 conn_profile = roam_info->u.pConnectedProfile;
4248 if (!conn_profile)
4249 return;
4250 profile = session->pCurRoamProfile;
4251 qdf_mem_set(&conn_stats,
4252 sizeof(struct host_event_wlan_connection_stats), 0);
4253 qdf_mem_copy(conn_stats.bssid, conn_profile->bssid.bytes,
4254 QDF_MAC_ADDR_SIZE);
4255 conn_stats.ssid_len = conn_profile->SSID.length;
4256 if (conn_stats.ssid_len > SIR_MAC_MAX_SSID_LENGTH)
4257 conn_stats.ssid_len = SIR_MAC_MAX_SSID_LENGTH;
4258 qdf_mem_copy(conn_stats.ssid, conn_profile->SSID.ssId,
4259 conn_stats.ssid_len);
Jeff Johnson0c4f4812018-06-10 20:47:54 -07004260 sme_get_rssi_snr_by_bssid(MAC_HANDLE(mac_ctx),
4261 session->pCurRoamProfile,
Krunal Soni4b6c9462018-03-09 15:56:56 -08004262 &conn_stats.bssid[0],
4263 &conn_stats.rssi, NULL);
4264 conn_stats.est_link_speed = 0;
4265 conn_stats.chnl_bw =
4266 diag_ch_width_from_csr_type(conn_profile->vht_channel_width);
4267 conn_stats.dot11mode =
4268 diag_dot11_mode_from_csr_type(conn_profile->dot11Mode);
4269 conn_stats.bss_type =
4270 diag_persona_from_csr_type(session->pCurRoamProfile->csrPersona);
4271 conn_stats.operating_channel = conn_profile->operationChannel;
4272 conn_stats.qos_capability = conn_profile->qosConnection;
4273 conn_stats.auth_type =
4274 diag_auth_type_from_csr_type(conn_profile->AuthType);
4275 conn_stats.encryption_type =
4276 diag_enc_type_from_csr_type(conn_profile->EncryptionType);
4277 conn_stats.result_code = (u2 == eCSR_ROAM_RESULT_ASSOCIATED) ? 1 : 0;
4278 conn_stats.reason_code = 0;
4279 sme_debug("+---------CONNECTION INFO START------------+");
4280 sme_debug("connection stats for session-id: %d", session->sessionId);
4281 sme_debug("ssid: %.*s", conn_stats.ssid_len, conn_stats.ssid);
4282 sme_debug("bssid: %pM", conn_stats.bssid);
4283 sme_debug("rssi: %d dBm", conn_stats.rssi);
4284 sme_debug("channel: %d", conn_stats.operating_channel);
4285 sme_debug("dot11Mode: %s",
4286 csr_get_dot11_mode_str(conn_stats.dot11mode));
4287 sme_debug("channel bw: %s",
4288 csr_get_ch_width_str(conn_stats.chnl_bw));
4289 sme_debug("Qos enable: %d", conn_stats.qos_capability);
4290 sme_debug("Auth-type: %s",
4291 csr_get_auth_type_str(conn_stats.auth_type));
4292 sme_debug("Encry-type: %s",
4293 csr_get_encr_type_str(conn_stats.encryption_type));
4294 sme_debug("is associated?: %s",
4295 (conn_stats.result_code ? "yes" : "no"));
4296 sme_debug("+---------CONNECTION INFO END------------+");
4297
4298 WLAN_HOST_DIAG_EVENT_REPORT(&conn_stats, EVENT_WLAN_CONN_STATS_V2);
4299}
4300#else
4301static void csr_dump_connection_stats(tpAniSirGlobal mac_ctx,
4302 struct csr_roam_session *session,
4303 struct csr_roam_info *roam_info,
4304 eRoamCmdStatus u1, eCsrRoamResult u2)
4305{}
4306
4307#endif
4308
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304309QDF_STATUS csr_roam_call_callback(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson172237b2017-11-07 15:32:59 -08004310 struct csr_roam_info *roam_info,
4311 uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 eRoamCmdStatus u1, eCsrRoamResult u2)
4313{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304314 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4316 uint32_t rssi = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304317
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 WLAN_HOST_DIAG_EVENT_DEF(connectionStatus,
4319 host_event_wlan_status_payload_type);
4320#endif
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304321 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 tDot11fBeaconIEs *beacon_ies = NULL;
4323 uint8_t chan1, chan2;
4324
4325 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004326 sme_err("Session ID: %d is not valid", sessionId);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304327 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304328 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 }
4330 pSession = CSR_GET_SESSION(pMac, sessionId);
4331
4332 if (false == pSession->sessionActive) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004333 sme_debug("Session is not Active");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304334 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 }
4336
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1 &&
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004338 eCSR_ROAM_RESULT_ASSOCIATED == u2 && roam_info) {
Abhinav Kumar50d4dc72018-06-15 16:35:50 +05304339 sme_debug("Assoc complete result: %d status: %d reason: %d",
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004340 u2, roam_info->statusCode, roam_info->reasonCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304341 beacon_ies = qdf_mem_malloc(sizeof(tDot11fBeaconIEs));
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004342 if ((NULL != beacon_ies) && (NULL != roam_info->pBssDesc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343 status = csr_parse_bss_description_ies(
Jeff Johnsonc0749332018-06-10 20:41:07 -07004344 pMac, roam_info->pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004345 beacon_ies);
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004346 csr_roam_populate_channels(beacon_ies, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 &chan1, &chan2);
4348 if (0 != chan1)
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004349 roam_info->chan_info.band_center_freq1 =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004350 cds_chan_to_freq(chan1);
4351 else
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004352 roam_info->chan_info.band_center_freq1 = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 if (0 != chan2)
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004354 roam_info->chan_info.band_center_freq2 =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355 cds_chan_to_freq(chan2);
4356 else
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004357 roam_info->chan_info.band_center_freq2 = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358 } else {
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004359 roam_info->chan_info.band_center_freq1 = 0;
4360 roam_info->chan_info.band_center_freq2 = 0;
4361 roam_info->chan_info.info = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 }
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004363 roam_info->chan_info.chan_id =
4364 roam_info->u.pConnectedProfile->operationChannel;
4365 roam_info->chan_info.mhz =
4366 cds_chan_to_freq(roam_info->chan_info.chan_id);
4367 roam_info->chan_info.reg_info_1 =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368 (csr_get_cfg_max_tx_power(pMac,
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004369 roam_info->chan_info.chan_id) << 16);
4370 roam_info->chan_info.reg_info_2 =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 (csr_get_cfg_max_tx_power(pMac,
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004372 roam_info->chan_info.chan_id) << 8);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304373 qdf_mem_free(beacon_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 } else if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED)
4375 && (pSession->bRefAssocStartCnt)) {
4376 /*
4377 * Decrement bRefAssocStartCnt for FT reassoc failure.
4378 * Reason: For FT reassoc failures, we first call
4379 * csr_roam_call_callback before notifying a failed roam
4380 * completion through csr_roam_complete. The latter in
4381 * turn calls csr_roam_process_results which tries to
4382 * once again call csr_roam_call_callback if bRefAssocStartCnt
4383 * is non-zero. Since this is redundant for FT reassoc
4384 * failure, decrement bRefAssocStartCnt.
4385 */
4386 pSession->bRefAssocStartCnt--;
Naveen Rawatc3411bb2018-04-30 14:28:52 -07004387 } else if (roam_info && (u1 == eCSR_ROAM_SET_CHANNEL_RSP)
4388 && (u2 == eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004389 pSession->connectedProfile.operationChannel =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004390 roam_info->channelChangeRespEvent->newChannelNumber;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004391 } else if ((u1 == eCSR_ROAM_SESSION_OPENED) &&
4392 (u2 == eCSR_ROAM_RESULT_NONE)) {
4393 if (pSession->session_open_cb)
4394 pSession->session_open_cb(sessionId);
4395 else
4396 sme_err("session_open_cb is not registered");
4397 }
Krunal Soni4b6c9462018-03-09 15:56:56 -08004398 if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
4399 csr_dump_connection_stats(pMac, pSession, roam_info, u1, u2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400
4401 if (NULL != pSession->callback) {
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004402 if (roam_info) {
4403 roam_info->sessionId = (uint8_t) sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 /*
4405 * the reasonCode will be passed to supplicant by
4406 * cfg80211_disconnected. Based on the document,
4407 * the reason code passed to supplicant needs to set
Jeff Johnsonbbca3d52018-05-10 14:59:38 -07004408 * to 0 if unknown. eSIR_BEACON_MISSED reason code is
4409 * not recognizable so that we set to 0 instead.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004411 roam_info->reasonCode =
4412 (roam_info->reasonCode == eSIR_BEACON_MISSED) ?
4413 0 : roam_info->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 }
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004415 status = pSession->callback(pSession->pContext, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 roamId, u1, u2);
4417 }
4418 /*
Abhishek Singh7a995582016-04-27 13:53:36 +05304419 * EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 * eCSR_ROAM_LOSTLINK,
4421 * eCSR_ROAM_DISASSOCIATED,
4422 */
4423#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304424 qdf_mem_set(&connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 sizeof(host_event_wlan_status_payload_type), 0);
4426
4427 if ((eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004428 && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && roam_info) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004429 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
4430 connectionStatus.bssType =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004431 roam_info->u.pConnectedProfile->BSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004433 if (NULL != roam_info->pBssDesc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004434 connectionStatus.rssi =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004435 roam_info->pBssDesc->rssi * (-1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 connectionStatus.channel =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004437 roam_info->pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 }
4439 if (cfg_set_int(pMac, WNI_CFG_CURRENT_RSSI,
Jeff Johnsonc09caa42018-06-07 22:58:55 -07004440 connectionStatus.rssi) == QDF_STATUS_E_FAILURE)
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004441 sme_err("Can't pass WNI_CFG_CURRENT_RSSI to cfg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442
4443 connectionStatus.qosCapability =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004444 roam_info->u.pConnectedProfile->qosConnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 connectionStatus.authType =
4446 (uint8_t) diag_auth_type_from_csr_type(
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004447 roam_info->u.pConnectedProfile->AuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004448 connectionStatus.encryptionType =
4449 (uint8_t) diag_enc_type_from_csr_type(
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004450 roam_info->u.pConnectedProfile->EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 qdf_mem_copy(connectionStatus.ssid,
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004452 roam_info->u.pConnectedProfile->SSID.ssId,
4453 roam_info->u.pConnectedProfile->SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454
4455 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304456 qdf_mem_copy(&pMac->sme.eventPayload, &connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 sizeof(host_event_wlan_status_payload_type));
4458 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304459 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 }
4461 if ((eCSR_ROAM_MIC_ERROR_IND == u1)
4462 || (eCSR_ROAM_RESULT_MIC_FAILURE == u2)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304463 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 sizeof(host_event_wlan_status_payload_type));
Jeff Johnsonc09caa42018-06-07 22:58:55 -07004465 if (QDF_IS_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 WNI_CFG_CURRENT_RSSI, &rssi)))
4467 connectionStatus.rssi = rssi;
4468
4469 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
4470 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
4471 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304472 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 }
4474 if (eCSR_ROAM_RESULT_FORCED == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304475 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476 sizeof(host_event_wlan_status_payload_type));
Jeff Johnsonc09caa42018-06-07 22:58:55 -07004477 if (QDF_IS_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 WNI_CFG_CURRENT_RSSI, &rssi)))
4479 connectionStatus.rssi = rssi;
4480
4481 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
4482 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
4483 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304484 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 }
4486 if (eCSR_ROAM_RESULT_DISASSOC_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304487 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 sizeof(host_event_wlan_status_payload_type));
Jeff Johnsonc09caa42018-06-07 22:58:55 -07004489 if (QDF_IS_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 WNI_CFG_CURRENT_RSSI, &rssi)))
4491 connectionStatus.rssi = rssi;
4492
4493 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
4494 connectionStatus.reason = eCSR_REASON_DISASSOC;
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004495 if (roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 connectionStatus.reasonDisconnect =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004497 roam_info->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498
4499 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304500 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 }
4502 if (eCSR_ROAM_RESULT_DEAUTH_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304503 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 sizeof(host_event_wlan_status_payload_type));
Jeff Johnsonc09caa42018-06-07 22:58:55 -07004505 if (QDF_IS_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506 WNI_CFG_CURRENT_RSSI, &rssi)))
4507 connectionStatus.rssi = rssi;
4508
4509 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
4510 connectionStatus.reason = eCSR_REASON_DEAUTH;
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004511 if (roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 connectionStatus.reasonDisconnect =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004513 roam_info->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304515 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 }
4517#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05304518
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 return status;
4520}
4521
4522/* Returns whether handoff is currently in progress or not */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004523static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524bool csr_roam_is_handoff_in_progress(tpAniSirGlobal pMac, uint8_t sessionId)
4525{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526 return csr_neighbor_roam_is_handoff_in_progress(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527}
4528
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004529static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304530QDF_STATUS csr_roam_issue_disassociate(tpAniSirGlobal pMac, uint32_t sessionId,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304531 enum csr_roam_substate NewSubstate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532 bool fMICFailure)
4533{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304534 QDF_STATUS status = QDF_STATUS_SUCCESS;
Dustin Brownce5b3d32018-01-17 15:07:38 -08004535 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BCAST_INIT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 uint16_t reasonCode;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304537 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538
4539 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004540 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304541 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 }
4543
4544 if (fMICFailure) {
4545 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
4546 } else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF) {
4547 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
4548 } else if (eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT == NewSubstate) {
4549 reasonCode = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
4550 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004551 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304552 "set to reason code eSIR_MAC_DISASSOC_LEAVING_BSS_REASON and set back NewSubstate");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 } else {
4554 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
4555 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 if ((csr_roam_is_handoff_in_progress(pMac, sessionId)) &&
4557 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)) {
4558 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
4559 &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanc5548422016-02-24 18:33:27 +05304560 qdf_copy_macaddr(&bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.
4562 bssid);
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08004563 } else if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304564 qdf_mem_copy(&bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304565 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 }
4567
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004568 sme_debug("CSR Attempting to Disassociate Bssid=" MAC_ADDRESS_STR
4569 " subState: %s reason: %d", MAC_ADDR_ARRAY(bssId.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570 mac_trace_getcsr_roam_sub_state(NewSubstate), reasonCode);
4571
4572 csr_roam_substate_change(pMac, NewSubstate, sessionId);
4573
4574 status = csr_send_mb_disassoc_req_msg(pMac, sessionId, bssId.bytes,
4575 reasonCode);
4576
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304577 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 csr_roam_link_down(pMac, sessionId);
4579#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304580 /* no need to tell QoS that we are disassociating, it will be
4581 * taken care off in assoc req for HO
4582 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 if (eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate) {
4584 /* notify QoS module that disassoc happening */
4585 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
4586 SME_QOS_CSR_DISCONNECT_REQ, NULL);
4587 }
4588#endif
4589 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004590 sme_warn("csr_send_mb_disassoc_req_msg failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 status);
4592 }
4593
4594 return status;
4595}
4596
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05304597/**
4598 * csr_roam_issue_disassociate_sta_cmd() - disassociate a associated station
4599 * @sessionId: Session Id for Soft AP
4600 * @p_del_sta_params: Pointer to parameters of the station to disassoc
4601 *
4602 * CSR function that HDD calls to delete a associated station
4603 *
4604 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_* on error
4605 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304606QDF_STATUS csr_roam_issue_disassociate_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 uint32_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08004608 struct csr_del_sta_params
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05304609 *p_del_sta_params)
4610
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304612 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 tSmeCmd *pCommand;
4614
4615 do {
4616 pCommand = csr_get_command_buffer(pMac);
4617 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004618 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304619 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 break;
4621 }
4622 pCommand->command = eSmeCommandRoam;
4623 pCommand->sessionId = (uint8_t) sessionId;
4624 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05304625 qdf_mem_copy(pCommand->u.roamCmd.peerMac,
4626 p_del_sta_params->peerMacAddr.bytes,
4627 sizeof(pCommand->u.roamCmd.peerMac));
4628 pCommand->u.roamCmd.reason =
4629 (tSirMacReasonCodes)p_del_sta_params->reason_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 status = csr_queue_sme_command(pMac, pCommand, false);
Krunal Soniaa179db2017-10-13 19:28:17 -07004631 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004632 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 } while (0);
4634
4635 return status;
4636}
4637
4638/**
4639 * csr_roam_issue_deauthSta() - delete a associated station
4640 * @sessionId: Session Id for Soft AP
4641 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
4642 *
4643 * CSR function that HDD calls to delete a associated station
4644 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304645 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304647QDF_STATUS csr_roam_issue_deauth_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 uint32_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08004649 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304651 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 tSmeCmd *pCommand;
4653
4654 do {
4655 pCommand = csr_get_command_buffer(pMac);
4656 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004657 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304658 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 break;
4660 }
4661 pCommand->command = eSmeCommandRoam;
4662 pCommand->sessionId = (uint8_t) sessionId;
4663 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304664 qdf_mem_copy(pCommand->u.roamCmd.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 pDelStaParams->peerMacAddr.bytes,
4666 sizeof(tSirMacAddr));
4667 pCommand->u.roamCmd.reason =
4668 (tSirMacReasonCodes)pDelStaParams->reason_code;
4669 status = csr_queue_sme_command(pMac, pCommand, false);
Krunal Soniaa179db2017-10-13 19:28:17 -07004670 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004671 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 } while (0);
4673
4674 return status;
4675}
4676
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304677QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678csr_roam_get_associated_stas(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304679 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680 void *pfnSapEventCallback, uint8_t *pAssocStasBuf)
4681{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304682 QDF_STATUS status = QDF_STATUS_SUCCESS;
Dustin Brownce5b3d32018-01-17 15:07:38 -08004683 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BCAST_INIT;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304684 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304687 sme_err("csr_roam_get_associated_stas:CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 return status;
4689 }
4690 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304691 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304692 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304694 sme_err("csr_roam_get_associated_stas:Connected BSS Description in CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 return status;
4696 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304697 sme_debug("CSR getting associated stations for Bssid: " MAC_ADDRESS_STR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004698 MAC_ADDR_ARRAY(bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 status =
4700 csr_send_mb_get_associated_stas_req_msg(pMac, sessionId, modId,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08004701 bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 pUsrContext,
4703 pfnSapEventCallback,
4704 pAssocStasBuf);
4705 return status;
4706}
4707
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004708static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304709QDF_STATUS csr_roam_issue_deauth(tpAniSirGlobal pMac, uint32_t sessionId,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304710 enum csr_roam_substate NewSubstate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304712 QDF_STATUS status = QDF_STATUS_SUCCESS;
Dustin Brownce5b3d32018-01-17 15:07:38 -08004713 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BCAST_INIT;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304714 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715
4716 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004717 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304718 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 }
4720
4721 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304722 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304723 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004725 sme_debug("CSR Attempting to Deauth Bssid= " MAC_ADDRESS_STR,
4726 MAC_ADDR_ARRAY(bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 csr_roam_substate_change(pMac, NewSubstate, sessionId);
4728
4729 status =
4730 csr_send_mb_deauth_req_msg(pMac, sessionId, bssId.bytes,
4731 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304732 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733 csr_roam_link_down(pMac, sessionId);
4734 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004735 sme_err("csr_send_mb_deauth_req_msg failed with status %d Session ID: %d"
4736 MAC_ADDRESS_STR, status, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737 MAC_ADDR_ARRAY(bssId.bytes));
4738 }
4739
4740 return status;
4741}
4742
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304743QDF_STATUS csr_roam_save_connected_bss_desc(tpAniSirGlobal pMac,
4744 uint32_t sessionId,
4745 tSirBssDescription *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304747 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304748 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 uint32_t size;
4750
4751 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004752 sme_err(" session %d not found ", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304753 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304755 /* If no BSS description was found in this connection
4756 * (happens with start IBSS), then nix the BSS description
4757 * that we keep around for the connected BSS) and get out.
4758 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 if (NULL == pBssDesc) {
4760 csr_free_connect_bss_desc(pMac, sessionId);
4761 } else {
4762 size = pBssDesc->length + sizeof(pBssDesc->length);
4763 if (NULL != pSession->pConnectBssDesc) {
4764 if (((pSession->pConnectBssDesc->length) +
4765 sizeof(pSession->pConnectBssDesc->length)) <
4766 size) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304767 /* not enough room for the new BSS,
4768 * pMac->roam.pConnectBssDesc is freed inside
4769 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 csr_free_connect_bss_desc(pMac, sessionId);
4771 }
4772 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304773 if (NULL == pSession->pConnectBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304774 pSession->pConnectBssDesc = qdf_mem_malloc(size);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304775
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776 if (NULL == pSession->pConnectBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304777 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004778 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304779 qdf_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004780 }
4781 return status;
4782}
4783
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004784static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304785QDF_STATUS csr_roam_prepare_bss_config(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07004786 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 tSirBssDescription *pBssDesc,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304788 struct bss_config_param *pBssConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 tDot11fBeaconIEs *pIes)
4790{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304791 enum csr_cfgdot11mode cfgDot11Mode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304792
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304793 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 if (pIes == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304795 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304797 qdf_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798 sizeof(tSirMacCapabilityInfo));
4799 /* get qos */
Jeff Johnson12ec0102018-06-03 16:26:55 -07004800 pBssConfig->qosType = csr_get_qos_from_bss_desc(pMac, pBssDesc, pIes);
Padma, Santhosh Kumar7eecb5a2018-02-28 19:37:20 +05304801 /* Take SSID always from profile */
4802 qdf_mem_copy(&pBssConfig->SSID.ssId,
4803 pProfile->SSIDs.SSIDList->SSID.ssId,
4804 pProfile->SSIDs.SSIDList->SSID.length);
4805 pBssConfig->SSID.length = pProfile->SSIDs.SSIDList->SSID.length;
4806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 if (csr_is_nullssid(pBssConfig->SSID.ssId, pBssConfig->SSID.length)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004808 sme_warn("BSS desc SSID is a wild card");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004809 /* Return failed if profile doesn't have an SSID either. */
4810 if (pProfile->SSIDs.numOfSSIDs == 0) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004811 sme_warn("BSS desc and profile doesn't have SSID");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304812 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004813 }
4814 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07004815 if (WLAN_REG_IS_5GHZ_CH(pBssDesc->channelId))
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004816 pBssConfig->eBand = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817 else
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004818 pBssConfig->eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819 /* phymode */
4820 if (csr_is_phy_mode_match(pMac, pProfile->phyMode, pBssDesc,
4821 pProfile, &cfgDot11Mode, pIes)) {
4822 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
4823 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004824 sme_warn("Can not find match phy mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825 /* force it */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004826 if (BAND_2G == pBssConfig->eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
4828 else
4829 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
4830 }
Padma, Santhosh Kumar19f57652017-05-26 18:03:45 +05304831
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05304832 sme_debug("phyMode=%d, uCfgDot11Mode=%d negotiatedAuthType %d",
4833 pProfile->phyMode, pBssConfig->uCfgDot11Mode,
4834 pProfile->negotiatedAuthType);
Padma, Santhosh Kumar19f57652017-05-26 18:03:45 +05304835
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836 /* Qos */
4837 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
4838 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos)) {
4839 /*
4840 * Joining BSS is not 11n capable and WMM is disabled on client.
4841 * Disable QoS and WMM
4842 */
4843 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
4844 }
4845
4846 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N)
4847 || (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC))
4848 && ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP)
4849 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF)
4850 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF))) {
4851 /* Joining BSS is 11n capable and WMM is disabled on AP. */
4852 /* Assume all HT AP's are QOS AP's and enable WMM */
4853 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
4854 }
4855 /* auth type */
4856 switch (pProfile->negotiatedAuthType) {
4857 default:
4858 case eCSR_AUTH_TYPE_WPA:
4859 case eCSR_AUTH_TYPE_WPA_PSK:
4860 case eCSR_AUTH_TYPE_WPA_NONE:
4861 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4862 pBssConfig->authType = eSIR_OPEN_SYSTEM;
4863 break;
4864 case eCSR_AUTH_TYPE_SHARED_KEY:
4865 pBssConfig->authType = eSIR_SHARED_KEY;
4866 break;
4867 case eCSR_AUTH_TYPE_AUTOSWITCH:
4868 pBssConfig->authType = eSIR_AUTO_SWITCH;
4869 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05304870 case eCSR_AUTH_TYPE_SAE:
4871 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
4872 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 }
4874 /* short slot time */
4875 if (eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode)
4876 pBssConfig->uShortSlotTime =
4877 pMac->roam.configParam.shortSlotTime;
4878 else
4879 pBssConfig->uShortSlotTime = 0;
4880
4881 if (pBssConfig->BssCap.ibss)
4882 /* We don't support 11h on IBSS */
4883 pBssConfig->f11hSupport = false;
4884 else
4885 pBssConfig->f11hSupport =
4886 pMac->roam.configParam.Is11hSupportEnabled;
4887 /* power constraint */
4888 pBssConfig->uPowerLimit =
4889 csr_get11h_power_constraint(pMac, &pIes->PowerConstraints);
4890 /* heartbeat */
4891 if (CSR_IS_11A_BSS(pBssDesc))
4892 pBssConfig->uHeartBeatThresh =
4893 pMac->roam.configParam.HeartbeatThresh50;
4894 else
4895 pBssConfig->uHeartBeatThresh =
4896 pMac->roam.configParam.HeartbeatThresh24;
4897
4898 /*
4899 * Join timeout: if we find a BeaconInterval in the BssDescription,
4900 * then set the Join Timeout to be 10 x the BeaconInterval.
4901 */
Naveen Rawate1fbbe02017-09-05 12:01:56 -07004902 if (pBssDesc->beaconInterval) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 /* Make sure it is bigger than the minimal */
4904 pBssConfig->uJoinTimeOut =
Anurag Chouhan6d760662016-02-20 16:05:43 +05304905 QDF_MAX(10 * pBssDesc->beaconInterval,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 CSR_JOIN_FAILURE_TIMEOUT_MIN);
yeshwanth sriram guntuka6d261f82017-08-24 15:56:47 +05304907 if (pBssConfig->uJoinTimeOut > CSR_JOIN_FAILURE_TIMEOUT_DEFAULT)
4908 pBssConfig->uJoinTimeOut =
4909 CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Naveen Rawate1fbbe02017-09-05 12:01:56 -07004910 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 pBssConfig->uJoinTimeOut =
4912 CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Naveen Rawate1fbbe02017-09-05 12:01:56 -07004913 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 /* validate CB */
Krishna Kumaar Natarajanf86c6ed2017-03-27 11:36:29 -07004915 if ((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
4916 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N_ONLY) ||
4917 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC) ||
4918 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC_ONLY) ||
4919 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AX) ||
4920 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AX_ONLY))
Kiran Kumar Lokere35fb5242017-03-10 20:16:44 -08004921 pBssConfig->cbMode = csr_get_cb_mode_from_ies(pMac,
4922 pBssDesc->channelId, pIes);
4923 else
4924 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925
Abhishek Singhb59f8d42017-07-31 14:42:47 +05304926 if (WLAN_REG_IS_24GHZ_CH(pBssDesc->channelId) &&
4927 pProfile->force_24ghz_in_ht20) {
4928 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
4929 sme_debug("force_24ghz_in_ht20 is set so set cbmode to 0");
4930 }
4931
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304932 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933}
4934
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304935QDF_STATUS csr_roam_prepare_bss_config_from_profile(
Jeff Johnson66ee8a92018-03-17 15:24:26 -07004936 tpAniSirGlobal pMac, struct csr_roam_profile *pProfile,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304937 struct bss_config_param *pBssConfig,
4938 tSirBssDescription *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304940 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 uint8_t operationChannel = 0;
4942 uint8_t qAPisEnabled = false;
4943 /* SSID */
4944 pBssConfig->SSID.length = 0;
4945 if (pProfile->SSIDs.numOfSSIDs) {
4946 /* only use the first one */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304947 qdf_mem_copy(&pBssConfig->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 &pProfile->SSIDs.SSIDList[0].SSID,
4949 sizeof(tSirMacSSid));
4950 } else {
4951 /* SSID must present */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304952 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 }
4954 /* Settomg up the capabilities */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304955 if (csr_is_bss_type_ibss(pProfile->BSSType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956 pBssConfig->BssCap.ibss = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304957 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 pBssConfig->BssCap.ess = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304959
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004960 if (eCSR_ENCRYPT_TYPE_NONE !=
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304961 pProfile->EncryptionType.encryptionType[0])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 pBssConfig->BssCap.privacy = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004964 pBssConfig->eBand = pMac->roam.configParam.eBand;
4965 /* phymode */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304966 if (pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004967 operationChannel = pProfile->ChannelInfo.ChannelList[0];
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304968 pBssConfig->uCfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac,
4969 pProfile, operationChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 &pBssConfig->eBand);
4971 /* QOS */
4972 /* Is this correct to always set to this // *** */
4973 if (pBssConfig->BssCap.ess == 1) {
4974 /*For Softap case enable WMM */
4975 if (CSR_IS_INFRA_AP(pProfile)
4976 && (eCsrRoamWmmNoQos !=
4977 pMac->roam.configParam.WMMSupportMode)) {
4978 qAPisEnabled = true;
4979 } else
4980 if (csr_roam_get_qos_info_from_bss(pMac, pBssDesc) ==
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304981 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982 qAPisEnabled = true;
4983 } else {
4984 qAPisEnabled = false;
4985 }
4986 } else {
4987 qAPisEnabled = true;
4988 }
4989 if ((eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode &&
4990 qAPisEnabled) ||
4991 ((eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode &&
4992 qAPisEnabled))) {
4993 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
4994 } else {
4995 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
4996 }
4997
4998 /* auth type */
4999 /* Take the preferred Auth type. */
5000 switch (pProfile->AuthType.authType[0]) {
5001 default:
5002 case eCSR_AUTH_TYPE_WPA:
5003 case eCSR_AUTH_TYPE_WPA_PSK:
5004 case eCSR_AUTH_TYPE_WPA_NONE:
5005 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5006 pBssConfig->authType = eSIR_OPEN_SYSTEM;
5007 break;
5008 case eCSR_AUTH_TYPE_SHARED_KEY:
5009 pBssConfig->authType = eSIR_SHARED_KEY;
5010 break;
5011 case eCSR_AUTH_TYPE_AUTOSWITCH:
5012 pBssConfig->authType = eSIR_AUTO_SWITCH;
5013 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305014 case eCSR_AUTH_TYPE_SAE:
5015 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
5016 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 }
5018 /* short slot time */
5019 if (WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode) {
5020 pBssConfig->uShortSlotTime =
5021 pMac->roam.configParam.shortSlotTime;
5022 } else {
5023 pBssConfig->uShortSlotTime = 0;
5024 }
5025 /* power constraint. We don't support 11h on IBSS */
5026 pBssConfig->f11hSupport = false;
5027 pBssConfig->uPowerLimit = 0;
5028 /* heartbeat */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005029 if (BAND_5G == pBssConfig->eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 pBssConfig->uHeartBeatThresh =
5031 pMac->roam.configParam.HeartbeatThresh50;
5032 } else {
5033 pBssConfig->uHeartBeatThresh =
5034 pMac->roam.configParam.HeartbeatThresh24;
5035 }
5036 /* Join timeout */
5037 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
5038
5039 return status;
5040}
5041
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305042static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005043 tSirBssDescription *pBssDesc)
5044{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305045 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046 tDot11fBeaconIEs *pIes = NULL;
5047
5048 do {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305049 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005050 csr_get_parsed_bss_description_ies(
5051 pMac, pBssDesc, &pIes))) {
5052 /* err msg */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305053 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005054 "csr_roam_get_qos_info_from_bss() failed");
5055 break;
5056 }
5057 /* check if the AP is QAP & it supports APSD */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305058 if (CSR_IS_QOS_BSS(pIes))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305059 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 } while (0);
5061
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305062 if (NULL != pIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305063 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005064
5065 return status;
5066}
5067
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005068void csr_set_cfg_privacy(tpAniSirGlobal pMac, struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 bool fPrivacy)
5070{
5071 /*
5072 * the only difference between this function and
5073 * the csr_set_cfg_privacyFromProfile() is the setting of the privacy
5074 * CFG based on the advertised privacy setting from the AP for WPA
5075 * associations. See note below in this function...
5076 */
5077 uint32_t PrivacyEnabled = 0, RsnEnabled = 0, WepDefaultKeyId = 0;
5078 uint32_t WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
5079 uint32_t Key0Length = 0, Key1Length = 0, Key2Length = 0, Key3Length = 0;
5080
5081 /* Reserve for the biggest key */
5082 uint8_t Key0[WNI_CFG_WEP_DEFAULT_KEY_1_LEN];
5083 uint8_t Key1[WNI_CFG_WEP_DEFAULT_KEY_2_LEN];
5084 uint8_t Key2[WNI_CFG_WEP_DEFAULT_KEY_3_LEN];
5085 uint8_t Key3[WNI_CFG_WEP_DEFAULT_KEY_4_LEN];
5086
5087 switch (pProfile->negotiatedUCEncryptionType) {
5088 case eCSR_ENCRYPT_TYPE_NONE:
5089 /* for NO encryption, turn off Privacy and Rsn. */
5090 PrivacyEnabled = 0;
5091 RsnEnabled = 0;
5092 /* clear out the WEP keys that may be hanging around. */
5093 Key0Length = 0;
5094 Key1Length = 0;
5095 Key2Length = 0;
5096 Key3Length = 0;
5097 break;
5098
5099 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5100 case eCSR_ENCRYPT_TYPE_WEP40:
5101
5102 /* Privacy is ON. NO RSN for Wep40 static key. */
5103 PrivacyEnabled = 1;
5104 RsnEnabled = 0;
5105 /* Set the Wep default key ID. */
5106 WepDefaultKeyId = pProfile->Keys.defaultIndex;
5107 /* Wep key size if 5 bytes (40 bits). */
5108 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
5109 /*
5110 * set encryption keys in the CFG database or
5111 * clear those that are not present in this profile.
5112 */
5113 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305114 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005115 pProfile->Keys.KeyMaterial[0],
5116 WNI_CFG_WEP_KEY_LENGTH_5);
5117 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
5118 } else {
5119 Key0Length = 0;
5120 }
5121
5122 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305123 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005124 pProfile->Keys.KeyMaterial[1],
5125 WNI_CFG_WEP_KEY_LENGTH_5);
5126 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
5127 } else {
5128 Key1Length = 0;
5129 }
5130
5131 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305132 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005133 pProfile->Keys.KeyMaterial[2],
5134 WNI_CFG_WEP_KEY_LENGTH_5);
5135 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
5136 } else {
5137 Key2Length = 0;
5138 }
5139
5140 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305141 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005142 pProfile->Keys.KeyMaterial[3],
5143 WNI_CFG_WEP_KEY_LENGTH_5);
5144 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
5145 } else {
5146 Key3Length = 0;
5147 }
5148 break;
5149
5150 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5151 case eCSR_ENCRYPT_TYPE_WEP104:
5152
5153 /* Privacy is ON. NO RSN for Wep40 static key. */
5154 PrivacyEnabled = 1;
5155 RsnEnabled = 0;
5156 /* Set the Wep default key ID. */
5157 WepDefaultKeyId = pProfile->Keys.defaultIndex;
5158 /* Wep key size if 13 bytes (104 bits). */
5159 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
5160 /*
5161 * set encryption keys in the CFG database or clear
5162 * those that are not present in this profile.
5163 */
5164 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305165 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166 pProfile->Keys.KeyMaterial[0],
5167 WNI_CFG_WEP_KEY_LENGTH_13);
5168 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
5169 } else {
5170 Key0Length = 0;
5171 }
5172
5173 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305174 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 pProfile->Keys.KeyMaterial[1],
5176 WNI_CFG_WEP_KEY_LENGTH_13);
5177 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
5178 } else {
5179 Key1Length = 0;
5180 }
5181
5182 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305183 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 pProfile->Keys.KeyMaterial[2],
5185 WNI_CFG_WEP_KEY_LENGTH_13);
5186 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
5187 } else {
5188 Key2Length = 0;
5189 }
5190
5191 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305192 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193 pProfile->Keys.KeyMaterial[3],
5194 WNI_CFG_WEP_KEY_LENGTH_13);
5195 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
5196 } else {
5197 Key3Length = 0;
5198 }
5199 break;
5200
5201 case eCSR_ENCRYPT_TYPE_TKIP:
5202 case eCSR_ENCRYPT_TYPE_AES:
Mukul Sharma05504ac2017-06-08 12:35:53 +05305203 case eCSR_ENCRYPT_TYPE_AES_GCMP:
5204 case eCSR_ENCRYPT_TYPE_AES_GCMP_256:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205#ifdef FEATURE_WLAN_WAPI
5206 case eCSR_ENCRYPT_TYPE_WPI:
5207#endif /* FEATURE_WLAN_WAPI */
5208 /*
5209 * this is the only difference between this function and
5210 * the csr_set_cfg_privacyFromProfile().
5211 * (setting of the privacy CFG based on the advertised
5212 * privacy setting from AP for WPA/WAPI associations).
5213 */
5214 PrivacyEnabled = (0 != fPrivacy);
5215 /* turn on RSN enabled for WPA associations */
5216 RsnEnabled = 1;
5217 /* clear static WEP keys that may be hanging around. */
5218 Key0Length = 0;
5219 Key1Length = 0;
5220 Key2Length = 0;
5221 Key3Length = 0;
5222 break;
5223 default:
5224 PrivacyEnabled = 0;
5225 RsnEnabled = 0;
5226 break;
5227 }
5228
5229 cfg_set_int(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled);
5230 cfg_set_int(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled);
5231 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length);
5232 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length);
5233 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length);
5234 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005235 cfg_set_int(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId);
5236}
5237
5238static void csr_set_cfg_ssid(tpAniSirGlobal pMac, tSirMacSSid *pSSID)
5239{
5240 uint32_t len = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305241
5242 if (pSSID->length <= WNI_CFG_SSID_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005243 len = pSSID->length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 cfg_set_str(pMac, WNI_CFG_SSID, (uint8_t *) pSSID->ssId, len);
5245}
5246
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005247static QDF_STATUS csr_set_qos_to_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
5248 eCsrMediaAccessType qosType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305250 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 uint32_t QoSEnabled;
5252 uint32_t WmeEnabled;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305253 /* set the CFG enable/disable variables based on the
5254 * qosType being configured.
5255 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256 switch (qosType) {
5257 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
5258 QoSEnabled = false;
5259 WmeEnabled = true;
5260 break;
5261 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
5262 QoSEnabled = false;
5263 WmeEnabled = true;
5264 break;
5265 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
5266 QoSEnabled = false;
5267 WmeEnabled = true;
5268 break;
5269 case eCSR_MEDIUM_ACCESS_11e_eDCF:
5270 QoSEnabled = true;
5271 WmeEnabled = false;
5272 break;
5273 case eCSR_MEDIUM_ACCESS_11e_HCF:
5274 QoSEnabled = true;
5275 WmeEnabled = false;
5276 break;
5277 default:
5278 case eCSR_MEDIUM_ACCESS_DCF:
5279 QoSEnabled = false;
5280 WmeEnabled = false;
5281 break;
5282 }
5283 /* save the WMM setting for later use */
5284 pMac->roam.roamSession[sessionId].fWMMConnection = (bool) WmeEnabled;
5285 pMac->roam.roamSession[sessionId].fQOSConnection = (bool) QoSEnabled;
5286 return status;
5287}
5288
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305289static QDF_STATUS csr_get_rate_set(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005290 struct csr_roam_profile *pProfile,
5291 eCsrPhyMode phyMode,
5292 tSirBssDescription *pBssDesc,
5293 tDot11fBeaconIEs *pIes,
5294 tSirMacRateSet *pOpRateSet,
5295 tSirMacRateSet *pExRateSet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305297 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 int i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305299 enum csr_cfgdot11mode cfgDot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300 uint8_t *pDstRate;
5301 uint16_t rateBitmap = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305302
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305303 qdf_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
5304 qdf_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305305 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306
5307 if (NULL == pIes) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005308 sme_err("failed to parse BssDesc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 return status;
5310 }
5311
5312 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
5313 &cfgDot11Mode, pIes);
5314 /*
5315 * Originally, we thought that for 11a networks, the 11a rates
5316 * are always in the Operational Rate set & for 11b and 11g
5317 * networks, the 11b rates appear in the Operational Rate set.
5318 * Consequently, in either case, we would blindly put the rates
5319 * we support into our Operational Rate set.
5320 * (including the basic rates, which we've already verified are
5321 * supported earlier in the roaming decision).
5322 * However, it turns out that this is not always the case.
5323 * Some AP's (e.g. D-Link DI-784) ram 11g rates into the
5324 * Operational Rate set too. Now, we're a little more careful.
5325 */
5326 pDstRate = pOpRateSet->rate;
5327 if (pIes->SuppRates.present) {
5328 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
5329 if (csr_rates_is_dot11_rate_supported(pMac,
5330 pIes->SuppRates.rates[i]) &&
5331 !csr_check_rate_bitmap(
5332 pIes->SuppRates.rates[i],
5333 rateBitmap)) {
5334 csr_add_rate_bitmap(pIes->SuppRates.
5335 rates[i], &rateBitmap);
5336 *pDstRate++ = pIes->SuppRates.rates[i];
5337 pOpRateSet->numRates++;
5338 }
5339 }
5340 }
Abhishek Singh10112382015-12-03 16:06:59 +05305341 /*
5342 * If there are Extended Rates in the beacon, we will reflect the
5343 * extended rates that we support in our Extended Operational Rate
5344 * set.
5345 */
5346 if (pIes->ExtSuppRates.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 pDstRate = pExRateSet->rate;
5348 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++) {
5349 if (csr_rates_is_dot11_rate_supported(pMac,
5350 pIes->ExtSuppRates.rates[i]) &&
5351 !csr_check_rate_bitmap(
5352 pIes->ExtSuppRates.rates[i],
5353 rateBitmap)) {
5354 *pDstRate++ = pIes->ExtSuppRates.rates[i];
5355 pExRateSet->numRates++;
5356 }
5357 }
5358 }
5359 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305360 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005361 return status;
5362}
5363
5364static void csr_set_cfg_rate_set(tpAniSirGlobal pMac, eCsrPhyMode phyMode,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005365 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 tSirBssDescription *pBssDesc,
5367 tDot11fBeaconIEs *pIes)
5368{
5369 int i;
5370 uint8_t *pDstRate;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305371 enum csr_cfgdot11mode cfgDot11Mode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305372 /* leave enough room for the max number of rates */
5373 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 uint32_t OperationalRatesLength = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305375 /* leave enough room for the max number of rates */
5376 uint8_t ExtendedOperationalRates
5377 [CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378 uint32_t ExtendedOperationalRatesLength = 0;
5379 uint8_t MCSRateIdxSet[SIZE_OF_SUPPORTED_MCS_SET];
5380 uint32_t MCSRateLength = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305381
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305382 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 if (NULL != pIes) {
5384 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
5385 &cfgDot11Mode, pIes);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305386 /* Originally, we thought that for 11a networks, the 11a rates
5387 * are always in the Operational Rate set & for 11b and 11g
5388 * networks, the 11b rates appear in the Operational Rate set.
5389 * Consequently, in either case, we would blindly put the rates
5390 * we support into our Operational Rate set (including the basic
5391 * rates, which we have already verified are supported earlier
5392 * in the roaming decision). However, it turns out that this is
5393 * not always the case. Some AP's (e.g. D-Link DI-784) ram 11g
5394 * rates into the Operational Rate set, too. Now, we're a
5395 * little more careful:
5396 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397 pDstRate = OperationalRates;
5398 if (pIes->SuppRates.present) {
5399 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
5400 if (csr_rates_is_dot11_rate_supported
5401 (pMac, pIes->SuppRates.rates[i])
5402 && (OperationalRatesLength <
5403 CSR_DOT11_SUPPORTED_RATES_MAX)) {
5404 *pDstRate++ = pIes->SuppRates.rates[i];
5405 OperationalRatesLength++;
5406 }
5407 }
5408 }
5409 if (eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
5410 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
5411 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305412 /* If there are Extended Rates in the beacon, we will
5413 * reflect those extended rates that we support in out
5414 * Extended Operational Rate set:
5415 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 pDstRate = ExtendedOperationalRates;
5417 if (pIes->ExtSuppRates.present) {
5418 for (i = 0; i < pIes->ExtSuppRates.num_rates;
5419 i++) {
5420 if (csr_rates_is_dot11_rate_supported
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305421 (pMac, pIes->ExtSuppRates.
5422 rates[i])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 && (ExtendedOperationalRatesLength <
5424 CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX)) {
5425 *pDstRate++ =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305426 pIes->ExtSuppRates.
5427 rates[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 ExtendedOperationalRatesLength++;
5429 }
5430 }
5431 }
5432 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305433 /* Enable proprietary MAC features if peer node is Airgo node
5434 * and STA user wants to use them For ANI network companions,
5435 * we need to populate the proprietary rate set with any
5436 * proprietary rates we found in the beacon, only if user allows
5437 * them.
5438 */
5439 /* No proprietary modes... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440 /* Get MCS Rate */
5441 pDstRate = MCSRateIdxSet;
5442 if (pIes->HTCaps.present) {
5443 for (i = 0; i < VALID_MAX_MCS_INDEX; i++) {
5444 if ((unsigned int)pIes->HTCaps.
5445 supportedMCSSet[0] & (1 << i)) {
5446 MCSRateLength++;
5447 *pDstRate++ = i;
5448 }
5449 }
5450 }
5451 /* Set the operational rate set CFG variables... */
5452 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
5453 OperationalRates, OperationalRatesLength);
5454 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
5455 ExtendedOperationalRates,
5456 ExtendedOperationalRatesLength);
5457 cfg_set_str(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
5458 MCSRateLength);
5459 } /* Parsing BSSDesc */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305460 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005461 sme_err("failed to parse BssDesc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462}
5463
5464static void csr_set_cfg_rate_set_from_profile(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005465 struct csr_roam_profile *pProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466{
5467 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
5468 {8,
5469 {SIR_MAC_RATE_6,
5470 SIR_MAC_RATE_9,
5471 SIR_MAC_RATE_12,
5472 SIR_MAC_RATE_18,
5473 SIR_MAC_RATE_24,
5474 SIR_MAC_RATE_36,
5475 SIR_MAC_RATE_48,
5476 SIR_MAC_RATE_54} } };
5477 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
5478 {4,
5479 {SIR_MAC_RATE_1,
5480 SIR_MAC_RATE_2,
5481 SIR_MAC_RATE_5_5,
5482 SIR_MAC_RATE_11} } };
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305483 enum csr_cfgdot11mode cfgDot11Mode;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005484 enum band_info eBand;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485 /* leave enough room for the max number of rates */
5486 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
5487 uint32_t OperationalRatesLength = 0;
5488 /* leave enough room for the max number of rates */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305489 uint8_t ExtendedOperationalRates
5490 [CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 uint32_t ExtendedOperationalRatesLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005492 uint8_t operationChannel = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305493
5494 if (pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495 operationChannel = pProfile->ChannelInfo.ChannelList[0];
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305496 cfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac, pProfile,
5497 operationChannel,
5498 &eBand);
5499 /* For 11a networks, the 11a rates go into the Operational Rate set.
5500 * For 11b and 11g networks, the 11b rates appear in the Operational
5501 * Rate set. In either case, we can blindly put the rates we support
5502 * into our Operational Rate set (including the basic rates, which we
5503 * have already verified are supported earlier in the roaming decision).
5504 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005505 if (BAND_5G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 /* 11a rates into the Operational Rate Set. */
5507 OperationalRatesLength =
5508 DefaultSupportedRates11a.supportedRateSet.numRates *
5509 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305510 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005511 DefaultSupportedRates11a.supportedRateSet.rate,
5512 OperationalRatesLength);
5513
5514 /* Nothing in the Extended rate set. */
5515 ExtendedOperationalRatesLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 } else if (eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode) {
5517 /* 11b rates into the Operational Rate Set. */
5518 OperationalRatesLength =
5519 DefaultSupportedRates11b.supportedRateSet.numRates *
5520 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305521 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 DefaultSupportedRates11b.supportedRateSet.rate,
5523 OperationalRatesLength);
5524 /* Nothing in the Extended rate set. */
5525 ExtendedOperationalRatesLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 } else {
5527 /* 11G */
5528
5529 /* 11b rates into the Operational Rate Set. */
5530 OperationalRatesLength =
5531 DefaultSupportedRates11b.supportedRateSet.numRates *
5532 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305533 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534 DefaultSupportedRates11b.supportedRateSet.rate,
5535 OperationalRatesLength);
5536
5537 /* 11a rates go in the Extended rate set. */
5538 ExtendedOperationalRatesLength =
5539 DefaultSupportedRates11a.supportedRateSet.numRates *
5540 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305541 qdf_mem_copy(ExtendedOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542 DefaultSupportedRates11a.supportedRateSet.rate,
5543 ExtendedOperationalRatesLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 }
5545
5546 /* Set the operational rate set CFG variables... */
5547 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
5548 OperationalRatesLength);
5549 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305550 ExtendedOperationalRates,
5551 ExtendedOperationalRatesLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552}
5553
Krunal Sonif3583022017-02-10 17:18:10 -08005554void csr_roam_ccm_cfg_set_callback(tpAniSirGlobal pMac, int32_t result,
5555 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556{
5557 tListElem *pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -08005558 csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 uint32_t sessionId;
5560 tSmeCmd *pCommand = NULL;
5561#ifdef WLAN_FEATURE_ROAM_OFFLOAD
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305562 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563#endif
5564 if (NULL == pEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005565 sme_err("CFG_CNF with active list empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566 return;
5567 }
5568 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
5569 sessionId = pCommand->sessionId;
5570#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5571 pSession = &pMac->roam.roamSession[sessionId];
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005572 if (pSession->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305573 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 "LFR3:csr_roam_cfg_set_callback");
5575 }
5576#endif
5577
5578 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
5579 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
Krunal Sonia8270f52017-02-23 19:51:25 -08005580 csr_roaming_state_config_cnf_processor(pMac, pCommand,
5581 (uint32_t) result, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 }
5583}
5584
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585/* pIes may be NULL */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305586QDF_STATUS csr_roam_set_bss_config_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005587 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 tSirBssDescription *pBssDesc,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305589 struct bss_config_param *pBssConfig,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305590 struct sDot11fBeaconIEs *pIes,
5591 bool resetCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592{
Jeff Johnsonc09caa42018-06-07 22:58:55 -07005593 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594 uint32_t cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5595 uint8_t channel = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305596 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Abhinav Kumar43ab01b2018-06-26 19:06:56 +05305597 if (!pSession) {
5598 sme_err("session %d not found", sessionId);
5599 return QDF_STATUS_E_FAILURE;
5600 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005601
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305602 /* Make sure we have the domain info for the BSS we try to connect to.
5603 * Do we need to worry about sequence for OSs that are not Windows??
5604 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 if (pBssDesc) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305606 if ((QDF_SAP_MODE !=
Peng Xuf5d60c82015-10-02 17:17:03 -07005607 csr_get_session_persona(pMac, sessionId)) &&
5608 csr_learn_11dcountry_information(
5609 pMac, pBssDesc, pIes, true)) {
5610 csr_apply_country_information(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 }
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07005612 if ((wlan_reg_11d_enabled_on_host(pMac->psoc)) && pIes) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305613 if (!pIes->Country.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005614 csr_apply_channel_power_info_wrapper(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 }
5616 }
5617 /* Qos */
5618 csr_set_qos_to_cfg(pMac, sessionId, pBssConfig->qosType);
5619 /* SSID */
5620 csr_set_cfg_ssid(pMac, &pBssConfig->SSID);
5621
5622 /* Auth type */
5623 cfg_set_int(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType);
5624 /* encryption type */
5625 csr_set_cfg_privacy(pMac, pProfile, (bool) pBssConfig->BssCap.privacy);
5626 /* short slot time */
5627 cfg_set_int(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED,
5628 pBssConfig->uShortSlotTime);
5629 /* 11d */
5630 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
5631 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport :
5632 pProfile->ieee80211d));
5633 cfg_set_int(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT,
5634 pBssConfig->uPowerLimit);
5635 /* CB */
5636
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305637 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_IBSS(pProfile))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638 channel = pProfile->operationChannel;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305639 else if (pBssDesc)
5640 channel = pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005641 if (0 != channel) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005642 /* for now if we are on 2.4 Ghz, CB will be always disabled */
5643 if (WLAN_REG_IS_24GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005645 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646 cfgCb = pBssConfig->cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 }
5648 /* Rate */
5649 /* Fixed Rate */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305650 if (pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 csr_set_cfg_rate_set(pMac, (eCsrPhyMode) pProfile->phyMode,
5652 pProfile, pBssDesc, pIes);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305653 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 csr_set_cfg_rate_set_from_profile(pMac, pProfile);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005655 status = cfg_set_int(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT,
5656 pBssConfig->uJoinTimeOut);
5657 /* Any roaming related changes should be above this line */
Arif Hussain557920f2016-09-07 16:03:46 -07005658 if (pSession && pSession->roam_synch_in_progress) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005659 sme_debug("Roam synch is in progress Session_id: %d",
5660 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305661 return QDF_STATUS_SUCCESS;
Arif Hussain557920f2016-09-07 16:03:46 -07005662 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305663 /* Make this the last CFG to set. The callback will trigger a
5664 * join_req Join time out
5665 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId);
5667
Krunal Sonif3583022017-02-10 17:18:10 -08005668 csr_roam_ccm_cfg_set_callback(pMac, status, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305669 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670}
5671
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005672static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305673QDF_STATUS csr_roam_stop_network(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005674 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675 tSirBssDescription *pBssDesc,
5676 tDot11fBeaconIEs *pIes)
5677{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305678 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305679 struct bss_config_param *pBssConfig;
5680 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681
5682 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005683 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305684 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005685 }
5686
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305687 pBssConfig = qdf_mem_malloc(sizeof(struct bss_config_param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005688 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305689 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005690
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005691 sme_debug("session id: %d", sessionId);
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +05305692
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 status = csr_roam_prepare_bss_config(pMac, pProfile, pBssDesc,
5694 pBssConfig, pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305695 if (QDF_IS_STATUS_SUCCESS(status)) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305696 enum csr_roam_substate substate;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698 substate = eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING;
5699 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
5700 /* This will allow to pass cbMode during join req */
5701 pSession->bssParams.cbMode = pBssConfig->cbMode;
5702 /* For IBSS, we need to prepare some more information */
5703 if (csr_is_bss_type_ibss(pProfile->BSSType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005704 CSR_IS_INFRA_AP(pProfile))
5705 csr_roam_prepare_bss_params(pMac, sessionId, pProfile,
5706 pBssDesc, pBssConfig, pIes);
5707
5708 /*
5709 * If we are in an IBSS, then stop the IBSS...
5710 * Not worry about WDS connection for now
5711 */
5712 if (csr_is_conn_state_ibss(pMac, sessionId)) {
5713 status = csr_roam_issue_stop_bss(pMac, sessionId,
5714 substate);
5715 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
5716 /*
5717 * the new Bss is an Ibss OR we are roaming from
5718 * Infra to Infra across SSIDs
5719 * (roaming to a new SSID)...
5720 * Not worry about WDS connection for now
5721 */
5722 if (pBssDesc && (csr_is_ibss_bss_desc(pBssDesc) ||
5723 !csr_is_ssid_equal(pMac,
5724 pSession->pConnectBssDesc,
5725 pBssDesc, pIes)))
5726 status = csr_roam_issue_disassociate(pMac,
5727 sessionId, substate, false);
5728 else if (pBssDesc)
5729 /*
5730 * In an infra & going to an infra network with
5731 * the same SSID. This calls for a reassoc seq.
5732 * So issue the CFG sets for this new AP. Set
5733 * parameters for this Bss.
5734 */
5735 status = csr_roam_set_bss_config_cfg(pMac,
5736 sessionId, pProfile, pBssDesc,
5737 pBssConfig, pIes, false);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005738 } else if (pBssDesc ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005739 CSR_IS_INFRA_AP(pProfile)) {
5740 /*
5741 * Neither in IBSS nor in Infra. We can go ahead and set
5742 * the cfg for tne new network... nothing to stop.
5743 */
5744 bool is11rRoamingFlag = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746 is11rRoamingFlag = csr_roam_is11r_assoc(pMac,
5747 sessionId);
5748 /* Set parameters for this Bss. */
5749 status = csr_roam_set_bss_config_cfg(pMac, sessionId,
5750 pProfile, pBssDesc, pBssConfig, pIes,
5751 is11rRoamingFlag);
5752 }
5753 } /* Success getting BSS config info */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305754 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 return status;
5756}
5757
5758/**
5759 * csr_roam_state_for_same_profile() - Determine roam state for same profile
5760 * @mac_ctx: pointer to mac context
5761 * @profile: Roam profile
5762 * @session: Roam session
5763 * @session_id: session id
5764 * @ies_local: local ies
5765 * @bss_descr: bss description
5766 *
5767 * This function will determine the roam state for same profile
5768 *
5769 * Return: Roaming state.
5770 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305771static enum csr_join_state csr_roam_state_for_same_profile(
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005772 tpAniSirGlobal mac_ctx, struct csr_roam_profile *profile,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305773 struct csr_roam_session *session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005774 uint32_t session_id, tDot11fBeaconIEs *ies_local,
5775 tSirBssDescription *bss_descr)
5776{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305777 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305778 struct bss_config_param bssConfig;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305779
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005780 if (csr_roam_is_same_profile_keys(mac_ctx, &session->connectedProfile,
5781 profile))
5782 return eCsrReassocToSelfNoCapChange;
5783 /* The key changes */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305784 qdf_mem_set(&bssConfig, sizeof(bssConfig), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 status = csr_roam_prepare_bss_config(mac_ctx, profile, bss_descr,
5786 &bssConfig, ies_local);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305787 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788 session->bssParams.uCfgDot11Mode =
5789 bssConfig.uCfgDot11Mode;
5790 session->bssParams.cbMode =
5791 bssConfig.cbMode;
5792 /* reapply the cfg including keys so reassoc happens. */
5793 status = csr_roam_set_bss_config_cfg(mac_ctx, session_id,
5794 profile, bss_descr, &bssConfig,
5795 ies_local, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305796 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005797 return eCsrContinueRoaming;
5798 }
5799
5800 return eCsrStopRoaming;
5801
5802}
5803
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305804static enum csr_join_state csr_roam_join(tpAniSirGlobal pMac,
5805 uint32_t sessionId, tCsrScanResultInfo *pScanResult,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005806 struct csr_roam_profile *pProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005807{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305808 enum csr_join_state eRoamState = eCsrContinueRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
5810 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *) (pScanResult->pvIes);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305811 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812
5813 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005814 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815 return eCsrStopRoaming;
5816 }
5817
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 if (!pIesLocal &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305819 !QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 pBssDesc, &pIesLocal))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005821 sme_err("fail to parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822 return eCsrStopRoaming;
5823 }
5824 if (csr_is_infra_bss_desc(pBssDesc)) {
5825 /*
5826 * If we are connected in infra mode and the join bss descr is
5827 * for the same BssID, then we are attempting to join the AP we
5828 * are already connected with. In that case, see if the Bss or
5829 * sta capabilities have changed and handle the changes
5830 * without disturbing the current association
5831 */
5832
5833 if (csr_is_conn_state_connected_infra(pMac, sessionId) &&
Jeff Johnson8aef3f62018-06-03 13:21:15 -07005834 csr_is_bss_id_equal(pBssDesc,
5835 pSession->pConnectBssDesc) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836 csr_is_ssid_equal(pMac, pSession->pConnectBssDesc,
5837 pBssDesc, pIesLocal)) {
5838 /*
5839 * Check to see if the Auth type has changed in the
5840 * profile. If so, we don't want to reassociate with
5841 * authenticating first. To force this, stop the
5842 * current association (Disassociate) and then re 'Join'
5843 * the AP, wihch will force an Authentication (with the
5844 * new Auth type) followed by a new Association.
5845 */
5846 if (csr_is_same_profile(pMac,
5847 &pSession->connectedProfile, pProfile)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005848 sme_warn("detect same profile");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 eRoamState =
5850 csr_roam_state_for_same_profile(pMac,
5851 pProfile, pSession, sessionId,
5852 pIesLocal, pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305853 } else if (!QDF_IS_STATUS_SUCCESS(
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305854 csr_roam_issue_disassociate(
5855 pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 sessionId,
5857 eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
5858 false))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305859 sme_err("fail disassoc session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860 sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305861 eRoamState = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305863 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305864 sessionId, pProfile, pBssDesc, pIesLocal)))
5865 /* we used to pre-auth here with open auth
5866 * networks but that wasn't working so well.
5867 * stop the existing network before attempting
5868 * to join the new network.
5869 */
5870 eRoamState = eCsrStopRoaming;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305871 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005872 pProfile, pBssDesc,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305873 pIesLocal)))
5874 eRoamState = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005875
5876 if (pIesLocal && !pScanResult->pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305877 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 return eRoamState;
5879}
5880
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005881static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305882QDF_STATUS csr_roam_should_roam(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005883 tSirBssDescription *pBssDesc, uint32_t roamId)
5884{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305885 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08005886 struct csr_roam_info roamInfo;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305887
Jeff Johnson172237b2017-11-07 15:32:59 -08005888 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 roamInfo.pBssDesc = pBssDesc;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305890 status = csr_roam_call_callback(pMac, sessionId, &roamInfo, roamId,
5891 eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 return status;
5893}
5894
5895/* In case no matching BSS is found, use whatever default we can find */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305896static void csr_roam_assign_default_param(tpAniSirGlobal pMac,
5897 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898{
5899 /* Need to get all negotiated types in place first */
5900 /* auth type */
5901 /* Take the preferred Auth type. */
5902 switch (pCommand->u.roamCmd.roamProfile.AuthType.authType[0]) {
5903 default:
5904 case eCSR_AUTH_TYPE_WPA:
5905 case eCSR_AUTH_TYPE_WPA_PSK:
5906 case eCSR_AUTH_TYPE_WPA_NONE:
5907 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5908 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5909 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5910 break;
5911
5912 case eCSR_AUTH_TYPE_SHARED_KEY:
5913 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5914 eCSR_AUTH_TYPE_SHARED_KEY;
5915 break;
5916
5917 case eCSR_AUTH_TYPE_AUTOSWITCH:
5918 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5919 eCSR_AUTH_TYPE_AUTOSWITCH;
5920 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305921
5922 case eCSR_AUTH_TYPE_SAE:
5923 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5924 eCSR_AUTH_TYPE_SAE;
5925 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 }
5927 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305928 pCommand->u.roamCmd.roamProfile.EncryptionType.
5929 encryptionType[0];
5930 /* In this case, the multicast encryption needs to follow the
5931 * uncast ones.
5932 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305934 pCommand->u.roamCmd.roamProfile.EncryptionType.
5935 encryptionType[0];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936}
5937
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938/**
5939 * csr_roam_select_bss() - Handle join scenario based on profile
5940 * @mac_ctx: Global MAC Context
5941 * @roam_bss_entry: The next BSS to join
5942 * @csr_result_info: Result of join
5943 * @csr_scan_result: Global scan result
5944 * @session_id: SME Session ID
5945 * @roam_id: Roaming ID
5946 * @roam_state: Current roaming state
5947 * @bss_list: BSS List
5948 *
5949 * Return: true if the entire BSS list is done, false otherwise.
5950 */
5951static bool csr_roam_select_bss(tpAniSirGlobal mac_ctx,
5952 tListElem *roam_bss_entry, tCsrScanResultInfo **csr_result_info,
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07005953 struct tag_csrscan_result **csr_scan_result,
5954 uint32_t session_id, uint32_t roam_id,
5955 enum csr_join_state *roam_state,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305956 struct scan_result_list *bss_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957{
5958 uint8_t conc_channel = 0;
5959 bool status = false;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305960 struct tag_csrscan_result *scan_result = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 tCsrScanResultInfo *result = NULL;
5962
5963 while (roam_bss_entry) {
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305964 scan_result = GET_BASE_ADDR(roam_bss_entry, struct
5965 tag_csrscan_result, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 /*
5967 * If concurrency enabled take the
5968 * concurrent connected channel first.
5969 * Valid multichannel concurrent
5970 * sessions exempted
5971 */
5972 result = &scan_result->Result;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005973 if (policy_mgr_concurrent_open_sessions_running(mac_ctx->psoc)
5974 && !csr_is_valid_mc_concurrent_session(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 session_id, &result->BssDescriptor)) {
5976 conc_channel = csr_get_concurrent_operation_channel(
5977 mac_ctx);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005978 sme_debug("csr Conc Channel: %d", conc_channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005979 if ((conc_channel) && (conc_channel ==
5980 result->BssDescriptor.channelId)) {
5981 /*
5982 * make this 0 because we do not want the below
5983 * check to pass as we don't want to connect on
5984 * other channel
5985 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005986 sme_debug("Conc chnl match: %d", conc_channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987 conc_channel = 0;
5988 }
5989 }
5990
5991 /* Ok to roam this */
5992 if (!conc_channel &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305993 QDF_IS_STATUS_SUCCESS(csr_roam_should_roam(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 session_id, &result->BssDescriptor, roam_id))) {
5995 status = false;
5996 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305998 *roam_state = eCsrStopRoamingDueToConcurrency;
5999 status = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006000 roam_bss_entry = csr_ll_next(&bss_list->List, roam_bss_entry,
6001 LL_ACCESS_LOCK);
6002 }
6003 *csr_result_info = result;
6004 *csr_scan_result = scan_result;
6005 return status;
6006}
6007
6008/**
6009 * csr_roam_join_handle_profile() - Handle join scenario based on profile
6010 * @mac_ctx: Global MAC Context
6011 * @session_id: SME Session ID
6012 * @cmd: Command
6013 * @roam_info_ptr: Pointed to the roaming info for join
6014 * @roam_state: Current roaming state
6015 * @result: Result of join
6016 * @scan_result: Global scan result
6017 *
6018 * Return: None
6019 */
6020static void csr_roam_join_handle_profile(tpAniSirGlobal mac_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -08006021 uint32_t session_id, tSmeCmd *cmd,
6022 struct csr_roam_info *roam_info_ptr,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306023 enum csr_join_state *roam_state, tCsrScanResultInfo *result,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306024 struct tag_csrscan_result *scan_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025{
6026#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6027 uint8_t acm_mask = 0;
6028#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306029 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306030 struct csr_roam_session *session;
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006031 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006032 tDot11fBeaconIEs *ies_local = NULL;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006033
6034 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006035 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006036 return;
6037 }
6038 session = CSR_GET_SESSION(mac_ctx, session_id);
6039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 /*
6041 * We have something to roam, tell HDD when it is infra.
6042 * For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006043 */
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006044 if (CSR_IS_INFRASTRUCTURE(profile) && roam_info_ptr) {
6045 if (session->bRefAssocStartCnt) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 session->bRefAssocStartCnt--;
6047 roam_info_ptr->pProfile = profile;
6048 /*
6049 * Complete the last assoc attempt as a
6050 * new one is about to be tried
6051 */
6052 csr_roam_call_callback(mac_ctx, session_id,
6053 roam_info_ptr, cmd->u.roamCmd.roamId,
6054 eCSR_ROAM_ASSOCIATION_COMPLETION,
6055 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
6056 }
Jianmin Zhuaac14e02018-08-31 23:00:27 +08006057
Jeff Johnson172237b2017-11-07 15:32:59 -08006058 qdf_mem_set(roam_info_ptr, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 if (!scan_result)
6060 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
6061 else
6062 ies_local = scan_result->Result.pvIes;
6063
Naveen Rawat48f51d02016-07-22 10:15:08 -07006064 if (!result) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006065 sme_err(" cannot parse IEs");
Naveen Rawat48f51d02016-07-22 10:15:08 -07006066 *roam_state = eCsrStopRoaming;
6067 return;
6068 } else if (scan_result && !ies_local &&
6069 (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070 csr_get_parsed_bss_description_ies(
Naveen Rawat48f51d02016-07-22 10:15:08 -07006071 mac_ctx, &result->BssDescriptor,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006072 &ies_local)))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006073 sme_err(" cannot parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074 *roam_state = eCsrStopRoaming;
6075 return;
6076 }
Naveen Rawat48f51d02016-07-22 10:15:08 -07006077 roam_info_ptr->pBssDesc = &result->BssDescriptor;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006078 cmd->u.roamCmd.pLastRoamBss = roam_info_ptr->pBssDesc;
6079 /* dont put uapsd_mask if BSS doesn't support uAPSD */
6080 if (scan_result && cmd->u.roamCmd.roamProfile.uapsd_mask
6081 && CSR_IS_QOS_BSS(ies_local)
6082 && CSR_IS_UAPSD_BSS(ies_local)) {
6083#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Naveen Rawat48f51d02016-07-22 10:15:08 -07006084 acm_mask = sme_qos_get_acm_mask(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006085 &result->BssDescriptor, ies_local);
6086#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
6087 } else {
6088 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
6089 }
Arif Hussainfdb25e22017-02-05 17:38:16 -08006090 if (ies_local && !scan_result->Result.pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306091 qdf_mem_free(ies_local);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 roam_info_ptr->pProfile = profile;
6093 session->bRefAssocStartCnt++;
6094 csr_roam_call_callback(mac_ctx, session_id, roam_info_ptr,
6095 cmd->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_START,
6096 eCSR_ROAM_RESULT_NONE);
6097 }
6098 if (NULL != cmd->u.roamCmd.pRoamBssEntry) {
6099 /*
6100 * We have BSS
6101 * Need to assign these value because
6102 * they are used in csr_is_same_profile
6103 */
6104 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306105 struct tag_csrscan_result, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006106 /*
6107 * The OSEN IE doesn't provide the cipher suite.Therefore set
6108 * to constant value of AES
6109 */
6110 if (cmd->u.roamCmd.roamProfile.bOSENAssociation) {
6111 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
6112 eCSR_ENCRYPT_TYPE_AES;
6113 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
6114 eCSR_ENCRYPT_TYPE_AES;
6115 } else {
6116 /* Negotiated while building scan result. */
6117 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
6118 scan_result->ucEncryptionType;
6119 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
6120 scan_result->mcEncryptionType;
6121 }
6122 cmd->u.roamCmd.roamProfile.negotiatedAuthType =
6123 scan_result->authType;
6124 if (CSR_IS_START_IBSS(&cmd->u.roamCmd.roamProfile)) {
6125 if (csr_is_same_profile(mac_ctx,
6126 &session->connectedProfile, profile)) {
6127 *roam_state = eCsrStartIbssSameIbss;
6128 return;
6129 }
6130 }
6131 if (cmd->u.roamCmd.fReassocToSelfNoCapChange) {
6132 /* trying to connect to the one already connected */
6133 cmd->u.roamCmd.fReassocToSelfNoCapChange = false;
6134 *roam_state = eCsrReassocToSelfNoCapChange;
6135 return;
6136 }
6137 /* Attempt to Join this Bss... */
6138 *roam_state = csr_roam_join(mac_ctx, session_id,
6139 &scan_result->Result, profile);
6140 return;
6141 }
6142
6143 /* For an IBSS profile, then we need to start the IBSS. */
6144 if (CSR_IS_START_IBSS(profile)) {
6145 bool same_ibss = false;
6146 /* Attempt to start this IBSS... */
6147 csr_roam_assign_default_param(mac_ctx, cmd);
6148 status = csr_roam_start_ibss(mac_ctx, session_id,
6149 profile, &same_ibss);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306150 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006151 if (same_ibss)
6152 *roam_state = eCsrStartIbssSameIbss;
6153 else
6154 *roam_state = eCsrContinueRoaming;
6155 } else {
6156 /* it somehow fail need to stop */
6157 *roam_state = eCsrStopRoaming;
6158 }
6159 return;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006160 } else if (CSR_IS_INFRA_AP(profile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006161 /* Attempt to start this WDS... */
6162 csr_roam_assign_default_param(mac_ctx, cmd);
6163 /* For AP WDS, we dont have any BSSDescription */
6164 status = csr_roam_start_wds(mac_ctx, session_id, profile, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306165 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 *roam_state = eCsrContinueRoaming;
6167 else
6168 *roam_state = eCsrStopRoaming;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006169 } else if (CSR_IS_NDI(profile)) {
6170 csr_roam_assign_default_param(mac_ctx, cmd);
6171 status = csr_roam_start_ndi(mac_ctx, session_id, profile);
6172 if (QDF_IS_STATUS_SUCCESS(status))
6173 *roam_state = eCsrContinueRoaming;
6174 else
6175 *roam_state = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176 } else {
6177 /* Nothing we can do */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006178 sme_warn("cannot continue without BSS list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006179 *roam_state = eCsrStopRoaming;
6180 return;
6181 }
6182
6183}
6184/**
6185 * csr_roam_join_next_bss() - Pick the next BSS for join
6186 * @mac_ctx: Global MAC Context
6187 * @cmd: Command
6188 * @use_same_bss: Use Same BSS to Join
6189 *
6190 * Return: The Join State
6191 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306192static enum csr_join_state csr_roam_join_next_bss(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006193 tSmeCmd *cmd, bool use_same_bss)
6194{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306195 struct tag_csrscan_result *scan_result = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306196 enum csr_join_state roam_state = eCsrStopRoaming;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306197 struct scan_result_list *bss_list =
6198 (struct scan_result_list *) cmd->u.roamCmd.hBSSList;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199 bool done = false;
Jeff Johnson172237b2017-11-07 15:32:59 -08006200 struct csr_roam_info *roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006201 uint32_t session_id = cmd->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306202 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006203 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306204 struct csr_roam_joinstatus *join_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006205 tCsrScanResultInfo *result = NULL;
6206
6207 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006208 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209 return eCsrStopRoaming;
6210 }
6211
Srinivas Girigowdaea4d8062017-10-14 12:40:48 -07006212 roam_info = qdf_mem_malloc(sizeof(*roam_info));
Kapil Guptaffa26022017-08-16 12:20:09 +05306213 if (!roam_info) {
6214 sme_err("failed to allocate memory");
6215 return eCsrStopRoaming;
6216 }
6217 qdf_mem_copy(&roam_info->bssid, &session->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006218 sizeof(tSirMacAddr));
6219 /*
6220 * When handling AP's capability change, continue to associate
6221 * to same BSS and make sure pRoamBssEntry is not Null.
6222 */
6223 if ((NULL != bss_list) &&
6224 ((false == use_same_bss) ||
6225 (cmd->u.roamCmd.pRoamBssEntry == NULL))) {
6226 if (cmd->u.roamCmd.pRoamBssEntry == NULL) {
6227 /* Try the first BSS */
6228 cmd->u.roamCmd.pLastRoamBss = NULL;
6229 cmd->u.roamCmd.pRoamBssEntry =
6230 csr_ll_peek_head(&bss_list->List,
6231 LL_ACCESS_LOCK);
6232 } else {
6233 cmd->u.roamCmd.pRoamBssEntry =
6234 csr_ll_next(&bss_list->List,
6235 cmd->u.roamCmd.pRoamBssEntry,
6236 LL_ACCESS_LOCK);
6237 /*
6238 * Done with all the BSSs.
6239 * In this case, will tell HDD the
6240 * completion
6241 */
6242 if (NULL == cmd->u.roamCmd.pRoamBssEntry)
6243 goto end;
6244 /*
6245 * We need to indicate to HDD that we
6246 * are done with this one.
6247 */
Kapil Guptaffa26022017-08-16 12:20:09 +05306248 roam_info->pBssDesc = cmd->u.roamCmd.pLastRoamBss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249 join_status = &session->joinFailStatusCode;
Kapil Guptaffa26022017-08-16 12:20:09 +05306250 roam_info->statusCode = join_status->statusCode;
6251 roam_info->reasonCode = join_status->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006252 }
6253 done = csr_roam_select_bss(mac_ctx,
6254 cmd->u.roamCmd.pRoamBssEntry, &result,
6255 &scan_result, session_id, cmd->u.roamCmd.roamId,
6256 &roam_state, bss_list);
6257 if (done)
6258 goto end;
6259 }
Kapil Guptaffa26022017-08-16 12:20:09 +05306260 roam_info->u.pConnectedProfile = &session->connectedProfile;
Naveen Rawata395d252016-06-15 11:07:24 -07006261
Kapil Guptaffa26022017-08-16 12:20:09 +05306262 csr_roam_join_handle_profile(mac_ctx, session_id, cmd, roam_info,
Naveen Rawat696a9302016-06-15 11:07:24 -07006263 &roam_state, result, scan_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006264end:
6265 if ((eCsrStopRoaming == roam_state) && CSR_IS_INFRASTRUCTURE(profile) &&
6266 (session->bRefAssocStartCnt > 0)) {
6267 /*
6268 * Need to indicate association_completion if association_start
6269 * has been done
6270 */
6271 session->bRefAssocStartCnt--;
6272 /*
6273 * Complete the last assoc attempte as a
6274 * new one is about to be tried
6275 */
Kapil Guptaffa26022017-08-16 12:20:09 +05306276 roam_info->pProfile = profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006277 csr_roam_call_callback(mac_ctx, session_id,
Kapil Guptaffa26022017-08-16 12:20:09 +05306278 roam_info, cmd->u.roamCmd.roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006279 eCSR_ROAM_ASSOCIATION_COMPLETION,
6280 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
6281 }
Kapil Guptaffa26022017-08-16 12:20:09 +05306282 qdf_mem_free(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006283
6284 return roam_state;
6285}
6286
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306287static QDF_STATUS csr_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006288{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306289 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306290 enum csr_join_state RoamState;
6291 enum csr_roam_substate substate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292 uint32_t sessionId = pCommand->sessionId;
6293
6294 /* Attept to join a Bss... */
6295 RoamState = csr_roam_join_next_bss(pMac, pCommand, false);
6296
6297 /* if nothing to join.. */
6298 if ((eCsrStopRoaming == RoamState) ||
6299 (eCsrStopRoamingDueToConcurrency == RoamState)) {
6300 bool fComplete = false;
6301 /* and if connected in Infrastructure mode... */
6302 if (csr_is_conn_state_infra(pMac, sessionId)) {
6303 /* ... then we need to issue a disassociation */
6304 substate = eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN;
6305 status = csr_roam_issue_disassociate(pMac, sessionId,
6306 substate, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306307 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006308 sme_warn("fail issuing disassoc status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006309 status);
6310 /*
6311 * roam command is completed by caller in the
6312 * failed case
6313 */
6314 fComplete = true;
6315 }
6316 } else if (csr_is_conn_state_ibss(pMac, sessionId)) {
6317 status = csr_roam_issue_stop_bss(pMac, sessionId,
6318 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306319 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006320 sme_warn("fail issuing stop bss status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006321 status);
6322 /*
6323 * roam command is completed by caller in the
6324 * failed case
6325 */
6326 fComplete = true;
6327 }
6328 } else if (csr_is_conn_state_connected_infra_ap(pMac,
6329 sessionId)) {
6330 substate = eCSR_ROAM_SUBSTATE_STOP_BSS_REQ;
6331 status = csr_roam_issue_stop_bss(pMac, sessionId,
6332 substate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306333 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006334 sme_warn("fail issuing stop bss status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006335 status);
6336 /*
6337 * roam command is completed by caller in the
6338 * failed case
6339 */
6340 fComplete = true;
6341 }
6342 } else {
6343 fComplete = true;
6344 }
6345
6346 if (fComplete) {
6347 /* otherwise, we can complete the Roam command here. */
6348 if (eCsrStopRoamingDueToConcurrency == RoamState)
6349 csr_roam_complete(pMac,
Krunal Sonif3583022017-02-10 17:18:10 -08006350 eCsrJoinFailureDueToConcurrency, NULL,
6351 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006352 else
6353 csr_roam_complete(pMac,
Krunal Sonif3583022017-02-10 17:18:10 -08006354 eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006355 }
6356 } else if (eCsrReassocToSelfNoCapChange == RoamState) {
6357 csr_roam_complete(pMac, eCsrSilentlyStopRoamingSaveState,
Krunal Sonif3583022017-02-10 17:18:10 -08006358 NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 } else if (eCsrStartIbssSameIbss == RoamState) {
Krunal Sonif3583022017-02-10 17:18:10 -08006360 csr_roam_complete(pMac, eCsrSilentlyStopRoaming, NULL,
6361 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006362 }
6363
6364 return status;
6365}
6366
Jeff Johnson29e2ca12016-10-14 12:50:38 -07006367static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306368QDF_STATUS csr_process_ft_reassoc_roam_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006369 tSmeCmd *pCommand)
6370{
6371 uint32_t sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306372 struct csr_roam_session *pSession;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306373 struct tag_csrscan_result *pScanResult = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006374 tSirBssDescription *pBssDesc = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306375 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006377 sessionId = pCommand->sessionId;
6378 pSession = CSR_GET_SESSION(pMac, sessionId);
6379
6380 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006381 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306382 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006383 }
6384
6385 if (CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming) {
6386 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006387 sme_debug("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08006388 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306389 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390 }
6391 if (pCommand->u.roamCmd.pRoamBssEntry) {
6392 pScanResult =
6393 GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306394 struct tag_csrscan_result, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006395 pBssDesc = &pScanResult->Result.BssDescriptor;
6396 } else {
6397 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006398 sme_debug("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08006399 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306400 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006401 }
6402 status = csr_roam_issue_reassociate(pMac, sessionId, pBssDesc,
6403 (tDot11fBeaconIEs *) (pScanResult->
6404 Result.pvIes),
6405 &pCommand->u.roamCmd.roamProfile);
6406 return status;
6407}
6408
6409/**
6410 * csr_roam_trigger_reassociate() - Helper function to trigger reassociate
6411 * @mac_ctx: pointer to mac context
6412 * @cmd: sme command
6413 * @roam_info: Roaming infor structure
6414 * @session_ptr: session pointer
6415 * @session_id: session id
6416 *
6417 * This function will trigger reassociate.
6418 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306419 * Return: QDF_STATUS for success or failure.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006420 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306421static QDF_STATUS csr_roam_trigger_reassociate(
Jeff Johnson172237b2017-11-07 15:32:59 -08006422tpAniSirGlobal mac_ctx, tSmeCmd *cmd, struct csr_roam_info *roam_info,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306423 struct csr_roam_session *session_ptr,
6424 uint32_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006425{
6426 tDot11fBeaconIEs *pIes = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306427 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006428
6429 if (session_ptr->pConnectBssDesc) {
6430 status = csr_get_parsed_bss_description_ies(mac_ctx,
6431 session_ptr->pConnectBssDesc, &pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306432 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006433 sme_err("fail to parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006434 } else {
6435 roam_info->reasonCode =
6436 eCsrRoamReasonStaCapabilityChanged;
6437 csr_roam_call_callback(mac_ctx, session_ptr->sessionId,
6438 roam_info, 0, eCSR_ROAM_ROAMING_START,
6439 eCSR_ROAM_RESULT_NONE);
6440 session_ptr->roamingReason = eCsrReassocRoaming;
6441 roam_info->pBssDesc = session_ptr->pConnectBssDesc;
6442 roam_info->pProfile = &cmd->u.roamCmd.roamProfile;
6443 session_ptr->bRefAssocStartCnt++;
6444 csr_roam_call_callback(mac_ctx, session_id, roam_info,
6445 cmd->u.roamCmd.roamId,
6446 eCSR_ROAM_ASSOCIATION_START,
6447 eCSR_ROAM_RESULT_NONE);
6448
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006449 sme_debug("calling csr_roam_issue_reassociate");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006450 status = csr_roam_issue_reassociate(mac_ctx, session_id,
6451 session_ptr->pConnectBssDesc, pIes,
6452 &cmd->u.roamCmd.roamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306453 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006454 sme_err("failed status %d", status);
Krunal Sonidea45952017-02-15 11:58:15 -08006455 csr_release_command(mac_ctx, cmd);
Zhu Jianmine5594d12017-07-11 12:22:46 +08006456 } else {
6457 csr_neighbor_roam_state_transition(mac_ctx,
6458 eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING,
6459 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460 }
6461
Zhu Jianmine5594d12017-07-11 12:22:46 +08006462
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306463 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006464 pIes = NULL;
6465 }
6466 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006467 sme_err("reassoc to same AP failed as connected BSS is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306468 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006469 }
6470 return status;
6471}
6472
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306473QDF_STATUS csr_roam_process_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006474{
Jeff Johnson172237b2017-11-07 15:32:59 -08006475 struct csr_roam_info roamInfo;
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306476 QDF_STATUS lock_status, status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006477 uint32_t sessionId = pCommand->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306478 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479
6480 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006481 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306482 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006484 sme_debug("Roam Reason: %d sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006485 pCommand->u.roamCmd.roamReason, sessionId);
6486
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07006487 pSession->disconnect_reason = pCommand->u.roamCmd.disconnect_reason;
6488
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489 switch (pCommand->u.roamCmd.roamReason) {
6490 case eCsrForcedDisassoc:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006491 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
6492 true, false);
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306493 lock_status = sme_acquire_global_lock(&pMac->sme);
6494 if (!QDF_IS_STATUS_SUCCESS(lock_status)) {
6495 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
6496 sessionId);
6497 return lock_status;
6498 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006499 csr_free_roam_profile(pMac, sessionId);
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306500 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006501 break;
6502 case eCsrSmeIssuedDisassocForHandoff:
6503 /* Not to free pMac->roam.pCurRoamProfile (via
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306504 * csr_free_roam_profile) because its needed after disconnect
6505 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006506 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
6507 true, false);
6508
6509 break;
6510 case eCsrForcedDisassocMICFailure:
6511 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
6512 true, true);
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306513 lock_status = sme_acquire_global_lock(&pMac->sme);
6514 if (!QDF_IS_STATUS_SUCCESS(lock_status)) {
6515 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
6516 sessionId);
6517 return lock_status;
6518 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006519 csr_free_roam_profile(pMac, sessionId);
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306520 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006521 break;
6522 case eCsrForcedDeauth:
6523 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
6524 false, false);
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306525 lock_status = sme_acquire_global_lock(&pMac->sme);
6526 if (!QDF_IS_STATUS_SUCCESS(lock_status)) {
6527 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
6528 sessionId);
6529 return lock_status;
6530 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006531 csr_free_roam_profile(pMac, sessionId);
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306532 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006533 break;
6534 case eCsrHddIssuedReassocToSameAP:
6535 case eCsrSmeIssuedReassocToSameAP:
6536 status = csr_roam_trigger_reassociate(pMac, pCommand, &roamInfo,
6537 pSession, sessionId);
6538 break;
6539 case eCsrCapsChange:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006540 sme_err("received eCsrCapsChange ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006541 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6542 sessionId);
6543 status = csr_roam_issue_disassociate(pMac, sessionId,
6544 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
6545 false);
6546 break;
6547 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006548 sme_debug("received FT Reassoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006549 status = csr_process_ft_reassoc_roam_command(pMac, pCommand);
6550 break;
6551
6552 case eCsrStopBss:
6553 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6554 sessionId);
6555 status = csr_roam_issue_stop_bss(pMac, sessionId,
6556 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
6557 break;
6558
6559 case eCsrForcedDisassocSta:
6560 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6561 sessionId);
6562 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
6563 sessionId);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006564 sme_debug("Disassociate issued with reason: %d",
yeshwanth sriram guntuka46f004f2017-02-07 12:22:31 +05306565 pCommand->u.roamCmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006566 status = csr_send_mb_disassoc_req_msg(pMac, sessionId,
6567 pCommand->u.roamCmd.peerMac,
6568 pCommand->u.roamCmd.reason);
6569 break;
6570
6571 case eCsrForcedDeauthSta:
6572 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6573 sessionId);
6574 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ,
6575 sessionId);
6576 status = csr_send_mb_deauth_req_msg(pMac, sessionId,
6577 pCommand->u.roamCmd.peerMac,
6578 pCommand->u.roamCmd.reason);
6579 break;
6580
6581 case eCsrPerformPreauth:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006582 sme_debug("Attempting FT PreAuth Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006583 status = csr_roam_issue_ft_preauth_req(pMac, sessionId,
6584 pCommand->u.roamCmd.pLastRoamBss);
6585 break;
6586 default:
6587 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6588 sessionId);
6589
6590 if (pCommand->u.roamCmd.fUpdateCurRoamProfile) {
6591 /* Remember the roaming profile */
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306592 lock_status = sme_acquire_global_lock(&pMac->sme);
6593 if (!QDF_IS_STATUS_SUCCESS(lock_status)) {
6594 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
6595 sessionId);
6596 return lock_status;
6597 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006598 csr_free_roam_profile(pMac, sessionId);
6599 pSession->pCurRoamProfile =
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006600 qdf_mem_malloc(sizeof(struct csr_roam_profile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006601 if (NULL != pSession->pCurRoamProfile) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006602 csr_roam_copy_profile(pMac,
6603 pSession->pCurRoamProfile,
6604 &pCommand->u.roamCmd.roamProfile);
6605 }
Padma, Santhosh Kumardbef1c52018-06-21 17:48:48 +05306606 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006607 }
6608 /*
6609 * At this point original uapsd_mask is saved in
6610 * pCurRoamProfile. uapsd_mask in the pCommand may change from
6611 * this point on. Attempt to roam with the new scan results
6612 * (if we need to..)
6613 */
6614 status = csr_roam(pMac, pCommand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306615 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006616 sme_warn("csr_roam() failed with status = 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006617 status);
6618 break;
6619 }
6620 return status;
6621}
6622
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006623void csr_reinit_roam_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
6624{
6625 if (pCommand->u.roamCmd.fReleaseBssList) {
6626 csr_scan_result_purge(pMac, pCommand->u.roamCmd.hBSSList);
6627 pCommand->u.roamCmd.fReleaseBssList = false;
6628 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6629 }
6630 if (pCommand->u.roamCmd.fReleaseProfile) {
6631 csr_release_profile(pMac, &pCommand->u.roamCmd.roamProfile);
6632 pCommand->u.roamCmd.fReleaseProfile = false;
6633 }
Pragaspathi Thilagaraj7dba4a72018-07-27 15:33:15 +05306634 pCommand->u.roamCmd.pLastRoamBss = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006635 pCommand->u.roamCmd.pRoamBssEntry = NULL;
6636 /* Because u.roamCmd is union and share with scanCmd and StatusChange */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306637 qdf_mem_set(&pCommand->u.roamCmd, sizeof(struct roam_cmd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006638}
6639
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306640void csr_reinit_wm_status_change_cmd(tpAniSirGlobal pMac,
6641 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006642{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306643 qdf_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(
6644 struct wmstatus_changecmd),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006645 0);
6646}
6647
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306648void csr_roam_complete(tpAniSirGlobal mac_ctx,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306649 enum csr_roamcomplete_result Result,
6650 void *Context, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006651{
Krunal Sonia8270f52017-02-23 19:51:25 -08006652 tSmeCmd *sme_cmd;
6653 struct wlan_serialization_command *cmd;
6654
6655 cmd = wlan_serialization_peek_head_active_cmd_using_psoc(
6656 mac_ctx->psoc, false);
6657 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006658 sme_err("Roam completion called but cmd is not active");
Krunal Sonia8270f52017-02-23 19:51:25 -08006659 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006660 }
Krunal Sonia8270f52017-02-23 19:51:25 -08006661 sme_cmd = cmd->umac_cmd;
6662 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07006663 sme_err("sme_cmd is NULL");
Krunal Sonia8270f52017-02-23 19:51:25 -08006664 return;
6665 }
6666 if (eSmeCommandRoam == sme_cmd->command) {
6667 csr_roam_process_results(mac_ctx, sme_cmd, Result, Context);
6668 csr_release_command(mac_ctx, sme_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006669 }
6670}
6671
Krunal Sonia8270f52017-02-23 19:51:25 -08006672
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306673void csr_reset_pmkid_candidate_list(tpAniSirGlobal pMac,
6674 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006675{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306676 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306677
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006678 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306679 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006680 return;
6681 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306682 qdf_mem_set(&(pSession->PmkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006683 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
6684 pSession->NumPmkidCandidate = 0;
6685}
6686
6687#ifdef FEATURE_WLAN_WAPI
6688void csr_reset_bkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
6689{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306690 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006692 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306693 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006694 return;
6695 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306696 qdf_mem_set(&(pSession->BkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006697 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
6698 pSession->NumBkidCandidate = 0;
6699}
6700#endif /* FEATURE_WLAN_WAPI */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006701
6702/**
6703 * csr_roam_save_params() - Helper function to save params
6704 * @mac_ctx: pointer to mac context
6705 * @session_ptr: Session pointer
6706 * @auth_type: auth type
6707 * @ie_ptr: pointer to ie
6708 * @ie_local: pointr to local ie
6709 *
6710 * This function will save params to session
6711 *
6712 * Return: none.
6713 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306714static QDF_STATUS csr_roam_save_params(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306715 struct csr_roam_session *session_ptr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006716 eCsrAuthType auth_type,
6717 tDot11fBeaconIEs *ie_ptr,
6718 tDot11fBeaconIEs *ie_local)
6719{
6720 uint32_t nIeLen;
6721 uint8_t *pIeBuf;
6722
6723 if ((eCSR_AUTH_TYPE_RSN == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006724 (eCSR_AUTH_TYPE_FT_RSN == auth_type) ||
6725 (eCSR_AUTH_TYPE_FT_RSN_PSK == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006726#if defined WLAN_FEATURE_11W
6727 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == auth_type) ||
6728 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == auth_type) ||
6729#endif
6730 (eCSR_AUTH_TYPE_RSN_PSK == auth_type)) {
6731 if (ie_local->RSN.present) {
6732 tDot11fIERSN *rsnie = &ie_local->RSN;
6733 /*
6734 * Calculate the actual length
6735 * version + gp_cipher_suite + pwise_cipher_suite_count
Abhishek Singh3f13a812018-01-16 14:24:44 +05306736 * + akm_suite_cnt + reserved + pwise_cipher_suites
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006737 */
6738 nIeLen = 8 + 2 + 2
6739 + (rsnie->pwise_cipher_suite_count * 4)
Abhishek Singh3f13a812018-01-16 14:24:44 +05306740 + (rsnie->akm_suite_cnt * 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006741 if (rsnie->pmkid_count)
6742 /* pmkid */
6743 nIeLen += 2 + rsnie->pmkid_count * 4;
6744
6745 /* nIeLen doesn't count EID and length fields */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306746 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306748 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006750 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
6751 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
Abhishek Singh3f13a812018-01-16 14:24:44 +05306752 /* copy upto akm_suite */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006753 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306754 qdf_mem_copy(pIeBuf, &rsnie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006755 sizeof(rsnie->version));
6756 pIeBuf += sizeof(rsnie->version);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306757 qdf_mem_copy(pIeBuf, &rsnie->gp_cipher_suite,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006758 sizeof(rsnie->gp_cipher_suite));
6759 pIeBuf += sizeof(rsnie->gp_cipher_suite);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306760 qdf_mem_copy(pIeBuf, &rsnie->pwise_cipher_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006761 sizeof(rsnie->pwise_cipher_suite_count));
6762 pIeBuf += sizeof(rsnie->pwise_cipher_suite_count);
6763 if (rsnie->pwise_cipher_suite_count) {
6764 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306765 qdf_mem_copy(pIeBuf, rsnie->pwise_cipher_suites,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006766 rsnie->pwise_cipher_suite_count * 4);
6767 pIeBuf += rsnie->pwise_cipher_suite_count * 4;
6768 }
Abhishek Singh3f13a812018-01-16 14:24:44 +05306769 qdf_mem_copy(pIeBuf, &rsnie->akm_suite_cnt, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006770 pIeBuf += 2;
Abhishek Singh3f13a812018-01-16 14:24:44 +05306771 if (rsnie->akm_suite_cnt) {
6772 /* copy akm_suite */
6773 qdf_mem_copy(pIeBuf, rsnie->akm_suite,
6774 rsnie->akm_suite_cnt * 4);
6775 pIeBuf += rsnie->akm_suite_cnt * 4;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006776 }
6777 /* copy the rest */
Abhishek Singh3f13a812018-01-16 14:24:44 +05306778 qdf_mem_copy(pIeBuf, rsnie->akm_suite +
6779 rsnie->akm_suite_cnt * 4,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006780 2 + rsnie->pmkid_count * 4);
6781 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
6782 }
6783 } else if ((eCSR_AUTH_TYPE_WPA == auth_type) ||
6784 (eCSR_AUTH_TYPE_WPA_PSK == auth_type)) {
6785 if (ie_local->WPA.present) {
6786 tDot11fIEWPA *wpaie = &ie_local->WPA;
6787 /* Calculate the actual length wpaie */
6788 nIeLen = 12 + 2 /* auth_suite_count */
6789 + wpaie->unicast_cipher_count * 4
6790 + wpaie->auth_suite_count * 4;
6791
6792 /* The WPA capabilities follows the Auth Suite
6793 * (two octects)-- this field is optional, and
6794 * we always "send" zero, so just remove it. This is
6795 * consistent with our assumptions in the frames
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306796 * compiler; nIeLen doesn't count EID & length fields
6797 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306798 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006799 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306800 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006801 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
6802 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
6803 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
6804 /* Copy WPA OUI */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306805 qdf_mem_copy(pIeBuf, &csr_wpa_oui[1], 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006806 pIeBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306807 qdf_mem_copy(pIeBuf, &wpaie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006808 8 + wpaie->unicast_cipher_count * 4);
6809 pIeBuf += 8 + wpaie->unicast_cipher_count * 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306810 qdf_mem_copy(pIeBuf, &wpaie->auth_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006811 2 + wpaie->auth_suite_count * 4);
6812 pIeBuf += wpaie->auth_suite_count * 4;
6813 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
6814 }
6815 }
6816#ifdef FEATURE_WLAN_WAPI
6817 else if ((eCSR_AUTH_TYPE_WAPI_WAI_PSK == auth_type) ||
6818 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ==
6819 auth_type)) {
6820 if (ie_local->WAPI.present) {
6821 tDot11fIEWAPI *wapi_ie = &ie_local->WAPI;
6822 /* Calculate the actual length of wapi ie*/
6823 nIeLen = 4 + 2 /* pwise_cipher_suite_count */
6824 + wapi_ie->akm_suite_count * 4
6825 + wapi_ie->unicast_cipher_suite_count * 4
6826 + 6; /* gp_cipher_suite + preauth + reserved */
6827
6828 if (wapi_ie->bkid_count)
6829 nIeLen += 2 + wapi_ie->bkid_count * 4;
6830
6831 /* nIeLen doesn't count EID and length fields */
6832 session_ptr->pWapiRspIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306833 qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006834 if (NULL == session_ptr->pWapiRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306835 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836 session_ptr->pWapiRspIE[0] = DOT11F_EID_WAPI;
6837 session_ptr->pWapiRspIE[1] = (uint8_t) nIeLen;
6838 pIeBuf = session_ptr->pWapiRspIE + 2;
6839 /* copy upto akm_suite_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306840 qdf_mem_copy(pIeBuf, &wapi_ie->version, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006841 pIeBuf += 4;
6842 if (wapi_ie->akm_suite_count) {
6843 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306844 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006845 wapi_ie->akm_suites,
6846 wapi_ie->akm_suite_count * 4);
6847 pIeBuf += wapi_ie->akm_suite_count * 4;
6848 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306849 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850 &wapi_ie->unicast_cipher_suite_count, 2);
6851 pIeBuf += 2;
6852 if (wapi_ie->unicast_cipher_suite_count) {
6853 uint16_t suite_size =
6854 wapi_ie->unicast_cipher_suite_count * 4;
6855 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306856 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006857 wapi_ie->unicast_cipher_suites,
6858 suite_size);
6859 pIeBuf += suite_size;
6860 }
6861 /* gp_cipher_suite */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306862 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863 wapi_ie->multicast_cipher_suite, 4);
6864 pIeBuf += 4;
6865 /* preauth + reserved */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306866 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006867 wapi_ie->multicast_cipher_suite + 4, 2);
6868 pIeBuf += 2;
6869 if (wapi_ie->bkid_count) {
6870 /* bkid_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306871 qdf_mem_copy(pIeBuf, &wapi_ie->bkid_count, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006872 pIeBuf += 2;
6873 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306874 qdf_mem_copy(pIeBuf, wapi_ie->bkid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006875 wapi_ie->bkid_count * 4);
6876 pIeBuf += wapi_ie->bkid_count * 4;
6877 }
6878 session_ptr->nWapiRspIeLength = nIeLen + 2;
6879 }
6880 }
6881#endif /* FEATURE_WLAN_WAPI */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306882 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006883}
6884
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306885static QDF_STATUS csr_roam_save_security_rsp_ie(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886 uint32_t sessionId,
6887 eCsrAuthType authType,
6888 tSirBssDescription *pSirBssDesc,
6889 tDot11fBeaconIEs *pIes)
6890{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306891 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306892 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006893 tDot11fBeaconIEs *pIesLocal = pIes;
6894
6895 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006896 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306897 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006898 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006900 sme_debug("authType %d session %d", authType, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006901 if ((eCSR_AUTH_TYPE_WPA == authType) ||
6902 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
6903 (eCSR_AUTH_TYPE_RSN == authType) ||
6904 (eCSR_AUTH_TYPE_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006905 || (eCSR_AUTH_TYPE_FT_RSN == authType) ||
6906 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006907#ifdef FEATURE_WLAN_WAPI
6908 || (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
6909 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
6910#endif /* FEATURE_WLAN_WAPI */
6911#ifdef WLAN_FEATURE_11W
6912 || (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
6913 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
6914#endif /* FEATURE_WLAN_WAPI */
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05306915 || (eCSR_AUTH_TYPE_SAE == authType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306916 if (!pIesLocal && !QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006917 (csr_get_parsed_bss_description_ies(pMac,
6918 pSirBssDesc, &pIesLocal)))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006919 sme_err(" cannot parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006920 if (pIesLocal) {
6921 status = csr_roam_save_params(pMac, pSession, authType,
6922 pIes, pIesLocal);
6923 if (!pIes)
6924 /* locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306925 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006926 }
6927 }
6928 return status;
6929}
6930
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006931/* Returns whether the current association is a 11r assoc or not */
6932bool csr_roam_is11r_assoc(tpAniSirGlobal pMac, uint8_t sessionId)
6933{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006934 return csr_neighbor_roam_is11r_assoc(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006935}
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08006936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006937/* Returns whether "Legacy Fast Roaming" is currently enabled...or not */
6938bool csr_roam_is_fast_roam_enabled(tpAniSirGlobal pMac, uint32_t sessionId)
6939{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306940 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941
6942 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
6943 pSession = CSR_GET_SESSION(pMac, sessionId);
6944 if (NULL != pSession->pCurRoamProfile) {
6945 if (pSession->pCurRoamProfile->csrPersona !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05306946 QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006947 return false;
6948 }
6949 }
6950 }
6951 if (true == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac)) {
6952 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
6953 } else {
6954 return pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
6955 (!csr_is_concurrent_session_running(pMac));
6956 }
6957}
6958
Sandeep Puligilla68908f22018-02-28 18:20:41 -08006959static void csr_update_scan_entry_associnfo(tpAniSirGlobal mac_ctx,
6960 struct bss_info *bss, enum scan_entry_connection_state state)
6961{
6962 QDF_STATUS status;
6963 struct mlme_info mlme;
6964
6965 sme_debug("Update MLME info in scan database. bssid %pM state: %d",
6966 bss->bssid.bytes, state);
6967 mlme.assoc_state = state;
6968 status = ucfg_scan_update_mlme_by_bssinfo(mac_ctx->pdev, bss, &mlme);
6969 if (QDF_IS_STATUS_ERROR(status))
6970 sme_debug("Failed to update the MLME info in scan entry");
6971}
6972
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnson29e2ca12016-10-14 12:50:38 -07006974static eCsrPhyMode csr_roamdot11mode_to_phymode(uint8_t dot11mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006975{
6976 eCsrPhyMode phymode = eCSR_DOT11_MODE_abg;
6977
6978 switch (dot11mode) {
6979 case WNI_CFG_DOT11_MODE_ALL:
6980 phymode = eCSR_DOT11_MODE_abg;
6981 break;
6982 case WNI_CFG_DOT11_MODE_11A:
6983 phymode = eCSR_DOT11_MODE_11a;
6984 break;
6985 case WNI_CFG_DOT11_MODE_11B:
6986 phymode = eCSR_DOT11_MODE_11b;
6987 break;
6988 case WNI_CFG_DOT11_MODE_11G:
6989 phymode = eCSR_DOT11_MODE_11g;
6990 break;
6991 case WNI_CFG_DOT11_MODE_11N:
6992 phymode = eCSR_DOT11_MODE_11n;
6993 break;
6994 case WNI_CFG_DOT11_MODE_11G_ONLY:
6995 phymode = eCSR_DOT11_MODE_11g_ONLY;
6996 break;
6997 case WNI_CFG_DOT11_MODE_11N_ONLY:
6998 phymode = eCSR_DOT11_MODE_11n_ONLY;
6999 break;
7000 case WNI_CFG_DOT11_MODE_11AC:
7001 phymode = eCSR_DOT11_MODE_11ac;
7002 break;
7003 case WNI_CFG_DOT11_MODE_11AC_ONLY:
7004 phymode = eCSR_DOT11_MODE_11ac_ONLY;
7005 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08007006 case WNI_CFG_DOT11_MODE_11AX:
7007 phymode = eCSR_DOT11_MODE_11ax;
7008 break;
7009 case WNI_CFG_DOT11_MODE_11AX_ONLY:
7010 phymode = eCSR_DOT11_MODE_11ax_ONLY;
7011 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007012 default:
7013 break;
7014 }
7015
7016 return phymode;
7017}
7018#endif
7019
7020#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307021static void csr_roam_synch_clean_up(tpAniSirGlobal mac, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007022{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07007023 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007024 struct roam_offload_synch_fail *roam_offload_failed = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307025 struct csr_roam_session *session = &mac->roam.roamSession[session_id];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007026
7027 /* Clean up the roam synch in progress for LFR3 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307028 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007029 "%s: Roam Synch Failed, Clean Up", __func__);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007030 session->roam_synch_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007031
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307032 roam_offload_failed = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007033 sizeof(struct roam_offload_synch_fail));
7034 if (NULL == roam_offload_failed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307035 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307036 "%s: unable to allocate memory for roam synch fail",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007037 __func__);
7038 return;
7039 }
7040
7041 roam_offload_failed->session_id = session_id;
7042 msg.type = WMA_ROAM_OFFLOAD_SYNCH_FAIL;
7043 msg.reserved = 0;
7044 msg.bodyptr = roam_offload_failed;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08007045 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007046 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307047 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007048 "%s: Unable to post WMA_ROAM_OFFLOAD_SYNCH_FAIL to WMA",
7049 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307050 qdf_mem_free(roam_offload_failed);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051 }
7052}
7053#endif
7054
7055#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7056/**
7057 * csr_roam_copy_ht_profile() - Copy from src to dst
7058 * @dst_profile: Destination HT profile
7059 * @src_profile: Source HT profile
7060 *
7061 * Copy the HT profile from the given source to destination
7062 *
7063 * Return: None
7064 */
7065static void csr_roam_copy_ht_profile(tCsrRoamHTProfile *dst_profile,
7066 tSirSmeHTProfile *src_profile)
7067{
7068 dst_profile->phymode =
7069 csr_roamdot11mode_to_phymode(src_profile->dot11mode);
7070 dst_profile->htCapability = src_profile->htCapability;
7071 dst_profile->htSupportedChannelWidthSet =
7072 src_profile->htSupportedChannelWidthSet;
7073 dst_profile->htRecommendedTxWidthSet =
7074 src_profile->htRecommendedTxWidthSet;
7075 dst_profile->htSecondaryChannelOffset =
7076 src_profile->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007077 dst_profile->vhtCapability = src_profile->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007078 dst_profile->apCenterChan = src_profile->apCenterChan;
7079 dst_profile->apChanWidth = src_profile->apChanWidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007080}
7081#endif
7082
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307083#if defined(WLAN_FEATURE_FILS_SK)
7084/**
7085 * csr_update_fils_seq_number() - Copy FILS sequence number to roam info
7086 * @session: CSR Roam Session
7087 * @roam_info: Roam info
7088 *
7089 * Return: None
7090 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307091static void csr_update_fils_seq_number(struct csr_roam_session *session,
Jeff Johnson172237b2017-11-07 15:32:59 -08007092 struct csr_roam_info *roam_info)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307093{
7094 roam_info->is_fils_connection = true;
7095 roam_info->fils_seq_num = session->fils_seq_num;
7096 pe_debug("FILS sequence number %x", session->fils_seq_num);
7097}
7098#else
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307099static inline void csr_update_fils_seq_number(struct csr_roam_session *session,
Jeff Johnson172237b2017-11-07 15:32:59 -08007100 struct csr_roam_info *roam_info)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307101{}
7102#endif
7103
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007104/**
7105 * csr_roam_process_results_default() - Process the result for start bss
7106 * @mac_ctx: Global MAC Context
7107 * @cmd: Command to be processed
7108 * @context: Additional data in context of the cmd
7109 *
7110 * Return: None
7111 */
7112static void csr_roam_process_results_default(tpAniSirGlobal mac_ctx,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05307113 tSmeCmd *cmd, void *context, enum csr_roamcomplete_result
7114 res)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007115{
7116 uint32_t session_id = cmd->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307117 struct csr_roam_session *session;
Jeff Johnson172237b2017-11-07 15:32:59 -08007118 struct csr_roam_info roam_info;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307119 QDF_STATUS status;
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007120 struct bss_info bss_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007121
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007122 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007123 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007124 return;
7125 }
7126 session = CSR_GET_SESSION(mac_ctx, session_id);
7127
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307128 sme_debug("receives no association indication; FILS %d",
7129 session->is_fils_connection);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007130 sme_debug("Assoc ref count: %d", session->bRefAssocStartCnt);
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007131
7132 if (CSR_IS_INFRASTRUCTURE(&session->connectedProfile)) {
7133 qdf_copy_macaddr(&bss_info.bssid,
7134 &session->connectedProfile.bssid);
7135 bss_info.chan = session->connectedProfile.operationChannel;
7136 bss_info.ssid.length = session->connectedProfile.SSID.length;
7137 qdf_mem_copy(&bss_info.ssid.ssid,
7138 &session->connectedProfile.SSID.ssId,
7139 bss_info.ssid.length);
7140 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007141 if (CSR_IS_INFRASTRUCTURE(&session->connectedProfile)
7142 || CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(mac_ctx, session_id)) {
7143 /*
7144 * do not free for the other profiles as we need
7145 * to send down stop BSS later
7146 */
7147 csr_free_connect_bss_desc(mac_ctx, session_id);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08007148 csr_roam_free_connect_profile(&session->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007149 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
7150 csr_set_default_dot11_mode(mac_ctx);
7151 }
7152
Jeff Johnson172237b2017-11-07 15:32:59 -08007153 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307154 /* Copy FILS sequence number used to be updated to userspace */
7155 if (session->is_fils_connection)
7156 csr_update_fils_seq_number(session, &roam_info);
7157
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007158 switch (cmd->u.roamCmd.roamReason) {
7159 /*
7160 * If this transition is because of an 802.11 OID, then we
7161 * transition back to INIT state so we sit waiting for more
7162 * OIDs to be issued and we don't start the IDLE timer.
7163 */
7164 case eCsrSmeIssuedFTReassoc:
7165 case eCsrSmeIssuedAssocToSimilarAP:
7166 case eCsrHddIssued:
7167 case eCsrSmeIssuedDisassocForHandoff:
7168 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
7169 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007170 roam_info.pBssDesc = cmd->u.roamCmd.pLastRoamBss;
7171 roam_info.pProfile = &cmd->u.roamCmd.roamProfile;
7172 roam_info.statusCode = session->joinFailStatusCode.statusCode;
7173 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307174 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007175 &session->joinFailStatusCode.bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307176 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007178 /*
7179 * If Join fails while Handoff is in progress, indicate
7180 * disassociated event to supplicant to reconnect
7181 */
7182 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)) {
7183 csr_neighbor_roam_indicate_connect(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307184 (uint8_t)session_id, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007185 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007186 if (session->bRefAssocStartCnt > 0) {
7187 session->bRefAssocStartCnt--;
7188 if (eCsrJoinFailureDueToConcurrency == res)
7189 csr_roam_call_callback(mac_ctx, session_id,
7190 &roam_info, cmd->u.roamCmd.roamId,
7191 eCSR_ROAM_ASSOCIATION_COMPLETION,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307192 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193 else
7194 csr_roam_call_callback(mac_ctx, session_id,
7195 &roam_info, cmd->u.roamCmd.roamId,
7196 eCSR_ROAM_ASSOCIATION_COMPLETION,
7197 eCSR_ROAM_RESULT_FAILURE);
7198 } else {
7199 /*
7200 * bRefAssocStartCnt is not incremented when
7201 * eRoamState == eCsrStopRoamingDueToConcurrency
7202 * in csr_roam_join_next_bss API. so handle this in
7203 * else case by sending assoc failure
7204 */
7205 csr_roam_call_callback(mac_ctx, session_id,
Abhishek Singh221cf992018-02-22 13:44:53 +05307206 &roam_info, cmd->u.roamCmd.roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007207 eCSR_ROAM_ASSOCIATION_FAILURE,
7208 eCSR_ROAM_RESULT_FAILURE);
7209 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007210 sme_debug("roam(reason %d) failed", cmd->u.roamCmd.roamReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007211#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7212 sme_qos_update_hand_off((uint8_t) session_id, false);
7213 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7214 SME_QOS_CSR_DISCONNECT_IND, NULL);
7215#endif
7216 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
7217 eCSR_ROAM_RESULT_FAILURE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007218 break;
7219 case eCsrHddIssuedReassocToSameAP:
7220 case eCsrSmeIssuedReassocToSameAP:
7221 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
7222 session_id);
7223
7224 csr_roam_call_callback(mac_ctx, session_id, NULL,
7225 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
7226 eCSR_ROAM_RESULT_FORCED);
7227#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7228 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7229 SME_QOS_CSR_DISCONNECT_IND, NULL);
7230#endif
7231 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
7232 eCSR_ROAM_RESULT_FAILURE, false);
7233 break;
7234 case eCsrForcedDisassoc:
7235 case eCsrForcedDeauth:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
7237 session_id);
Jianmin Zhu1ad0dad2018-09-04 16:19:57 +08007238 csr_roam_call_callback(
7239 mac_ctx, session_id, NULL,
7240 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
7241 eCSR_ROAM_RESULT_FORCED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007242#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7243 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7244 SME_QOS_CSR_DISCONNECT_IND,
7245 NULL);
7246#endif
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007247 csr_update_scan_entry_associnfo(mac_ctx, &bss_info,
7248 SCAN_ENTRY_CON_STATE_NONE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007249 csr_roam_link_down(mac_ctx, session_id);
7250
7251 if (mac_ctx->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007252 sme_warn("FW still in connected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007253 break;
7254 }
7255 break;
7256 case eCsrForcedIbssLeave:
7257 csr_roam_call_callback(mac_ctx, session_id, NULL,
7258 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_LEAVE,
7259 eCSR_ROAM_RESULT_IBSS_STOP);
Krunal Soni2c68f232015-10-26 20:52:51 -07007260 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007261 break;
7262 case eCsrForcedDisassocMICFailure:
7263 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
7264 session_id);
7265
7266 csr_roam_call_callback(mac_ctx, session_id, NULL,
7267 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
7268 eCSR_ROAM_RESULT_MIC_FAILURE);
7269#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7270 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7271 SME_QOS_CSR_DISCONNECT_REQ, NULL);
7272#endif
7273 break;
7274 case eCsrStopBss:
7275 csr_roam_call_callback(mac_ctx, session_id, NULL,
7276 cmd->u.roamCmd.roamId, eCSR_ROAM_INFRA_IND,
7277 eCSR_ROAM_RESULT_INFRA_STOPPED);
7278 break;
7279 case eCsrForcedDisassocSta:
7280 case eCsrForcedDeauthSta:
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05307281 roam_info.rssi = mac_ctx->peer_rssi;
7282 roam_info.tx_rate = mac_ctx->peer_txrate;
7283 roam_info.rx_rate = mac_ctx->peer_rxrate;
7284
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007285 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
7286 session_id);
7287 session = CSR_GET_SESSION(mac_ctx, session_id);
7288 if (CSR_IS_SESSION_VALID(mac_ctx, session_id) &&
7289 CSR_IS_INFRA_AP(&session->connectedProfile)) {
7290 roam_info.u.pConnectedProfile =
7291 &session->connectedProfile;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307292 qdf_mem_copy(roam_info.peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007293 cmd->u.roamCmd.peerMac,
7294 sizeof(tSirMacAddr));
Ashish Kumar Dhanotiyad39c8b52018-03-27 18:18:52 +05307295 roam_info.reasonCode = eCSR_ROAM_RESULT_FORCED;
7296 /* Update the MAC reason code */
7297 roam_info.disassoc_reason = cmd->u.roamCmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007298 roam_info.statusCode = eSIR_SME_SUCCESS;
7299 status = csr_roam_call_callback(mac_ctx, session_id,
7300 &roam_info, cmd->u.roamCmd.roamId,
7301 eCSR_ROAM_LOSTLINK,
7302 eCSR_ROAM_RESULT_FORCED);
7303 }
7304 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007305 default:
7306 csr_roam_state_change(mac_ctx,
7307 eCSR_ROAMING_STATE_IDLE, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007308 break;
7309 }
7310}
7311
7312/**
7313 * csr_roam_process_start_bss_success() - Process the result for start bss
7314 * @mac_ctx: Global MAC Context
7315 * @cmd: Command to be processed
7316 * @context: Additional data in context of the cmd
7317 *
7318 * Return: None
7319 */
7320static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx,
7321 tSmeCmd *cmd, void *context)
7322{
7323 uint32_t session_id = cmd->sessionId;
Jeff Johnson66ee8a92018-03-17 15:24:26 -07007324 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307325 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007326 tSirBssDescription *bss_desc = NULL;
Jeff Johnson172237b2017-11-07 15:32:59 -08007327 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007328 tSirSmeStartBssRsp *start_bss_rsp = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007329 eRoamCmdStatus roam_status;
7330 eCsrRoamResult roam_result;
7331 tDot11fBeaconIEs *ies_ptr = NULL;
7332 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307333 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007334 host_log_ibss_pkt_type *ibss_log;
7335 uint32_t bi;
7336#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7337 tSirSmeHTProfile *src_profile = NULL;
7338 tCsrRoamHTProfile *dst_profile = NULL;
7339#endif
7340
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007341 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007342 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007343 return;
7344 }
7345 session = CSR_GET_SESSION(mac_ctx, session_id);
7346
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007347 /*
7348 * on the StartBss Response, LIM is returning the Bss Description that
7349 * we are beaconing. Add this Bss Description to our scan results and
7350 * chain the Profile to this Bss Description. On a Start BSS, there was
7351 * no detected Bss description (no partner) so we issued the Start Bss
7352 * to start the Ibss without any Bss description. Lim was kind enough
7353 * to return the Bss Description that we start beaconing for the newly
7354 * started Ibss.
7355 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007356 sme_debug("receives start BSS ok indication");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307357 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007358 start_bss_rsp = (tSirSmeStartBssRsp *) context;
Jeff Johnson172237b2017-11-07 15:32:59 -08007359 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007360 if (CSR_IS_IBSS(profile))
7361 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
7362 else if (CSR_IS_INFRA_AP(profile))
7363 session->connectState =
7364 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007365 else if (CSR_IS_NDI(profile))
7366 session->connectState = eCSR_CONNECT_STATE_TYPE_NDI_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007367 else
7368 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007369
7370 bss_desc = &start_bss_rsp->bssDescription;
7371 if (CSR_IS_NDI(profile)) {
7372 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
7373 session_id);
7374 csr_roam_save_ndi_connected_info(mac_ctx, session_id, profile,
7375 bss_desc);
7376 roam_info.u.pConnectedProfile = &session->connectedProfile;
7377 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
7378 sizeof(struct qdf_mac_addr));
Naveen Rawatcb186cf2016-07-11 13:47:19 -07007379 } else {
7380 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
7381 session_id);
7382 if (!QDF_IS_STATUS_SUCCESS
7383 (csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
7384 &ies_ptr))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007385 sme_warn("cannot parse IBSS IEs");
Naveen Rawatcb186cf2016-07-11 13:47:19 -07007386 roam_info.pBssDesc = bss_desc;
7387 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7388 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_IND,
7389 eCSR_ROAM_RESULT_IBSS_START_FAILED);
7390 return;
7391 }
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007392 }
Naveen Rawat334c51b2017-05-05 17:33:32 -07007393 if (!CSR_IS_INFRA_AP(profile) && !CSR_IS_NDI(profile)) {
Abhishek Singhf723e3d2018-02-20 18:02:37 +05307394 csr_scan_append_bss_description(mac_ctx, bss_desc);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007395 }
7396 csr_roam_save_connected_bss_desc(mac_ctx, session_id, bss_desc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08007397 csr_roam_free_connect_profile(&session->connectedProfile);
7398 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
Jeff Johnson536249f2018-05-12 16:48:38 -07007399 csr_roam_save_connected_information(mac_ctx, session_id,
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007400 profile, bss_desc, ies_ptr);
7401 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307402 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007403 /* We are done with the IEs so free it */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307404 qdf_mem_free(ies_ptr);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007405#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7406 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
7407 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7408 if (ibss_log) {
7409 if (CSR_INVALID_SCANRESULT_HANDLE ==
7410 cmd->u.roamCmd.hBSSList) {
7411 /*
7412 * We start the IBSS (didn't find any
7413 * matched IBSS out there)
7414 */
7415 ibss_log->eventId =
7416 WLAN_IBSS_EVENT_START_IBSS_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007417 } else {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007418 ibss_log->eventId =
7419 WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
7420 }
7421 if (bss_desc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307422 qdf_mem_copy(ibss_log->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307423 bss_desc->bssId, QDF_MAC_ADDR_SIZE);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007424 ibss_log->operatingChannel =
7425 bss_desc->channelId;
7426 }
Jeff Johnsonc09caa42018-06-07 22:58:55 -07007427 if (QDF_IS_STATUS_SUCCESS(wlan_cfg_get_int(
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007428 mac_ctx,
7429 WNI_CFG_BEACON_INTERVAL,
7430 &bi)))
7431 /* U8 is not enough for BI */
7432 ibss_log->beaconInterval = (uint8_t) bi;
7433 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
7434 }
7435#endif
7436 /*
7437 * Only set context for non-WDS_STA. We don't even need it for
7438 * WDS_AP. But since the encryption.
7439 * is WPA2-PSK so it won't matter.
7440 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08007441 if (session->pCurRoamProfile &&
7442 !CSR_IS_INFRA_AP(session->pCurRoamProfile)) {
7443 if (CSR_IS_ENC_TYPE_STATIC(
7444 profile->negotiatedUCEncryptionType)) {
7445 /*
7446 * Issue the set Context request to LIM to establish
7447 * the Broadcast STA context for the Ibss. In Rome IBSS
7448 * case, dummy key installation will break proper BSS
7449 * key installation, so skip it.
7450 */
7451 if (!CSR_IS_IBSS(session->pCurRoamProfile)) {
7452 /* NO keys. these key parameters don't matter */
7453 csr_roam_issue_set_context_req(mac_ctx,
7454 session_id,
7455 profile->negotiatedMCEncryptionType,
7456 bss_desc, &bcast_mac, false,
7457 false, eSIR_TX_RX, 0, 0, NULL, 0);
7458 }
7459 }
7460 if (CSR_IS_IBSS(session->pCurRoamProfile) &&
7461 (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
7462 profile->negotiatedUCEncryptionType ||
7463 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
7464 profile->negotiatedUCEncryptionType ||
7465 eCSR_ENCRYPT_TYPE_TKIP ==
7466 profile->negotiatedUCEncryptionType ||
7467 eCSR_ENCRYPT_TYPE_AES ==
7468 profile->negotiatedUCEncryptionType)) {
7469 roam_info.fAuthRequired = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007470 }
7471 }
7472 /*
7473 * Only tell upper layer is we start the BSS because Vista doesn't like
7474 * multiple connection indications. If we don't start the BSS ourself,
7475 * handler of eSIR_SME_JOINED_NEW_BSS will trigger the connection start
7476 * indication in Vista
7477 */
7478 if (!CSR_IS_JOIN_TO_IBSS(profile)) {
7479 roam_status = eCSR_ROAM_IBSS_IND;
7480 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007481 if (CSR_IS_INFRA_AP(profile)) {
7482 roam_status = eCSR_ROAM_INFRA_IND;
7483 roam_result = eCSR_ROAM_RESULT_INFRA_STARTED;
7484 }
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07007485 roam_info.staId = (uint8_t) start_bss_rsp->staId;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007486 if (CSR_IS_NDI(profile)) {
7487 csr_roam_update_ndp_return_params(mac_ctx,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07007488 eCsrStartBssSuccess,
7489 &roam_status,
7490 &roam_result,
7491 &roam_info);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007492 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007493 /*
7494 * Only tell upper layer is we start the BSS because Vista
7495 * doesn't like multiple connection indications. If we don't
7496 * start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS
7497 * will trigger the connection start indication in Vista
7498 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007499 roam_info.statusCode = session->joinFailStatusCode.statusCode;
7500 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
7501 /* We start the IBSS (didn't find any matched IBSS out there) */
7502 roam_info.pBssDesc = bss_desc;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007503 if (bss_desc)
7504 qdf_mem_copy(roam_info.bssid.bytes, bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307505 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007506 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
7507 (csr_is_concurrent_session_running(mac_ctx))) {
7508 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
7509 }
7510#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7511 dst_profile = &session->connectedProfile.HTProfile;
7512 src_profile = &start_bss_rsp->HTProfile;
7513 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307514 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007515 csr_roam_copy_ht_profile(dst_profile, src_profile);
7516#endif
7517 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7518 cmd->u.roamCmd.roamId,
7519 roam_status, roam_result);
7520 }
7521
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007522}
7523
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307524#ifdef WLAN_FEATURE_FILS_SK
7525/**
7526 * populate_fils_params_join_rsp() - Copy FILS params from JOIN rsp
7527 * @mac_ctx: Global MAC Context
7528 * @roam_info: CSR Roam Info
7529 * @join_rsp: SME Join response
7530 *
7531 * Copy the FILS params from the join results
7532 *
7533 * Return: QDF_STATUS
7534 */
7535static QDF_STATUS populate_fils_params_join_rsp(tpAniSirGlobal mac_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -08007536 struct csr_roam_info *roam_info,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307537 tSirSmeJoinRsp *join_rsp)
7538{
7539 QDF_STATUS status = QDF_STATUS_SUCCESS;
7540 struct fils_join_rsp_params *roam_fils_info,
7541 *fils_join_rsp = join_rsp->fils_join_rsp;
7542
7543 if (!fils_join_rsp->fils_pmk_len ||
7544 !fils_join_rsp->fils_pmk || !fils_join_rsp->tk_len ||
7545 !fils_join_rsp->kek_len || !fils_join_rsp->gtk_len) {
7546 sme_err("fils join rsp err: pmk len %d tk len %d kek len %d gtk len %d",
7547 fils_join_rsp->fils_pmk_len,
7548 fils_join_rsp->tk_len,
7549 fils_join_rsp->kek_len,
7550 fils_join_rsp->gtk_len);
7551 status = QDF_STATUS_E_FAILURE;
7552 goto free_fils_join_rsp;
7553 }
7554
7555 roam_info->fils_join_rsp = qdf_mem_malloc(sizeof(*fils_join_rsp));
7556 if (!roam_info->fils_join_rsp) {
7557 sme_err("fils_join_rsp malloc fails!");
7558 status = QDF_STATUS_E_FAILURE;
7559 goto free_fils_join_rsp;
7560 }
7561
7562 roam_fils_info = roam_info->fils_join_rsp;
7563 roam_fils_info->fils_pmk = qdf_mem_malloc(fils_join_rsp->fils_pmk_len);
7564 if (!roam_fils_info->fils_pmk) {
7565 qdf_mem_free(roam_info->fils_join_rsp);
7566 roam_info->fils_join_rsp = NULL;
7567 sme_err("fils_pmk malloc fails!");
7568 status = QDF_STATUS_E_FAILURE;
7569 goto free_fils_join_rsp;
7570 }
7571
7572 roam_info->fils_seq_num = join_rsp->fils_seq_num;
7573 roam_fils_info->fils_pmk_len = fils_join_rsp->fils_pmk_len;
7574 qdf_mem_copy(roam_fils_info->fils_pmk,
7575 fils_join_rsp->fils_pmk, roam_fils_info->fils_pmk_len);
7576
7577 qdf_mem_copy(roam_fils_info->fils_pmkid,
7578 fils_join_rsp->fils_pmkid, PMKID_LEN);
7579
7580 roam_fils_info->kek_len = fils_join_rsp->kek_len;
7581 qdf_mem_copy(roam_fils_info->kek,
7582 fils_join_rsp->kek, roam_fils_info->kek_len);
7583
7584 roam_fils_info->tk_len = fils_join_rsp->tk_len;
7585 qdf_mem_copy(roam_fils_info->tk,
7586 fils_join_rsp->tk, fils_join_rsp->tk_len);
7587
7588 roam_fils_info->gtk_len = fils_join_rsp->gtk_len;
7589 qdf_mem_copy(roam_fils_info->gtk,
7590 fils_join_rsp->gtk, roam_fils_info->gtk_len);
7591
Vignesh Viswanathana1bb0922017-09-15 12:58:48 +05307592 cds_copy_hlp_info(&fils_join_rsp->dst_mac, &fils_join_rsp->src_mac,
7593 fils_join_rsp->hlp_data_len, fils_join_rsp->hlp_data,
7594 &roam_fils_info->dst_mac, &roam_fils_info->src_mac,
7595 &roam_fils_info->hlp_data_len,
7596 roam_fils_info->hlp_data);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307597 sme_debug("FILS connect params copied to CSR!");
7598
7599free_fils_join_rsp:
7600 qdf_mem_free(fils_join_rsp->fils_pmk);
7601 qdf_mem_free(fils_join_rsp);
7602 return status;
7603}
7604
7605/**
7606 * csr_process_fils_join_rsp() - Process join rsp for FILS connection
7607 * @mac_ctx: Global MAC Context
7608 * @profile: CSR Roam Profile
7609 * @session_id: Session ID
7610 * @roam_info: CSR Roam Info
7611 * @bss_desc: BSS description
7612 * @join_rsp: SME Join rsp
7613 *
7614 * Process SME join response for FILS connection
7615 *
7616 * Return: None
7617 */
7618static void csr_process_fils_join_rsp(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07007619 struct csr_roam_profile *profile,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307620 uint32_t session_id,
Jeff Johnson172237b2017-11-07 15:32:59 -08007621 struct csr_roam_info *roam_info,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307622 tSirBssDescription *bss_desc,
7623 tSirSmeJoinRsp *join_rsp)
7624{
7625 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
7626 QDF_STATUS status;
7627
7628 if (!join_rsp || !join_rsp->fils_join_rsp) {
7629 sme_err("Join rsp doesn't have FILS info");
7630 goto process_fils_join_rsp_fail;
7631 }
7632
7633 /* Copy FILS params */
7634 status = populate_fils_params_join_rsp(mac_ctx, roam_info, join_rsp);
7635 if (!QDF_IS_STATUS_SUCCESS(status)) {
7636 sme_err("Copy FILS params join rsp fails");
7637 goto process_fils_join_rsp_fail;
7638 }
7639
7640 status = csr_roam_issue_set_context_req(mac_ctx, session_id,
7641 profile->negotiatedMCEncryptionType,
7642 bss_desc, &bcast_mac, true, false,
7643 eSIR_RX_ONLY, 2,
7644 roam_info->fils_join_rsp->gtk_len,
7645 roam_info->fils_join_rsp->gtk, 0);
7646 if (!QDF_IS_STATUS_SUCCESS(status)) {
7647 sme_err("Set context for bcast fail");
7648 goto process_fils_join_rsp_fail;
7649 }
7650
7651 status = csr_roam_issue_set_context_req(mac_ctx, session_id,
7652 profile->negotiatedUCEncryptionType,
7653 bss_desc, &(bss_desc->bssId), true,
7654 true, eSIR_TX_RX, 0,
7655 roam_info->fils_join_rsp->tk_len,
7656 roam_info->fils_join_rsp->tk, 0);
7657 if (!QDF_IS_STATUS_SUCCESS(status)) {
7658 sme_err("Set context for unicast fail");
7659 goto process_fils_join_rsp_fail;
7660 }
7661 return;
7662
7663process_fils_join_rsp_fail:
7664 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE, session_id);
7665}
7666#else
7667
7668static inline void csr_process_fils_join_rsp(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07007669 struct csr_roam_profile *profile,
7670 uint32_t session_id,
7671 struct csr_roam_info *roam_info,
7672 tSirBssDescription *bss_desc,
7673 tSirSmeJoinRsp *join_rsp)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307674{}
7675#endif
7676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007677/**
7678 * csr_roam_process_join_res() - Process the Join results
7679 * @mac_ctx: Global MAC Context
7680 * @result: Result after the command was processed
7681 * @cmd: Command to be processed
7682 * @context: Additional data in context of the cmd
7683 *
Jeff Johnson3370f3a2018-05-11 09:54:12 -07007684 * Process the join results which are obtained in a successful join
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007685 *
7686 * Return: None
7687 */
7688static void csr_roam_process_join_res(tpAniSirGlobal mac_ctx,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05307689 enum csr_roamcomplete_result res, tSmeCmd *cmd, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007690{
7691 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
7692 sme_QosAssocInfo assoc_info;
7693 uint32_t key_timeout_interval = 0;
7694 uint8_t acm_mask = 0; /* HDD needs ACM mask in assoc rsp callback */
7695 uint32_t session_id = cmd->sessionId;
Jeff Johnson66ee8a92018-03-17 15:24:26 -07007696 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307697 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007698 tSirBssDescription *bss_desc = NULL;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05307699 struct tag_csrscan_result *scan_res = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007700 sme_qos_csr_event_indType ind_qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007701#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7702 tSirSmeHTProfile *src_profile = NULL;
7703 tCsrRoamHTProfile *dst_profile = NULL;
7704#endif
7705 tCsrRoamConnectedProfile *conn_profile = NULL;
7706 tDot11fBeaconIEs *ies_ptr = NULL;
Jeff Johnson172237b2017-11-07 15:32:59 -08007707 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007708 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
7709 tSirSmeJoinRsp *join_rsp = (tSirSmeJoinRsp *) context;
7710 uint32_t len;
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007711 struct bss_info bss_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007712
Nishank Aggarwal68d39272017-05-15 17:05:14 +05307713 if (!join_rsp) {
7714 sme_err("join_rsp is NULL");
7715 return;
7716 }
7717
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007718 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007719 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007720 return;
7721 }
7722 session = CSR_GET_SESSION(mac_ctx, session_id);
7723
Zhang Qian32fd43e2017-08-24 18:36:28 +08007724 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007725 conn_profile = &session->connectedProfile;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307726 if (eCsrReassocSuccess == res) {
7727 roam_info.reassoc = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007728 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307729 } else {
7730 roam_info.reassoc = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007731 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307732 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007733 sme_debug("receives association indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007734 /* always free the memory here */
7735 if (session->pWpaRsnRspIE) {
7736 session->nWpaRsnRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307737 qdf_mem_free(session->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007738 session->pWpaRsnRspIE = NULL;
7739 }
7740#ifdef FEATURE_WLAN_WAPI
7741 if (session->pWapiRspIE) {
7742 session->nWapiRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307743 qdf_mem_free(session->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007744 session->pWapiRspIE = NULL;
7745 }
7746#endif /* FEATURE_WLAN_WAPI */
7747#ifdef FEATURE_WLAN_BTAMP_UT_RF
7748 session->maxRetryCount = 0;
7749 csr_roam_stop_join_retry_timer(mac_ctx, session_id);
7750#endif
7751 /*
7752 * Reset remain_in_power_active_till_dhcp as
7753 * it might have been set by last failed secured connection.
7754 * It should be set only for secured connection.
7755 */
7756 ps_global_info->remain_in_power_active_till_dhcp = false;
7757 if (CSR_IS_INFRASTRUCTURE(profile))
7758 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
7759 else
7760 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
7761 /*
7762 * Use the last connected bssdesc for reassoc-ing to the same AP.
7763 * NOTE: What to do when reassoc to a different AP???
7764 */
7765 if ((eCsrHddIssuedReassocToSameAP == cmd->u.roamCmd.roamReason)
7766 || (eCsrSmeIssuedReassocToSameAP ==
7767 cmd->u.roamCmd.roamReason)) {
7768 bss_desc = session->pConnectBssDesc;
7769 if (bss_desc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307770 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307771 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007772 } else {
7773 if (cmd->u.roamCmd.pRoamBssEntry) {
7774 scan_res = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05307775 struct tag_csrscan_result, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007776 if (scan_res != NULL) {
7777 bss_desc = &scan_res->Result.BssDescriptor;
7778 ies_ptr = (tDot11fBeaconIEs *)
7779 (scan_res->Result.pvIes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307780 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307781 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007782 }
7783 }
7784 }
7785 if (bss_desc) {
7786 roam_info.staId = STA_INVALID_IDX;
Jeff Johnson536249f2018-05-12 16:48:38 -07007787 csr_roam_save_connected_information(mac_ctx, session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007788 profile, bss_desc, ies_ptr);
7789 /* Save WPA/RSN IE */
7790 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
7791 profile->negotiatedAuthType, bss_desc, ies_ptr);
7792#ifdef FEATURE_WLAN_ESE
7793 roam_info.isESEAssoc = conn_profile->isESEAssoc;
7794#endif
7795
7796 /*
7797 * csr_roam_state_change also affects sub-state.
7798 * Hence, csr_roam_state_change happens first and then
7799 * substate change.
7800 * Moving even save profile above so that below
7801 * mentioned conditon is also met.
7802 * JEZ100225: Moved to after saving the profile.
7803 * Fix needed in main/latest
7804 */
7805 csr_roam_state_change(mac_ctx,
7806 eCSR_ROAMING_STATE_JOINED, session_id);
7807
7808 /*
7809 * Make sure the Set Context is issued before link
7810 * indication to NDIS. After link indication is
7811 * made to NDIS, frames could start flowing.
7812 * If we have not set context with LIM, the frames
7813 * will be dropped for the security context may not
7814 * be set properly.
7815 *
7816 * this was causing issues in the 2c_wlan_wep WHQL test
7817 * when the SetContext was issued after the link
7818 * indication. (Link Indication happens in the
7819 * profFSMSetConnectedInfra call).
7820 *
7821 * this reordering was done on titan_prod_usb branch
7822 * and is being replicated here.
7823 */
7824
7825 if (CSR_IS_ENC_TYPE_STATIC
7826 (profile->negotiatedUCEncryptionType) &&
7827 !profile->bWPSAssociation) {
7828 /*
7829 * Issue the set Context request to LIM to establish
7830 * the Unicast STA context
7831 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307832 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007833 csr_roam_issue_set_context_req(mac_ctx,
7834 session_id,
7835 profile->negotiatedUCEncryptionType,
7836 bss_desc, &(bss_desc->bssId),
7837 false, true,
7838 eSIR_TX_RX, 0, 0, NULL, 0))) {
7839 /* NO keys. these key parameters don't matter */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007840 sme_err("Set context for unicast fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841 csr_roam_substate_change(mac_ctx,
7842 eCSR_ROAM_SUBSTATE_NONE, session_id);
7843 }
7844 /*
7845 * Issue the set Context request to LIM
7846 * to establish the Broadcast STA context
7847 * NO keys. these key parameters don't matter
7848 */
7849 csr_roam_issue_set_context_req(mac_ctx, session_id,
7850 profile->negotiatedMCEncryptionType,
7851 bss_desc, &bcast_mac, false, false,
7852 eSIR_TX_RX, 0, 0, NULL, 0);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307853 } else if (CSR_IS_AUTH_TYPE_FILS(profile->negotiatedAuthType)
7854 && join_rsp->is_fils_connection) {
7855 roam_info.is_fils_connection = true;
7856 csr_process_fils_join_rsp(mac_ctx, profile, session_id,
7857 &roam_info, bss_desc, join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007858 } else {
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007859 /* Need to wait for supplicant authtication */
7860 roam_info.fAuthRequired = true;
7861 /*
7862 * Set the substate to WaitForKey in case
7863 * authentiation is needed
7864 */
7865 csr_roam_substate_change(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007866 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
7867 session_id);
7868
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007869 /*
7870 * Set remain_in_power_active_till_dhcp to make
7871 * sure we wait for until keys are set before
7872 * going into BMPS.
7873 */
7874 ps_global_info->remain_in_power_active_till_dhcp
7875 = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007876
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007877 if (profile->bWPSAssociation)
7878 key_timeout_interval =
7879 CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
7880 else
7881 key_timeout_interval =
7882 CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007883
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007884 /* Save session_id in case of timeout */
7885 mac_ctx->roam.WaitForKeyTimerInfo.sessionId =
7886 (uint8_t) session_id;
7887 /*
7888 * This time should be long enough for the rest
7889 * of the process plus setting key
7890 */
7891 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007892 (csr_roam_start_wait_for_key_timer(
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007893 mac_ctx, key_timeout_interval))
7894 ) {
7895 /* Reset state so nothing is blocked. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007896 sme_err("Failed preauth timer start");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007897 csr_roam_substate_change(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007898 eCSR_ROAM_SUBSTATE_NONE,
7899 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007900 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007901 }
7902
7903 assoc_info.pBssDesc = bss_desc; /* could be NULL */
7904 assoc_info.pProfile = profile;
7905 if (context) {
7906#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007907 if (session->roam_synch_in_progress)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307908 QDF_TRACE(QDF_MODULE_ID_SME,
7909 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007910 FL("LFR3:Clear Connected info"));
7911#endif
7912 csr_roam_free_connected_info(mac_ctx,
7913 &session->connectedInfo);
7914 len = join_rsp->assocReqLength +
7915 join_rsp->assocRspLength +
7916 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007917 len += join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007918#ifdef FEATURE_WLAN_ESE
7919 len += join_rsp->tspecIeLen;
7920#endif
7921 if (len) {
7922 session->connectedInfo.pbFrames =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307923 qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007924 if (session->connectedInfo.pbFrames !=
7925 NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307926 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007927 session->connectedInfo.pbFrames,
7928 join_rsp->frames, len);
7929 session->connectedInfo.nAssocReqLength =
7930 join_rsp->assocReqLength;
7931 session->connectedInfo.nAssocRspLength =
7932 join_rsp->assocRspLength;
7933 session->connectedInfo.nBeaconLength =
7934 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007935 session->connectedInfo.nRICRspLength =
7936 join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007937#ifdef FEATURE_WLAN_ESE
7938 session->connectedInfo.nTspecIeLength =
7939 join_rsp->tspecIeLen;
7940#endif
7941 roam_info.nAssocReqLength =
7942 join_rsp->assocReqLength;
7943 roam_info.nAssocRspLength =
7944 join_rsp->assocRspLength;
7945 roam_info.nBeaconLength =
7946 join_rsp->beaconLength;
7947 roam_info.pbFrames =
7948 session->connectedInfo.pbFrames;
7949 }
7950 }
7951 if (cmd->u.roamCmd.fReassoc)
7952 roam_info.fReassocReq =
7953 roam_info.fReassocRsp = true;
7954 conn_profile->vht_channel_width =
7955 join_rsp->vht_channel_width;
7956 session->connectedInfo.staId =
7957 (uint8_t) join_rsp->staId;
7958 roam_info.staId = (uint8_t) join_rsp->staId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007959 roam_info.timingMeasCap = join_rsp->timingMeasCap;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05307960 roam_info.chan_info.nss = join_rsp->nss;
7961 roam_info.chan_info.rate_flags =
7962 join_rsp->max_rate_flags;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +05307963 roam_info.chan_info.ch_width =
7964 join_rsp->vht_channel_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007965#ifdef FEATURE_WLAN_TDLS
7966 roam_info.tdls_prohibited = join_rsp->tdls_prohibited;
7967 roam_info.tdls_chan_swit_prohibited =
7968 join_rsp->tdls_chan_swit_prohibited;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007969 sme_debug("tdls:prohibit: %d chan_swit_prohibit: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007970 roam_info.tdls_prohibited,
7971 roam_info.tdls_chan_swit_prohibited);
7972#endif
7973#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7974 src_profile = &join_rsp->HTProfile;
7975 dst_profile = &conn_profile->HTProfile;
7976 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307977 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007978 csr_roam_copy_ht_profile(dst_profile,
7979 src_profile);
7980#endif
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307981 roam_info.vht_caps = join_rsp->vht_caps;
7982 roam_info.ht_caps = join_rsp->ht_caps;
7983 roam_info.hs20vendor_ie = join_rsp->hs20vendor_ie;
7984 roam_info.ht_operation = join_rsp->ht_operation;
7985 roam_info.vht_operation = join_rsp->vht_operation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007986 } else {
7987 if (cmd->u.roamCmd.fReassoc) {
7988 roam_info.fReassocReq =
7989 roam_info.fReassocRsp = true;
7990 roam_info.nAssocReqLength =
7991 session->connectedInfo.nAssocReqLength;
7992 roam_info.nAssocRspLength =
7993 session->connectedInfo.nAssocRspLength;
7994 roam_info.nBeaconLength =
7995 session->connectedInfo.nBeaconLength;
7996 roam_info.pbFrames =
7997 session->connectedInfo.pbFrames;
7998 }
7999 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008000 /*
8001 * Update the staId from the previous connected profile info
8002 * as the reassociation is triggred at SME/HDD
8003 */
8004
8005 if ((eCsrHddIssuedReassocToSameAP ==
8006 cmd->u.roamCmd.roamReason) ||
8007 (eCsrSmeIssuedReassocToSameAP ==
8008 cmd->u.roamCmd.roamReason))
8009 roam_info.staId = session->connectedInfo.staId;
8010
8011#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8012 /*
8013 * Indicate SME-QOS with reassoc success event,
8014 * only after copying the frames
8015 */
8016 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id, ind_qos,
8017 &assoc_info);
8018#endif
8019 roam_info.pBssDesc = bss_desc;
8020 roam_info.statusCode =
8021 session->joinFailStatusCode.statusCode;
8022 roam_info.reasonCode =
8023 session->joinFailStatusCode.reasonCode;
8024#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8025 acm_mask = sme_qos_get_acm_mask(mac_ctx, bss_desc, NULL);
8026#endif
8027 conn_profile->acm_mask = acm_mask;
8028 /*
8029 * start UAPSD if uapsd_mask is not 0 because HDD will
8030 * configure for trigger frame It may be better to let QoS do
8031 * this????
8032 */
8033 if (conn_profile->modifyProfileFields.uapsd_mask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008034 sme_err(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008035 " uapsd_mask (0x%X) set, request UAPSD now",
8036 conn_profile->modifyProfileFields.uapsd_mask);
Kiran Kumar Lokere4de87552018-06-28 13:49:17 -07008037 sme_ps_start_uapsd(MAC_HANDLE(mac_ctx), session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008038 }
8039 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
8040 roam_info.u.pConnectedProfile = conn_profile;
8041
8042 if (session->bRefAssocStartCnt > 0) {
8043 session->bRefAssocStartCnt--;
8044 if (!IS_FEATURE_SUPPORTED_BY_FW
8045 (SLM_SESSIONIZATION) &&
8046 (csr_is_concurrent_session_running(mac_ctx))) {
8047 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
8048 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008049 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8050 cmd->u.roamCmd.roamId,
8051 eCSR_ROAM_ASSOCIATION_COMPLETION,
8052 eCSR_ROAM_RESULT_ASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008053 }
8054
Sandeep Puligilla68908f22018-02-28 18:20:41 -08008055 qdf_copy_macaddr(&bss_info.bssid, &conn_profile->bssid);
8056 bss_info.chan = conn_profile->operationChannel;
8057 bss_info.ssid.length =
8058 conn_profile->SSID.length;
8059 qdf_mem_copy(&bss_info.ssid.ssid,
8060 &conn_profile->SSID.ssId,
8061 bss_info.ssid.length);
8062 csr_update_scan_entry_associnfo(mac_ctx,
8063 &bss_info, SCAN_ENTRY_CON_STATE_ASSOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008064 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
8065 eCSR_ROAM_RESULT_NONE, true);
8066 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
8067#ifdef FEATURE_WLAN_WAPI
8068 csr_reset_bkid_candidate_list(mac_ctx, session_id);
8069#endif
8070 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008071 sme_warn("Roam command doesn't have a BSS desc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008072 }
8073 /* Not to signal link up because keys are yet to be set.
8074 * The linkup function will overwrite the sub-state that
8075 * we need to keep at this point.
8076 */
8077 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
8078#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008079 if (session->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308080 QDF_TRACE(QDF_MODULE_ID_SME,
8081 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008082 FL
8083 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
8084 }
8085#endif
8086 csr_roam_link_up(mac_ctx, conn_profile->bssid);
8087 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308088 sme_free_join_rsp_fils_params(&roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008089}
8090
8091/**
8092 * csr_roam_process_results() - Process the Roam Results
8093 * @mac_ctx: Global MAC Context
8094 * @cmd: Command that has been processed
8095 * @res: Results available after processing the command
8096 * @context: Context
8097 *
8098 * Process the available results and make an appropriate decision
8099 *
8100 * Return: true if the command can be released, else not.
8101 */
8102static bool csr_roam_process_results(tpAniSirGlobal mac_ctx, tSmeCmd *cmd,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05308103 enum csr_roamcomplete_result res,
8104 void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008105{
8106 bool release_cmd = true;
8107 tSirBssDescription *bss_desc = NULL;
Jeff Johnson172237b2017-11-07 15:32:59 -08008108 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008109 uint32_t session_id = cmd->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308110 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008111 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008112 eRoamCmdStatus roam_status;
8113 eCsrRoamResult roam_result;
8114 host_log_ibss_pkt_type *ibss_log;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008115 tSirSmeStartBssRsp *start_bss_rsp = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008116
8117 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008118 sme_err("session %d not found ", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008119 return false;
8120 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008121
8122 sme_debug("Processing ROAM results...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008123 switch (res) {
8124 case eCsrJoinSuccess:
8125 case eCsrReassocSuccess:
8126 csr_roam_process_join_res(mac_ctx, res, cmd, context);
8127 break;
8128 case eCsrStartBssSuccess:
8129 csr_roam_process_start_bss_success(mac_ctx, cmd, context);
8130 break;
8131 case eCsrStartBssFailure:
8132#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8133 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
8134 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8135 if (ibss_log) {
8136 ibss_log->status = WLAN_IBSS_STATUS_FAILURE;
8137 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
8138 }
8139#endif
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008140 start_bss_rsp = (tSirSmeStartBssRsp *)context;
8141 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008142 roam_status = eCSR_ROAM_IBSS_IND;
8143 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008144 if (CSR_IS_INFRA_AP(profile)) {
8145 roam_status = eCSR_ROAM_INFRA_IND;
8146 roam_result = eCSR_ROAM_RESULT_INFRA_START_FAILED;
8147 }
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008148 if (CSR_IS_NDI(profile)) {
8149 csr_roam_update_ndp_return_params(mac_ctx,
8150 eCsrStartBssFailure,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008151 &roam_status, &roam_result, &roam_info);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008152 }
8153
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308154 if (context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008155 bss_desc = (tSirBssDescription *) context;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308156 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008157 bss_desc = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008158 roam_info.pBssDesc = bss_desc;
8159 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8160 cmd->u.roamCmd.roamId, roam_status,
8161 roam_result);
8162 csr_set_default_dot11_mode(mac_ctx);
8163 break;
8164 case eCsrSilentlyStopRoaming:
8165 /*
8166 * We are here because we try to start the same IBSS.
8167 * No message to PE. return the roaming state to Joined.
8168 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008169 sme_debug("receives silently stop roam ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008170 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
8171 session_id);
8172 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
8173 session_id);
Jeff Johnson172237b2017-11-07 15:32:59 -08008174 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008175 roam_info.pBssDesc = session->pConnectBssDesc;
8176 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308177 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008178 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05308179 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008180 /*
8181 * Since there is no change in the current state, simply pass
8182 * back no result otherwise HDD may be mistakenly mark to
8183 * disconnected state.
8184 */
8185 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8186 cmd->u.roamCmd.roamId,
8187 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE);
8188 break;
8189 case eCsrSilentlyStopRoamingSaveState:
8190 /* We are here because we try to connect to the same AP */
8191 /* No message to PE */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008192 sme_debug("receives silently stop roaming indication");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308193 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008194
8195 /* to aviod resetting the substate to NONE */
8196 mac_ctx->roam.curState[session_id] = eCSR_ROAMING_STATE_JOINED;
8197 /*
8198 * No need to change substate to wai_for_key because there
8199 * is no state change
8200 */
8201 roam_info.pBssDesc = session->pConnectBssDesc;
8202 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308203 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008204 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05308205 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008206 roam_info.statusCode = session->joinFailStatusCode.statusCode;
8207 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
8208 roam_info.nBeaconLength = session->connectedInfo.nBeaconLength;
8209 roam_info.nAssocReqLength =
8210 session->connectedInfo.nAssocReqLength;
8211 roam_info.nAssocRspLength =
8212 session->connectedInfo.nAssocRspLength;
8213 roam_info.pbFrames = session->connectedInfo.pbFrames;
8214 roam_info.staId = session->connectedInfo.staId;
8215 roam_info.u.pConnectedProfile = &session->connectedProfile;
Abhishek Singhacfdc922015-12-30 17:31:21 +05308216 if (0 == roam_info.staId)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308217 QDF_ASSERT(0);
Abhishek Singhacfdc922015-12-30 17:31:21 +05308218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 session->bRefAssocStartCnt--;
8220 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8221 cmd->u.roamCmd.roamId,
8222 eCSR_ROAM_ASSOCIATION_COMPLETION,
8223 eCSR_ROAM_RESULT_ASSOCIATED);
8224 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
8225 eCSR_ROAM_RESULT_ASSOCIATED, true);
8226 break;
8227 case eCsrReassocFailure:
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008228 /*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308229 * Currently Reassoc failure is handled through eCsrJoinFailure
8230 * Need to revisit for eCsrReassocFailure handling
8231 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008232#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8233 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
8234 SME_QOS_CSR_REASSOC_FAILURE, NULL);
8235#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008236 break;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008237 case eCsrStopBssSuccess:
8238 if (CSR_IS_NDI(profile)) {
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05308239 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008240 csr_roam_update_ndp_return_params(mac_ctx, res,
8241 &roam_status, &roam_result, &roam_info);
8242 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8243 cmd->u.roamCmd.roamId,
8244 roam_status, roam_result);
8245 }
8246 break;
8247 case eCsrStopBssFailure:
8248 if (CSR_IS_NDI(profile)) {
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05308249 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008250 csr_roam_update_ndp_return_params(mac_ctx, res,
8251 &roam_status, &roam_result, &roam_info);
8252 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8253 cmd->u.roamCmd.roamId,
8254 roam_status, roam_result);
8255 }
8256 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008257 case eCsrJoinFailure:
8258 case eCsrNothingToJoin:
8259 case eCsrJoinFailureDueToConcurrency:
8260 default:
8261 csr_roam_process_results_default(mac_ctx, cmd, context, res);
8262 break;
8263 }
8264 return release_cmd;
8265}
8266
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308267#ifdef WLAN_FEATURE_FILS_SK
8268/*
8269 * update_profile_fils_info: API to update FILS info from
8270 * source profile to destination profile.
8271 * @des_profile: pointer to destination profile
8272 * @src_profile: pointer to souce profile
8273 *
8274 * Return: None
8275 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008276static void update_profile_fils_info(struct csr_roam_profile *des_profile,
8277 struct csr_roam_profile *src_profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308278{
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308279 if (!src_profile || !src_profile->fils_con_info)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308280 return;
8281
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308282 sme_debug("is fils %d", src_profile->fils_con_info->is_fils_connection);
8283
8284 if (!src_profile->fils_con_info->is_fils_connection)
8285 return;
8286
8287 des_profile->fils_con_info =
8288 qdf_mem_malloc(sizeof(struct cds_fils_connection_info));
8289 if (!des_profile->fils_con_info) {
8290 sme_err("failed to allocate memory");
8291 return;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308292 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308293
8294 qdf_mem_copy(des_profile->fils_con_info,
8295 src_profile->fils_con_info,
8296 sizeof(struct cds_fils_connection_info));
8297
8298 des_profile->hlp_ie =
8299 qdf_mem_malloc(src_profile->hlp_ie_len);
8300 if (!des_profile->hlp_ie) {
8301 sme_err("failed to allocate memory for hlp ie");
8302 return;
8303 }
8304
8305 qdf_mem_copy(des_profile->hlp_ie, src_profile->hlp_ie,
8306 src_profile->hlp_ie_len);
8307 des_profile->hlp_ie_len = src_profile->hlp_ie_len;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308308}
8309#else
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008310static inline
8311void update_profile_fils_info(struct csr_roam_profile *des_profile,
8312 struct csr_roam_profile *src_profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308313{ }
8314#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308315QDF_STATUS csr_roam_copy_profile(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008316 struct csr_roam_profile *pDstProfile,
8317 struct csr_roam_profile *pSrcProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008318{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308319 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008320 uint32_t size = 0;
8321
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008322 qdf_mem_set(pDstProfile, sizeof(struct csr_roam_profile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008323 if (pSrcProfile->BSSIDs.numOfBSSIDs) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308324 size = sizeof(struct qdf_mac_addr) * pSrcProfile->BSSIDs.
8325 numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308326 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008327 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308328 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008329 goto end;
8330 }
8331 pDstProfile->BSSIDs.numOfBSSIDs =
8332 pSrcProfile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308333 qdf_mem_copy(pDstProfile->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008334 pSrcProfile->BSSIDs.bssid, size);
8335 }
8336 if (pSrcProfile->SSIDs.numOfSSIDs) {
8337 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308338 pDstProfile->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008339 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308340 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008341 goto end;
8342 }
8343 pDstProfile->SSIDs.numOfSSIDs =
8344 pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308345 qdf_mem_copy(pDstProfile->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008346 pSrcProfile->SSIDs.SSIDList, size);
8347 }
8348 if (pSrcProfile->nWPAReqIELength) {
8349 pDstProfile->pWPAReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308350 qdf_mem_malloc(pSrcProfile->nWPAReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008351 if (NULL == pDstProfile->pWPAReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308352 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008353 goto end;
8354 }
8355 pDstProfile->nWPAReqIELength =
8356 pSrcProfile->nWPAReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308357 qdf_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008358 pSrcProfile->nWPAReqIELength);
8359 }
8360 if (pSrcProfile->nRSNReqIELength) {
8361 pDstProfile->pRSNReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308362 qdf_mem_malloc(pSrcProfile->nRSNReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008363 if (NULL == pDstProfile->pRSNReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308364 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008365 goto end;
8366 }
8367 pDstProfile->nRSNReqIELength =
8368 pSrcProfile->nRSNReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308369 qdf_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008370 pSrcProfile->nRSNReqIELength);
8371 }
8372#ifdef FEATURE_WLAN_WAPI
8373 if (pSrcProfile->nWAPIReqIELength) {
8374 pDstProfile->pWAPIReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308375 qdf_mem_malloc(pSrcProfile->nWAPIReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008376 if (NULL == pDstProfile->pWAPIReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308377 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008378 goto end;
8379 }
8380 pDstProfile->nWAPIReqIELength =
8381 pSrcProfile->nWAPIReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308382 qdf_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008383 pSrcProfile->nWAPIReqIELength);
8384 }
8385#endif /* FEATURE_WLAN_WAPI */
8386 if (pSrcProfile->nAddIEScanLength) {
8387 pDstProfile->pAddIEScan =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308388 qdf_mem_malloc(pSrcProfile->nAddIEScanLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008389 if (NULL == pDstProfile->pAddIEScan) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308390 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008391 goto end;
8392 }
8393 pDstProfile->nAddIEScanLength =
8394 pSrcProfile->nAddIEScanLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308395 qdf_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008396 pSrcProfile->nAddIEScanLength);
8397 }
8398 if (pSrcProfile->nAddIEAssocLength) {
8399 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308400 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008401 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308402 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008403 goto end;
8404 }
8405 pDstProfile->nAddIEAssocLength =
8406 pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308407 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008408 pSrcProfile->nAddIEAssocLength);
8409 }
8410 if (pSrcProfile->ChannelInfo.ChannelList) {
8411 pDstProfile->ChannelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308412 qdf_mem_malloc(pSrcProfile->ChannelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008413 numOfChannels);
8414 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308415 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008416 goto end;
8417 }
8418 pDstProfile->ChannelInfo.numOfChannels =
8419 pSrcProfile->ChannelInfo.numOfChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308420 qdf_mem_copy(pDstProfile->ChannelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008421 pSrcProfile->ChannelInfo.ChannelList,
8422 pSrcProfile->ChannelInfo.numOfChannels);
8423 }
8424 pDstProfile->AuthType = pSrcProfile->AuthType;
8425 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
8426 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
8427 pDstProfile->negotiatedUCEncryptionType =
8428 pSrcProfile->negotiatedUCEncryptionType;
8429 pDstProfile->negotiatedMCEncryptionType =
8430 pSrcProfile->negotiatedMCEncryptionType;
8431 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
8432#ifdef WLAN_FEATURE_11W
8433 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
8434 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
8435 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
8436#endif
8437 pDstProfile->BSSType = pSrcProfile->BSSType;
8438 pDstProfile->phyMode = pSrcProfile->phyMode;
8439 pDstProfile->csrPersona = pSrcProfile->csrPersona;
8440
8441#ifdef FEATURE_WLAN_WAPI
8442 if (csr_is_profile_wapi(pSrcProfile))
8443 if (pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
8444 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
8445#endif /* FEATURE_WLAN_WAPI */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 pDstProfile->ch_params.ch_width = pSrcProfile->ch_params.ch_width;
8447 pDstProfile->ch_params.center_freq_seg0 =
8448 pSrcProfile->ch_params.center_freq_seg0;
8449 pDstProfile->ch_params.center_freq_seg1 =
8450 pSrcProfile->ch_params.center_freq_seg1;
8451 pDstProfile->ch_params.sec_ch_offset =
8452 pSrcProfile->ch_params.sec_ch_offset;
8453 /*Save the WPS info */
8454 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
8455 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Abhishek Singhb59f8d42017-07-31 14:42:47 +05308456 pDstProfile->force_24ghz_in_ht20 = pSrcProfile->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008457 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
8458 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
8459 pDstProfile->privacy = pSrcProfile->privacy;
8460 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
8461 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
8462 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
8463 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
8464 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
8465 pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
8466 pDstProfile->protEnabled = pSrcProfile->protEnabled;
8467 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
8468 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
8469 pDstProfile->wps_state = pSrcProfile->wps_state;
8470 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
8471 pDstProfile->sap_dot11mc = pSrcProfile->sap_dot11mc;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07008472 pDstProfile->supplicant_disabled_roaming =
8473 pSrcProfile->supplicant_disabled_roaming;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308474 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008475 sizeof(pDstProfile->Keys));
8476#ifdef WLAN_FEATURE_11W
8477 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
8478 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
8479 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
8480#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008481 if (pSrcProfile->MDID.mdiePresent) {
8482 pDstProfile->MDID.mdiePresent = 1;
8483 pDstProfile->MDID.mobilityDomain =
8484 pSrcProfile->MDID.mobilityDomain;
8485 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308486 qdf_mem_copy(&pDstProfile->addIeParams, &pSrcProfile->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008487 sizeof(tSirAddIeParams));
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308488
8489 update_profile_fils_info(pDstProfile, pSrcProfile);
8490
Jiachao Wu712d4fd2017-08-23 16:52:34 +08008491 pDstProfile->beacon_tx_rate = pSrcProfile->beacon_tx_rate;
8492
Agrawal Ashish06e76d22016-08-18 16:44:48 +05308493 if (pSrcProfile->supported_rates.numRates) {
8494 qdf_mem_copy(pDstProfile->supported_rates.rate,
8495 pSrcProfile->supported_rates.rate,
8496 pSrcProfile->supported_rates.numRates);
8497 pDstProfile->supported_rates.numRates =
8498 pSrcProfile->supported_rates.numRates;
8499 }
8500 if (pSrcProfile->extended_rates.numRates) {
8501 qdf_mem_copy(pDstProfile->extended_rates.rate,
8502 pSrcProfile->extended_rates.rate,
8503 pSrcProfile->extended_rates.numRates);
8504 pDstProfile->extended_rates.numRates =
8505 pSrcProfile->extended_rates.numRates;
8506 }
Arif Hussain671a1902017-03-17 09:08:32 -07008507 pDstProfile->cac_duration_ms = pSrcProfile->cac_duration_ms;
8508 pDstProfile->dfs_regdomain = pSrcProfile->dfs_regdomain;
hqu16d6e082017-09-04 10:52:31 +08008509 pDstProfile->chan_switch_hostapd_rate_enabled =
8510 pSrcProfile->chan_switch_hostapd_rate_enabled;
Abhishek Singh6454ad32017-12-20 10:42:21 +05308511 pDstProfile->force_rsne_override = pSrcProfile->force_rsne_override;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008512end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308513 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008514 csr_release_profile(pMac, pDstProfile);
8515 pDstProfile = NULL;
8516 }
8517
8518 return status;
8519}
8520
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308521QDF_STATUS csr_roam_copy_connected_profile(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008522 uint32_t sessionId,
8523 struct csr_roam_profile *pDstProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008524{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308525 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008526 tCsrRoamConnectedProfile *pSrcProfile =
8527 &pMac->roam.roamSession[sessionId].connectedProfile;
8528
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008529 qdf_mem_set(pDstProfile, sizeof(struct csr_roam_profile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008530
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308531 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008532 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308533 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008534 sme_err("failed to allocate memory for BSSID "
8535 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008536 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
8537 goto end;
8538 }
8539 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Anurag Chouhanc5548422016-02-24 18:33:27 +05308540 qdf_copy_macaddr(pDstProfile->BSSIDs.bssid, &pSrcProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008541
Yingying Tangd5661072016-10-20 17:53:01 +08008542 if (pSrcProfile->SSID.length > 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008543 pDstProfile->SSIDs.SSIDList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308544 qdf_mem_malloc(sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008545 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308546 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008547 sme_err("failed to allocate memory for SSID "
8548 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008549 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
8550 goto end;
8551 }
8552 pDstProfile->SSIDs.numOfSSIDs = 1;
8553 pDstProfile->SSIDs.SSIDList[0].handoffPermitted =
8554 pSrcProfile->handoffPermitted;
8555 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
8556 pSrcProfile->ssidHidden;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308557 qdf_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008558 &pSrcProfile->SSID, sizeof(tSirMacSSid));
8559 }
8560 if (pSrcProfile->nAddIEAssocLength) {
8561 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308562 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008563 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308564 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008565 sme_err("failed to allocate mem for additional ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008566 goto end;
8567 }
8568 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308569 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008570 pSrcProfile->nAddIEAssocLength);
8571 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308572 pDstProfile->ChannelInfo.ChannelList = qdf_mem_malloc(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008573 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308574 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008575 goto end;
8576 }
8577 pDstProfile->ChannelInfo.numOfChannels = 1;
8578 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
8579 pDstProfile->AuthType.numEntries = 1;
8580 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
8581 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
8582 pDstProfile->EncryptionType.numEntries = 1;
8583 pDstProfile->EncryptionType.encryptionType[0] =
8584 pSrcProfile->EncryptionType;
8585 pDstProfile->negotiatedUCEncryptionType =
8586 pSrcProfile->EncryptionType;
8587 pDstProfile->mcEncryptionType.numEntries = 1;
8588 pDstProfile->mcEncryptionType.encryptionType[0] =
8589 pSrcProfile->mcEncryptionType;
8590 pDstProfile->negotiatedMCEncryptionType =
8591 pSrcProfile->mcEncryptionType;
8592 pDstProfile->BSSType = pSrcProfile->BSSType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308593 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008594 sizeof(pDstProfile->Keys));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008595 if (pSrcProfile->MDID.mdiePresent) {
8596 pDstProfile->MDID.mdiePresent = 1;
8597 pDstProfile->MDID.mobilityDomain =
8598 pSrcProfile->MDID.mobilityDomain;
8599 }
Krunal Sonib2f13042015-11-02 18:41:08 -08008600#ifdef WLAN_FEATURE_11W
8601 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
8602 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
8603 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
8604#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008605
8606end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308607 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008608 csr_release_profile(pMac, pDstProfile);
8609 pDstProfile = NULL;
8610 }
8611
8612 return status;
8613}
8614
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308615QDF_STATUS csr_roam_issue_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008616 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008617 tScanResultHandle hBSSList,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308618 enum csr_roam_reason reason, uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008619 bool fImediate, bool fClearScan)
8620{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308621 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008622 tSmeCmd *pCommand;
8623
8624 pCommand = csr_get_command_buffer(pMac);
8625 if (NULL == pCommand) {
Will Huang8e8d3002018-05-11 10:48:03 +08008626 csr_scan_result_purge(pMac, hBSSList);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008627 sme_err(" fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308628 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008629 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308630 if (fClearScan)
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05308631 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
8632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008633 pCommand->u.roamCmd.fReleaseProfile = false;
8634 if (NULL == pProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308635 /* We can roam now
8636 * Since pProfile is NULL, we need to build our own
8637 * profile, set everything to default We can only
8638 * support open and no encryption
8639 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008640 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
8641 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] =
8642 eCSR_AUTH_TYPE_OPEN_SYSTEM;
8643 pCommand->u.roamCmd.roamProfile.EncryptionType.
8644 numEntries = 1;
8645 pCommand->u.roamCmd.roamProfile.EncryptionType.
8646 encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8647 pCommand->u.roamCmd.roamProfile.csrPersona =
Anurag Chouhan6d760662016-02-20 16:05:43 +05308648 QDF_STA_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008649 } else {
8650 /* make a copy of the profile */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308651 status = csr_roam_copy_profile(pMac, &pCommand->u.
8652 roamCmd.roamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008653 pProfile);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308654 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008655 pCommand->u.roamCmd.fReleaseProfile = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008656 }
8657
8658 pCommand->command = eSmeCommandRoam;
8659 pCommand->sessionId = (uint8_t) sessionId;
8660 pCommand->u.roamCmd.hBSSList = hBSSList;
8661 pCommand->u.roamCmd.roamId = roamId;
8662 pCommand->u.roamCmd.roamReason = reason;
8663 /* We need to free the BssList when the command is done */
8664 pCommand->u.roamCmd.fReleaseBssList = true;
8665 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008666 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
8667 FL("CSR PERSONA=%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008668 pCommand->u.roamCmd.roamProfile.csrPersona);
8669 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308670 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308671 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008672 }
8673 }
8674
8675 return status;
8676}
8677
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308678QDF_STATUS csr_roam_issue_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008679 struct csr_roam_profile *pProfile,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308680 tCsrRoamModifyProfileFields
8681 *pMmodProfileFields,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308682 enum csr_roam_reason reason, uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008683 bool fImediate)
8684{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308685 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008686 tSmeCmd *pCommand;
8687
8688 pCommand = csr_get_command_buffer(pMac);
8689 if (NULL == pCommand) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308690 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308691 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008692 } else {
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05308693 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008694 if (pProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308695 /* This is likely trying to reassoc to
8696 * different profile
8697 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008698 pCommand->u.roamCmd.fReleaseProfile = false;
8699 /* make a copy of the profile */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308700 status = csr_roam_copy_profile(pMac, &pCommand->u.
8701 roamCmd.roamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008702 pProfile);
8703 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
8704 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308705 status = csr_roam_copy_connected_profile(pMac,
8706 sessionId,
8707 &pCommand->u.roamCmd.
8708 roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008709 /* how to update WPA/WPA2 info in roamProfile?? */
8710 pCommand->u.roamCmd.roamProfile.uapsd_mask =
8711 pMmodProfileFields->uapsd_mask;
8712 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308713 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008714 pCommand->u.roamCmd.fReleaseProfile = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008715 pCommand->command = eSmeCommandRoam;
8716 pCommand->sessionId = (uint8_t) sessionId;
8717 pCommand->u.roamCmd.roamId = roamId;
8718 pCommand->u.roamCmd.roamReason = reason;
8719 /* We need to free the BssList when the command is done */
8720 /* For reassoc there is no BSS list, so the bool set to false */
8721 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
8722 pCommand->u.roamCmd.fReleaseBssList = false;
8723 pCommand->u.roamCmd.fReassoc = true;
8724 csr_roam_remove_duplicate_command(pMac, sessionId, pCommand,
8725 reason);
8726 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308727 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308728 sme_err("fail to send message status = %d", status);
Krunal Soniaa179db2017-10-13 19:28:17 -07008729 csr_roam_completion(pMac, sessionId, NULL, NULL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008730 eCSR_ROAM_RESULT_FAILURE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008731 }
8732 }
8733 return status;
8734}
8735
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308736QDF_STATUS csr_dequeue_roam_command(tpAniSirGlobal pMac,
8737 enum csr_roam_reason reason,
Krunal Sonif3583022017-02-10 17:18:10 -08008738 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008739{
8740 tListElem *pEntry;
8741 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308742
Krunal Sonia8270f52017-02-23 19:51:25 -08008743 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745 if (pEntry) {
8746 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8747 if ((eSmeCommandRoam == pCommand->command) &&
8748 (eCsrPerformPreauth == reason)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008749 sme_debug("DQ-Command = %d, Reason = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008750 pCommand->command,
8751 pCommand->u.roamCmd.roamReason);
Krunal Soni72dba662017-02-15 20:13:17 -08008752 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008753 LL_ACCESS_LOCK)) {
Paul Zhang43626972017-11-21 18:25:58 +08008754 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008755 }
8756 } else if ((eSmeCommandRoam == pCommand->command) &&
8757 (eCsrSmeIssuedFTReassoc == reason)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008758 sme_debug("DQ-Command = %d, Reason = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759 pCommand->command,
8760 pCommand->u.roamCmd.roamReason);
Krunal Soni72dba662017-02-15 20:13:17 -08008761 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008762 LL_ACCESS_LOCK)) {
Krunal Sonidea45952017-02-15 11:58:15 -08008763 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008764 }
8765 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008766 sme_err("Command = %d, Reason = %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008767 pCommand->command,
8768 pCommand->u.roamCmd.roamReason);
8769 }
8770 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008771 sme_err("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008772 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308773 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008774}
8775
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308776#ifdef WLAN_FEATURE_FILS_SK
8777/**
8778 * csr_is_fils_connection() - API to check if FILS connection
8779 * @profile: CSR Roam Profile
8780 *
8781 * Return: true, if fils connection, false otherwise
8782 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008783static bool csr_is_fils_connection(struct csr_roam_profile *profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308784{
8785 if (!profile->fils_con_info)
8786 return false;
8787
8788 return profile->fils_con_info->is_fils_connection;
8789}
8790#else
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008791static bool csr_is_fils_connection(struct csr_roam_profile *pProfile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308792{
8793 return false;
8794}
8795#endif
8796
Abhishek Singhb58164a2017-07-19 18:47:23 +05308797/**
8798 * csr_roam_print_candidate_aps() - print all candidate AP in sorted
8799 * score.
8800 * @results: scan result
8801 *
8802 * Return : void
8803 */
8804static void csr_roam_print_candidate_aps(tScanResultHandle results)
8805{
8806 tListElem *entry;
8807 struct tag_csrscan_result *bss_desc = NULL;
8808 struct scan_result_list *bss_list = NULL;
8809
8810 if (!results)
8811 return;
8812 bss_list = (struct scan_result_list *)results;
8813 entry = csr_ll_peek_head(&bss_list->List, LL_ACCESS_NOLOCK);
8814 while (entry) {
8815 bss_desc = GET_BASE_ADDR(entry,
8816 struct tag_csrscan_result, Link);
8817 sme_debug("BSSID" MAC_ADDRESS_STR "score is %d",
8818 MAC_ADDR_ARRAY(bss_desc->Result.BssDescriptor.bssId),
8819 bss_desc->bss_score);
8820
8821 entry = csr_ll_next(&bss_list->List, entry,
8822 LL_ACCESS_NOLOCK);
8823 }
8824}
8825
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308826QDF_STATUS csr_roam_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008827 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008828 uint32_t *pRoamId)
8829{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308830 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008831 tScanResultHandle hBSSList;
8832 tCsrScanResultFilter *pScanFilter;
8833 uint32_t roamId = 0;
8834 bool fCallCallback = false;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308835 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308836 tSirBssDescription *first_ap_profile;
Tushnim Bhattacharyya3f780532018-08-01 19:11:40 -07008837 uint8_t channel_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008838
8839 if (NULL == pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008840 sme_err("session does not exist for given sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008841 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308842 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008843 }
8844
8845 if (NULL == pProfile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008846 sme_err("No profile specified");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008848 }
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308849
8850 first_ap_profile = qdf_mem_malloc(sizeof(*first_ap_profile));
8851 if (NULL == first_ap_profile) {
8852 sme_err("malloc fails for first_ap_profile");
8853 return QDF_STATUS_E_NOMEM;
8854 }
8855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 /* Initialize the count before proceeding with the Join requests */
8857 pSession->join_bssid_count = 0;
Abhishek Singhd5686472017-09-20 15:18:50 +05308858 pSession->discon_in_progress = false;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308859 pSession->is_fils_connection = csr_is_fils_connection(pProfile);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008860 sme_debug(
8861 "called BSSType = %s (%d) authtype = %d encryType = %d",
Rajeev Kumar43e25b12016-04-15 16:26:36 -07008862 sme_bss_type_to_string(pProfile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008863 pProfile->BSSType, pProfile->AuthType.authType[0],
8864 pProfile->EncryptionType.encryptionType[0]);
8865 csr_roam_cancel_roaming(pMac, sessionId);
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05308866 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008867 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
8868 /* Check whether ssid changes */
8869 if (csr_is_conn_state_connected(pMac, sessionId) &&
Jeff Johnsonb9307a92018-06-03 11:22:32 -07008870 pProfile->SSIDs.numOfSSIDs &&
8871 !csr_is_ssid_in_list(&pSession->connectedProfile.SSID,
8872 &pProfile->SSIDs))
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308873 csr_roam_issue_disassociate_cmd(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Abhishek Singhacfdc922015-12-30 17:31:21 +05308875 /*
8876 * If roamSession.connectState is disconnecting that mean
8877 * disconnect was received with scan for ssid in progress
8878 * and dropped. This state will ensure that connect will
8879 * not be issued from scan for ssid completion. Thus
8880 * if this fresh connect also issue scan for ssid the connect
8881 * command will be dropped assuming disconnect is in progress.
8882 * Thus reset connectState here
8883 */
8884 if (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING ==
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308885 pMac->roam.roamSession[sessionId].connectState)
8886 pMac->roam.roamSession[sessionId].connectState =
8887 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008888#ifdef FEATURE_WLAN_BTAMP_UT_RF
8889 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
8890#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308891 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008892 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308893 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008894 goto end;
8895 }
8896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008897 /* Try to connect to any BSS */
8898 if (NULL == pProfile) {
8899 /* No encryption */
8900 pScanFilter->EncryptionType.numEntries = 1;
8901 pScanFilter->EncryptionType.encryptionType[0] =
8902 eCSR_ENCRYPT_TYPE_NONE;
8903 } else {
8904 /* Here is the profile we need to connect to */
8905 status = csr_roam_prepare_filter_from_profile(pMac,
8906 pProfile, pScanFilter);
8907 }
8908 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
8909 if (pRoamId)
8910 *pRoamId = roamId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308911 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308912 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008913 goto end;
8914 }
8915
8916 /*Save the WPS info */
8917 if (NULL != pProfile) {
8918 pScanFilter->bWPSAssociation =
8919 pProfile->bWPSAssociation;
8920 pScanFilter->bOSENAssociation =
8921 pProfile->bOSENAssociation;
8922 } else {
8923 pScanFilter->bWPSAssociation = 0;
8924 pScanFilter->bOSENAssociation = 0;
8925 }
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008926 if (pProfile && CSR_IS_INFRA_AP(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008927 /* This can be started right away */
8928 status = csr_roam_issue_connect(pMac, sessionId, pProfile, NULL,
8929 eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308930 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308931 sme_err("CSR failed to issue start BSS cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008932 status);
8933 fCallCallback = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308934 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008935 sme_debug("Connect request to proceed for sap mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008936
8937 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308938 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008939 goto end;
8940 }
8941 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308942 sme_debug("csr_scan_get_result Status: %d", status);
Abhishek Singhb58164a2017-07-19 18:47:23 +05308943 csr_roam_print_candidate_aps(hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308944 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008945 /* check if set hw mode needs to be done */
Krunal Soni3091bcc2016-06-23 12:28:21 -07008946 if ((pScanFilter->csrPersona == QDF_STA_MODE) ||
8947 (pScanFilter->csrPersona == QDF_P2P_CLIENT_MODE)) {
Ajit Pal Singh64aff0c2017-06-20 16:35:26 +05308948 bool ok;
8949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008950 csr_get_bssdescr_from_scan_handle(hBSSList,
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308951 first_ap_profile);
Ajit Pal Singh64aff0c2017-06-20 16:35:26 +05308952 status = policy_mgr_is_chan_ok_for_dnbs(pMac->psoc,
8953 first_ap_profile->channelId, &ok);
8954 if (QDF_IS_STATUS_ERROR(status)) {
8955 sme_debug("policy_mgr_is_chan_ok_for_dnbs():error:%d",
8956 status);
8957 csr_scan_result_purge(pMac, hBSSList);
8958 fCallCallback = true;
8959 goto error;
8960 }
8961 if (!ok) {
8962 sme_debug("chan:%d not ok for DNBS",
8963 first_ap_profile->channelId);
8964 csr_scan_result_purge(pMac, hBSSList);
8965 fCallCallback = true;
8966 status = QDF_STATUS_E_INVAL;
8967 goto error;
8968 }
Tushnim Bhattacharyya3f780532018-08-01 19:11:40 -07008969
8970 channel_id = csr_get_channel_for_hw_mode_change
8971 (pMac, hBSSList, sessionId);
8972 if (!channel_id)
8973 channel_id = first_ap_profile->channelId;
8974
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08008975 status = policy_mgr_handle_conc_multiport(pMac->psoc,
Tushnim Bhattacharyya3f780532018-08-01 19:11:40 -07008976 sessionId, channel_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308977 if ((QDF_IS_STATUS_SUCCESS(status)) &&
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308978 (!csr_wait_for_connection_update(pMac, true))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008979 sme_debug("conn update error");
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308980 csr_scan_result_purge(pMac, hBSSList);
8981 fCallCallback = true;
Abhishek Singh471652b2017-04-14 12:28:32 +05308982 status = QDF_STATUS_E_TIMEOUT;
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308983 goto error;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308984 } else if (status == QDF_STATUS_E_FAILURE) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008985 sme_debug("conn update error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008986 csr_scan_result_purge(pMac, hBSSList);
8987 fCallCallback = true;
8988 goto error;
8989 }
8990 }
8991
8992 status = csr_roam_issue_connect(pMac, sessionId, pProfile,
8993 hBSSList, eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308994 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308995 sme_err("CSR failed to issue connect cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008996 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008997 fCallCallback = true;
8998 }
8999 } else if (NULL != pProfile) {
9000 /* Check whether it is for start ibss */
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07009001 if (CSR_IS_START_IBSS(pProfile) ||
9002 CSR_IS_NDI(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009003 status = csr_roam_issue_connect(pMac, sessionId,
9004 pProfile, NULL, eCsrHddIssued,
9005 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309006 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009007 sme_err("Failed with status = 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009008 status);
9009 fCallCallback = true;
9010 }
9011 } else {
9012 /* scan for this SSID */
9013 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
9014 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309015 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309016 sme_err("CSR failed to issue SSID scan cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009017 status);
9018 fCallCallback = true;
9019 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009020 sme_debug("SSID scan requested");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009021 }
9022 }
9023 } else {
9024 fCallCallback = true;
9025 }
9026
9027error:
9028 if (NULL != pProfile)
9029 /*
9030 * we need to free memory for filter
9031 * if profile exists
9032 */
9033 csr_free_scan_filter(pMac, pScanFilter);
9034
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309035 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009036end:
9037 /* tell the caller if we fail to trigger a join request */
9038 if (fCallCallback) {
9039 csr_roam_call_callback(pMac, sessionId, NULL, roamId,
9040 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
9041 }
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05309042 qdf_mem_free(first_ap_profile);
9043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009044 return status;
9045}
9046
9047/**
9048 * csr_roam_reassoc() - process reassoc command
9049 * @mac_ctx: mac global context
9050 * @session_id: session id
9051 * @profile: roam profile
9052 * @mod_fields: AC info being modified in reassoc
9053 * @roam_id: roam id to be populated
9054 *
9055 * Return: status of operation
9056 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309057QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009058csr_roam_reassoc(tpAniSirGlobal mac_ctx, uint32_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009059 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009060 tCsrRoamModifyProfileFields mod_fields,
9061 uint32_t *roam_id)
9062{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309063 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009064 bool fCallCallback = true;
9065 uint32_t roamId = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309066 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009068 if (NULL == profile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009069 sme_err("No profile specified");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309070 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009071 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009072 sme_debug(
9073 "called BSSType = %s (%d) authtype = %d encryType = %d",
Rajeev Kumar43e25b12016-04-15 16:26:36 -07009074 sme_bss_type_to_string(profile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009075 profile->BSSType, profile->AuthType.authType[0],
9076 profile->EncryptionType.encryptionType[0]);
9077 csr_roam_cancel_roaming(mac_ctx, session_id);
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05309078 csr_scan_abort_mac_scan(mac_ctx, session_id, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009079 csr_roam_remove_duplicate_command(mac_ctx, session_id, NULL,
9080 eCsrHddIssuedReassocToSameAP);
9081 if (csr_is_conn_state_connected(mac_ctx, session_id)) {
9082 if (profile) {
9083 if (profile->SSIDs.numOfSSIDs &&
Jeff Johnsonb9307a92018-06-03 11:22:32 -07009084 csr_is_ssid_in_list(&session->connectedProfile.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009085 &profile->SSIDs)) {
9086 fCallCallback = false;
9087 } else {
9088 /*
9089 * Connected SSID did not match with what is
9090 * asked in profile
9091 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009092 sme_debug("SSID mismatch");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009093 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309094 } else if (qdf_mem_cmp(&mod_fields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009095 &session->connectedProfile.modifyProfileFields,
9096 sizeof(tCsrRoamModifyProfileFields))) {
9097 fCallCallback = false;
9098 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009099 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009100 /*
9101 * Either the profile is NULL or none of the
9102 * fields in tCsrRoamModifyProfileFields got
9103 * modified
9104 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009105 "Profile NULL or nothing to modify");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009106 }
9107 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009108 sme_debug("Not connected! No need to reassoc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009109 }
9110 if (!fCallCallback) {
9111 roamId = GET_NEXT_ROAM_ID(&mac_ctx->roam);
9112 if (roam_id)
9113 *roam_id = roamId;
9114 status = csr_roam_issue_reassoc(mac_ctx, session_id, profile,
9115 &mod_fields, eCsrHddIssuedReassocToSameAP,
9116 roamId, false);
9117 } else {
9118 status = csr_roam_call_callback(mac_ctx, session_id, NULL,
9119 roamId, eCSR_ROAM_FAILED,
9120 eCSR_ROAM_RESULT_FAILURE);
9121 }
9122 return status;
9123}
9124
Jeff Johnson29e2ca12016-10-14 12:50:38 -07009125static QDF_STATUS csr_roam_join_last_profile(tpAniSirGlobal pMac,
9126 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009127{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309128 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009129 tScanResultHandle hBSSList = NULL;
9130 tCsrScanResultFilter *pScanFilter = NULL;
9131 uint32_t roamId;
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009132 struct csr_roam_profile *pProfile = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309133 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009134
9135 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009136 sme_err("session %d not found ", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309137 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009138 }
9139
9140 if (pSession->pCurRoamProfile) {
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05309141 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009142 /* We have to make a copy of pCurRoamProfile because it
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309143 * will be free inside csr_roam_issue_connect
9144 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009145 pProfile = qdf_mem_malloc(sizeof(struct csr_roam_profile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009146 if (NULL == pProfile) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309147 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009148 goto end;
9149 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009150 status = csr_roam_copy_profile(pMac, pProfile,
9151 pSession->pCurRoamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309152 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009153 goto end;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309154 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009155 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309156 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009157 goto end;
9158 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009159 status = csr_roam_prepare_filter_from_profile(pMac, pProfile,
9160 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309161 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009162 goto end;
9163 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
9164 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309165 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009166 /* we want to put the last connected BSS to the
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309167 * very beginning, if possible
9168 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009169 csr_move_bss_to_head_from_bssid(pMac,
9170 &pSession->connectedProfile.bssid, hBSSList);
9171 status = csr_roam_issue_connect(pMac, sessionId,
9172 pProfile, hBSSList, eCsrHddIssued,
9173 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309174 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009175 goto end;
9176 }
9177 } else {
9178 /* scan for this SSID only incase AP suppresses SSID */
9179 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
9180 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309181 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009182 goto end;
9183 }
9184 } /* We have a profile */
9185 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009186 sme_warn("cannot find a roaming profile");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009187 goto end;
9188 }
9189end:
9190 if (pScanFilter) {
9191 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309192 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009193 }
9194 if (NULL != pProfile) {
9195 csr_release_profile(pMac, pProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309196 qdf_mem_free(pProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009197 }
9198 return status;
9199}
9200
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309201QDF_STATUS csr_roam_reconnect(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009202{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309203 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009205 if (csr_is_conn_state_connected(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309206 status = csr_roam_issue_disassociate_cmd(pMac, sessionId,
9207 eCSR_DISCONNECT_REASON_UNSPECIFIED);
9208 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009209 status = csr_roam_join_last_profile(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009210 }
9211 return status;
9212}
9213
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309214QDF_STATUS csr_roam_connect_to_last_profile(tpAniSirGlobal pMac,
9215 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009216{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309217 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009219 csr_roam_cancel_roaming(pMac, sessionId);
9220 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309221 if (csr_is_conn_state_disconnected(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009222 status = csr_roam_join_last_profile(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309223
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009224 return status;
9225}
9226
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309227QDF_STATUS csr_roam_process_disassoc_deauth(tpAniSirGlobal pMac,
9228 tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009229 bool fDisassoc, bool fMICFailure)
9230{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309231 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009232 bool fComplete = false;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309233 enum csr_roam_substate NewSubstate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009234 uint32_t sessionId = pCommand->sessionId;
9235
9236 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309237 sme_debug("Stop Wait for key timer and change substate to eCSR_ROAM_SUBSTATE_NONE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009238 csr_roam_stop_wait_for_key_timer(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309239 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
9240 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009241 }
9242 /* change state to 'Roaming'... */
9243 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
9244
9245 if (csr_is_conn_state_ibss(pMac, sessionId)) {
9246 /* If we are in an IBSS, then stop the IBSS... */
9247 status =
9248 csr_roam_issue_stop_bss(pMac, sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309249 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309250 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009251 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
9252 /*
9253 * in Infrastructure, we need to disassociate from the
9254 * Infrastructure network...
9255 */
9256 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
9257 if (eCsrSmeIssuedDisassocForHandoff ==
9258 pCommand->u.roamCmd.roamReason) {
9259 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
9260 } else
9261 if ((eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason)
9262 && (eSIR_MAC_DISASSOC_LEAVING_BSS_REASON ==
9263 pCommand->u.roamCmd.reason)) {
9264 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009265 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
9266 "set to substate eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009267 }
Abhishek Singhe0680852015-12-16 14:28:48 +05309268 if (eCsrSmeIssuedDisassocForHandoff !=
9269 pCommand->u.roamCmd.roamReason) {
9270 /*
9271 * If we are in neighbor preauth done state then
9272 * on receiving disassoc or deauth we dont roam
9273 * instead we just disassoc from current ap and
9274 * then go to disconnected state.
9275 * This happens for ESE and 11r FT connections ONLY.
9276 */
Abhishek Singhe0680852015-12-16 14:28:48 +05309277 if (csr_roam_is11r_assoc(pMac, sessionId) &&
9278 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309279 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05309280 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
9281 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05309282#ifdef FEATURE_WLAN_ESE
9283 if (csr_roam_is_ese_assoc(pMac, sessionId) &&
9284 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309285 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05309286 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
9287 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05309288#endif
Abhishek Singhe0680852015-12-16 14:28:48 +05309289 if (csr_roam_is_fast_roam_enabled(pMac, sessionId) &&
9290 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309291 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05309292 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
9293 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05309294 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309295 if (fDisassoc)
9296 status = csr_roam_issue_disassociate(pMac, sessionId,
9297 NewSubstate,
9298 fMICFailure);
9299 else
9300 status = csr_roam_issue_deauth(pMac, sessionId,
9301 eCSR_ROAM_SUBSTATE_DEAUTH_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309302 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009303 } else {
9304 /* we got a dis-assoc request while not connected to any peer */
9305 /* just complete the command */
9306 fComplete = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309307 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009308 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309309 if (fComplete)
Krunal Sonif3583022017-02-10 17:18:10 -08009310 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009311
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309312 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009313 if (csr_is_conn_state_infra(pMac, sessionId)) {
9314 /* Set the state to disconnect here */
9315 pMac->roam.roamSession[sessionId].connectState =
9316 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9317 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309318 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009319 sme_warn(" failed with status %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009320 return status;
9321}
9322
9323/**
9324 * csr_prepare_disconnect_command() - function to prepare disconnect command
9325 * @mac: pointer to global mac structure
9326 * @session_id: sme session index
9327 * @sme_cmd: pointer to sme command being prepared
9328 *
9329 * Function to prepare internal sme disconnect command
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309330 * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS_E_RESOURCES on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009331 */
9332
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309333QDF_STATUS csr_prepare_disconnect_command(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009334 uint32_t session_id, tSmeCmd **sme_cmd)
9335{
9336 tSmeCmd *command;
9337
9338 command = csr_get_command_buffer(mac);
9339 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009340 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309341 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009342 }
9343
9344 command->command = eSmeCommandRoam;
9345 command->sessionId = (uint8_t)session_id;
9346 command->u.roamCmd.roamReason = eCsrForcedDisassoc;
9347
9348 *sme_cmd = command;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309349 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009350}
9351
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309352QDF_STATUS csr_roam_issue_disassociate_cmd(tpAniSirGlobal pMac,
9353 uint32_t sessionId,
9354 eCsrRoamDisconnectReason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009355{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309356 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009357 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359 do {
9360 pCommand = csr_get_command_buffer(pMac);
9361 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009362 sme_err(" fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309363 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009364 break;
9365 }
9366 /* Change the substate in case it is wait-for-key */
9367 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
9368 csr_roam_stop_wait_for_key_timer(pMac);
9369 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
9370 sessionId);
9371 }
9372 pCommand->command = eSmeCommandRoam;
9373 pCommand->sessionId = (uint8_t) sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009374 sme_debug(
9375 "Disassociate reason: %d, sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009376 reason, sessionId);
9377 switch (reason) {
9378 case eCSR_DISCONNECT_REASON_MIC_ERROR:
9379 pCommand->u.roamCmd.roamReason =
9380 eCsrForcedDisassocMICFailure;
9381 break;
9382 case eCSR_DISCONNECT_REASON_DEAUTH:
9383 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
9384 break;
9385 case eCSR_DISCONNECT_REASON_HANDOFF:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009386 pCommand->u.roamCmd.roamReason =
9387 eCsrSmeIssuedDisassocForHandoff;
9388 break;
9389 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
9390 case eCSR_DISCONNECT_REASON_DISASSOC:
9391 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
9392 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07009393 case eCSR_DISCONNECT_REASON_ROAM_HO_FAIL:
9394 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
9395 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009396 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
9397 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
9398 break;
9399 case eCSR_DISCONNECT_REASON_STA_HAS_LEFT:
9400 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
9401 pCommand->u.roamCmd.reason =
9402 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009403 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
9404 "SME convert to internal reason code eCsrStaHasLeft");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009405 break;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07009406 case eCSR_DISCONNECT_REASON_NDI_DELETE:
9407 pCommand->u.roamCmd.roamReason = eCsrStopBss;
9408 pCommand->u.roamCmd.roamProfile.BSSType =
9409 eCSR_BSS_TYPE_NDI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009410 default:
9411 break;
9412 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07009413 pCommand->u.roamCmd.disconnect_reason = reason;
Abhishek Singhb7b2a3b2015-12-03 16:09:38 +05309414 status = csr_queue_sme_command(pMac, pCommand, true);
Krunal Soniaa179db2017-10-13 19:28:17 -07009415 if (!QDF_IS_STATUS_SUCCESS(status))
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309416 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009417 } while (0);
9418 return status;
9419}
9420
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309421QDF_STATUS csr_roam_issue_stop_bss_cmd(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009422 bool fHighPriority)
9423{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309424 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009425 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309426
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009427 pCommand = csr_get_command_buffer(pMac);
9428 if (NULL != pCommand) {
9429 /* Change the substate in case it is wait-for-key */
9430 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
9431 csr_roam_stop_wait_for_key_timer(pMac);
9432 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
9433 sessionId);
9434 }
9435 pCommand->command = eSmeCommandRoam;
9436 pCommand->sessionId = (uint8_t) sessionId;
9437 pCommand->u.roamCmd.roamReason = eCsrStopBss;
9438 status = csr_queue_sme_command(pMac, pCommand, fHighPriority);
Krunal Soniaa179db2017-10-13 19:28:17 -07009439 if (!QDF_IS_STATUS_SUCCESS(status))
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309440 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009441 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309442 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309443 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009444 }
9445 return status;
9446}
9447
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309448QDF_STATUS csr_roam_disconnect_internal(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009449 eCsrRoamDisconnectReason reason)
9450{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309451 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309452 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009453
9454 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309455 sme_err("session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309456 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009457 }
9458#ifdef FEATURE_WLAN_BTAMP_UT_RF
9459 /* Stop the retry */
9460 pSession->maxRetryCount = 0;
9461 csr_roam_stop_join_retry_timer(pMac, sessionId);
9462#endif
9463 /* Not to call cancel roaming here */
9464 /* Only issue disconnect when necessary */
9465 if (csr_is_conn_state_connected(pMac, sessionId)
9466 || csr_is_bss_type_ibss(pSession->connectedProfile.BSSType)
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07009467 || csr_is_roam_command_waiting_for_session(pMac, sessionId)
9468 || CSR_IS_CONN_NDI(&pSession->connectedProfile)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009469 sme_debug("called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009470 status = csr_roam_issue_disassociate_cmd(pMac, sessionId,
9471 reason);
9472 } else {
kaliu154d7892015-12-30 17:27:58 +05309473 pMac->roam.roamSession[sessionId].connectState =
9474 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING;
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05309475 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309476 status = QDF_STATUS_CMD_NOT_QUEUED;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309477 sme_debug("Disconnect cmd not queued, Roam command is not present return with status: %d",
9478 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009479 }
9480 return status;
9481}
9482
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07009483QDF_STATUS csr_roam_disconnect(tpAniSirGlobal mac_ctx, uint32_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009484 eCsrRoamDisconnectReason reason)
9485{
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07009486 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009487
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07009488 if (!session) {
9489 sme_err("session: %d not found ", session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309490 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009491 }
9492
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07009493 session->discon_in_progress = true;
9494 csr_roam_cancel_roaming(mac_ctx, session_id);
9495 csr_roam_remove_duplicate_command(mac_ctx, session_id, NULL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009496 eCsrForcedDisassoc);
9497
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07009498 return csr_roam_disconnect_internal(mac_ctx, session_id, reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009499}
9500
Jeff Johnson536249f2018-05-12 16:48:38 -07009501QDF_STATUS csr_roam_save_connected_information(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009502 uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009503 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009504 tSirBssDescription *pSirBssDesc,
9505 tDot11fBeaconIEs *pIes)
9506{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309507 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009508 tDot11fBeaconIEs *pIesTemp = pIes;
9509 uint8_t index;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309510 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009511 tCsrRoamConnectedProfile *pConnectProfile = NULL;
9512
9513 pSession = CSR_GET_SESSION(pMac, sessionId);
9514 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309515 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309516 "session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309517 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009518 }
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +05309519
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309520 sme_debug("session id: %d", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009521 pConnectProfile = &pSession->connectedProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009522 if (pConnectProfile->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309523 qdf_mem_free(pConnectProfile->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009524 pConnectProfile->pAddIEAssoc = NULL;
9525 }
Varun Reddy Yeturud5216002016-02-03 17:09:09 -08009526 /*
9527 * In case of LFR2.0, the connected profile is copied into a temporary
9528 * profile and cleared and then is copied back. This is not needed for
9529 * LFR3.0, since the profile is not cleared.
9530 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009531 if (!pSession->roam_synch_in_progress) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309532 qdf_mem_set(&pSession->connectedProfile,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009533 sizeof(tCsrRoamConnectedProfile), 0);
9534 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
9535 pConnectProfile->AuthInfo = pProfile->AuthType;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009536 pConnectProfile->EncryptionType =
9537 pProfile->negotiatedUCEncryptionType;
9538 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
9539 pConnectProfile->mcEncryptionType =
9540 pProfile->negotiatedMCEncryptionType;
9541 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
9542 pConnectProfile->BSSType = pProfile->BSSType;
9543 pConnectProfile->modifyProfileFields.uapsd_mask =
9544 pProfile->uapsd_mask;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309545 qdf_mem_copy(&pConnectProfile->Keys, &pProfile->Keys,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009546 sizeof(tCsrKeys));
9547 if (pProfile->nAddIEAssocLength) {
9548 pConnectProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309549 qdf_mem_malloc(pProfile->nAddIEAssocLength);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009550 if (NULL == pConnectProfile->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309551 status = QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009552 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309553 status = QDF_STATUS_SUCCESS;
9554 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309555 sme_err("Failed to allocate memory for IE");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309556 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009557 }
9558 pConnectProfile->nAddIEAssocLength =
9559 pProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309560 qdf_mem_copy(pConnectProfile->pAddIEAssoc,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009561 pProfile->pAddIEAssoc,
9562 pProfile->nAddIEAssocLength);
9563 }
9564#ifdef WLAN_FEATURE_11W
9565 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
9566 pConnectProfile->MFPRequired = pProfile->MFPRequired;
9567 pConnectProfile->MFPCapable = pProfile->MFPCapable;
9568#endif
9569 }
9570 /* Save bssid */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009571 pConnectProfile->operationChannel = pSirBssDesc->channelId;
9572 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309573 if (!pConnectProfile->beaconInterval)
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009574 sme_err("ERROR: Beacon interval is ZERO");
Jeff Johnson20ac1c42018-06-03 12:09:02 -07009575 csr_get_bss_id_bss_desc(pSirBssDesc, &pConnectProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576 if (pSirBssDesc->mdiePresent) {
9577 pConnectProfile->MDID.mdiePresent = 1;
9578 pConnectProfile->MDID.mobilityDomain =
9579 (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
9580 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309581 if (NULL == pIesTemp)
9582 status = csr_get_parsed_bss_description_ies(pMac, pSirBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009583 &pIesTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009584#ifdef FEATURE_WLAN_ESE
9585 if ((csr_is_profile_ese(pProfile) ||
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309586 (QDF_IS_STATUS_SUCCESS(status) && (pIesTemp->ESEVersion.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009587 && (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)))
9588 && (pMac->roam.configParam.isEseIniFeatureEnabled)) {
9589 pConnectProfile->isESEAssoc = 1;
9590 }
9591#endif
9592 /* save ssid */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309593 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009594 if (pIesTemp->SSID.present) {
9595 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309596 qdf_mem_copy(pConnectProfile->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009597 pIesTemp->SSID.ssid,
9598 pIesTemp->SSID.num_ssid);
9599 }
9600 /* Save the bss desc */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309601 status = csr_roam_save_connected_bss_desc(pMac, sessionId,
9602 pSirBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009603
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309604 if (CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
9605 /* Some HT AP's dont send WMM IE so in that case we
9606 * assume all HT Ap's are Qos Enabled AP's
9607 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009608 pConnectProfile->qap = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309609 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 pConnectProfile->qap = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009611
9612 if (pIesTemp->ExtCap.present) {
9613 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
9614 pIesTemp->ExtCap.bytes;
9615 pConnectProfile->proxyARPService = p_ext_cap->
9616 proxy_arp_service;
9617 }
9618
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309619 if (NULL == pIes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009620 /* Free memory if it allocated locally */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309621 qdf_mem_free(pIesTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009622 }
9623 /* Save Qos connection */
9624 pConnectProfile->qosConnection =
9625 pMac->roam.roamSession[sessionId].fWMMConnection;
9626
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309627 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009628 csr_free_connect_bss_desc(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009630 for (index = 0; index < pProfile->SSIDs.numOfSSIDs; index++) {
9631 if ((pProfile->SSIDs.SSIDList[index].SSID.length ==
9632 pConnectProfile->SSID.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309633 && (!qdf_mem_cmp(pProfile->SSIDs.SSIDList[index].SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009634 ssId, pConnectProfile->SSID.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309635 pConnectProfile->SSID.length))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309636 pConnectProfile->handoffPermitted = pProfile->SSIDs.
9637 SSIDList[index].handoffPermitted;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009638 break;
9639 }
9640 pConnectProfile->handoffPermitted = false;
9641 }
9642
9643 return status;
9644}
9645
9646
Abhishek Singhb1d73ab2015-12-03 16:14:00 +05309647bool is_disconnect_pending(tpAniSirGlobal pmac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009648 uint8_t sessionid)
9649{
9650 tListElem *entry = NULL;
9651 tListElem *next_entry = NULL;
9652 tSmeCmd *command = NULL;
9653 bool disconnect_cmd_exist = false;
9654
Krunal Soni20126cb2017-02-15 16:26:57 -08009655 csr_nonscan_pending_ll_lock(pmac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009656 entry = csr_nonscan_pending_ll_peek_head(pmac, LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009657 while (entry) {
Krunal Soni72dba662017-02-15 20:13:17 -08009658 next_entry = csr_nonscan_pending_ll_next(pmac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009659 entry, LL_ACCESS_NOLOCK);
9660
9661 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
9662 if (command && CSR_IS_DISCONNECT_COMMAND(command) &&
9663 command->sessionId == sessionid){
9664 disconnect_cmd_exist = true;
9665 break;
9666 }
9667 entry = next_entry;
9668 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009669 csr_nonscan_pending_ll_unlock(pmac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009670 return disconnect_cmd_exist;
9671}
9672
9673static void csr_roam_join_rsp_processor(tpAniSirGlobal pMac,
9674 tSirSmeJoinRsp *pSmeJoinRsp)
9675{
9676 tListElem *pEntry = NULL;
9677 tSmeCmd *pCommand = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309678 struct csr_roam_session *session_ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009679
9680 if (pSmeJoinRsp) {
9681 session_ptr = CSR_GET_SESSION(pMac, pSmeJoinRsp->sessionId);
9682 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309683 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009684 FL("Sme Join Response is NULL"));
9685 return;
9686 }
9687 if (!session_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309688 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009689 ("session %d not found"), pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009690 return;
9691 }
9692 /* The head of the active list is the request we sent */
Krunal Sonia8270f52017-02-23 19:51:25 -08009693 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309694 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009695 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309696
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05309697 sme_debug("is_fils_connection %d", pSmeJoinRsp->is_fils_connection);
9698 /* Copy Sequence Number last used for FILS assoc failure case */
9699 if (session_ptr->is_fils_connection)
9700 session_ptr->fils_seq_num = pSmeJoinRsp->fils_seq_num;
9701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009702 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
9703 if (pCommand
9704 && eCsrSmeIssuedAssocToSimilarAP ==
9705 pCommand->u.roamCmd.roamReason) {
9706#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9707 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309708 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009709#endif
9710 }
Archana Ramachandran20d2e232016-02-11 16:58:40 -08009711
9712 session_ptr->supported_nss_1x1 =
9713 pSmeJoinRsp->supported_nss_1x1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309714 sme_debug("SME session supported nss: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08009715 session_ptr->supported_nss_1x1);
9716
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309717 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009718 * The join bssid count can be reset as soon as
9719 * we are done with the join requests and returning
9720 * the response to upper layers
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309721 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009722 session_ptr->join_bssid_count = 0;
Krunal Sonif3583022017-02-10 17:18:10 -08009723 csr_roam_complete(pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp,
9724 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009725 } else {
9726 uint32_t roamId = 0;
9727 bool is_dis_pending;
9728
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309729 /* The head of the active list is the request we sent
9730 * Try to get back the same profile and roam again
9731 */
9732 if (pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009733 roamId = pCommand->u.roamCmd.roamId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009734 session_ptr->joinFailStatusCode.statusCode =
9735 pSmeJoinRsp->statusCode;
9736 session_ptr->joinFailStatusCode.reasonCode =
9737 pSmeJoinRsp->protStatusCode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309738 sme_warn("SmeJoinReq failed with statusCode= 0x%08X [%d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009739 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309740 /* If Join fails while Handoff is in progress, indicate
9741 * disassociated event to supplicant to reconnect
9742 */
9743 if (csr_roam_is_handoff_in_progress(pMac,
9744 pSmeJoinRsp->sessionId)) {
9745 csr_roam_call_callback(pMac, pSmeJoinRsp->sessionId,
9746 NULL, roamId,
9747 eCSR_ROAM_DISASSOCIATED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009748 eCSR_ROAM_RESULT_FORCED);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309749 /* Should indicate neighbor roam algorithm about the
9750 * connect failure here
9751 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009752 csr_neighbor_roam_indicate_connect(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309753 pSmeJoinRsp->sessionId,
9754 QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009755 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009756 /*
9757 * if userspace has issued disconnection,
9758 * driver should not continue connecting
9759 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309760 is_dis_pending = is_disconnect_pending(pMac,
9761 session_ptr->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009762 if (pCommand && (session_ptr->join_bssid_count <
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309763 CSR_MAX_BSSID_COUNT) && !is_dis_pending)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07009764 csr_roam(pMac, pCommand);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309765 else {
9766 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009767 * When the upper layers issue a connect command, there
9768 * is a roam command with reason eCsrHddIssued that
9769 * gets enqueued and an associated timer for the SME
9770 * command timeout is started which is currently 120
9771 * seconds. This command would be dequeued only upon
Jeff Johnson3370f3a2018-05-11 09:54:12 -07009772 * successful connections. In case of join failures, if
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009773 * there are too many BSS in the cache, and if we fail
9774 * Join requests with all of them, there is a chance of
9775 * timing out the above timer.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309776 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009777 if (session_ptr->join_bssid_count >=
9778 CSR_MAX_BSSID_COUNT)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309779 QDF_TRACE(QDF_MODULE_ID_SME,
9780 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009781 "Excessive Join Req Failures");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009782
9783 if (is_dis_pending)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309784 QDF_TRACE(QDF_MODULE_ID_SME,
9785 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009786 "disconnect is pending, complete roam");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009787
Abhishek Singh6e4621c2017-03-31 13:13:10 +05309788 if (session_ptr->bRefAssocStartCnt)
9789 session_ptr->bRefAssocStartCnt--;
9790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009791 session_ptr->join_bssid_count = 0;
Abhishek Singh6e4621c2017-03-31 13:13:10 +05309792
9793 csr_roam_call_callback(pMac, session_ptr->sessionId,
9794 NULL, roamId,
9795 eCSR_ROAM_ASSOCIATION_COMPLETION,
9796 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
9797
Krunal Sonif3583022017-02-10 17:18:10 -08009798 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
9799 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009800 }
9801 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
9802}
9803
Jeff Johnson29e2ca12016-10-14 12:50:38 -07009804static QDF_STATUS csr_roam_issue_join(tpAniSirGlobal pMac, uint32_t sessionId,
9805 tSirBssDescription *pSirBssDesc,
9806 tDot11fBeaconIEs *pIes,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009807 struct csr_roam_profile *pProfile,
Jeff Johnson29e2ca12016-10-14 12:50:38 -07009808 uint32_t roamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009809{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309810 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309811
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009812 sme_debug("Attempting to Join Bssid= " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009813 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
9814
9815 /* Set the roaming substate to 'join attempt'... */
9816 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
9817 /* attempt to Join this BSS... */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309818 status = csr_send_join_req_msg(pMac, sessionId, pSirBssDesc, pProfile,
9819 pIes, eWNI_SME_JOIN_REQ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009820 return status;
9821}
9822
Krunal Sonif3583022017-02-10 17:18:10 -08009823static void
9824csr_roam_reissue_roam_command(tpAniSirGlobal pMac, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009825{
9826 tListElem *pEntry;
9827 tSmeCmd *pCommand;
Jeff Johnson172237b2017-11-07 15:32:59 -08009828 struct csr_roam_info roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009829 uint32_t sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309830 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009831
Krunal Sonia8270f52017-02-23 19:51:25 -08009832 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009833 if (NULL == pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309834 sme_err("Disassoc rsp can't continue, no active CMD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009835 return;
9836 }
9837 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9838 if (eSmeCommandRoam != pCommand->command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009839 sme_err("Active cmd, is not a roaming CMD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009840 return;
9841 }
9842 sessionId = pCommand->sessionId;
9843 pSession = CSR_GET_SESSION(pMac, sessionId);
9844
9845 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009846 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009847 return;
9848 }
9849
9850 if (!pCommand->u.roamCmd.fStopWds) {
9851 if (pSession->bRefAssocStartCnt > 0) {
9852 /*
9853 * bRefAssocStartCnt was incremented in
9854 * csr_roam_join_next_bss when the roam command issued
9855 * previously. As part of reissuing the roam command
9856 * again csr_roam_join_next_bss is going increment
9857 * RefAssocStartCnt. So make sure to decrement the
9858 * bRefAssocStartCnt
9859 */
9860 pSession->bRefAssocStartCnt--;
9861 }
9862 if (eCsrStopRoaming == csr_roam_join_next_bss(pMac, pCommand,
9863 true)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009864 sme_warn("Failed to reissue join command");
Krunal Sonif3583022017-02-10 17:18:10 -08009865 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
9866 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009867 }
9868 return;
9869 }
Jeff Johnson172237b2017-11-07 15:32:59 -08009870 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009871 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
9872 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
9873 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07009874 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
9875 csr_roam_call_callback(pMac, sessionId, &roamInfo,
9876 pCommand->u.roamCmd.roamId,
9877 eCSR_ROAM_INFRA_IND,
9878 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009879
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309880 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_stop_bss(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009881 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009882 sme_err("Failed to reissue stop_bss command for WDS");
Krunal Sonif3583022017-02-10 17:18:10 -08009883 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009884 }
9885}
9886
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309887bool csr_is_roam_command_waiting_for_session(tpAniSirGlobal pMac,
9888 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009889{
9890 bool fRet = false;
9891 tListElem *pEntry;
9892 tSmeCmd *pCommand = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009894 /* alwasy lock active list before locking pending list */
Krunal Soni20126cb2017-02-15 16:26:57 -08009895 csr_nonscan_active_ll_lock(pMac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009896 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009897 if (pEntry) {
9898 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9899 if ((eSmeCommandRoam == pCommand->command)
9900 && (sessionId == pCommand->sessionId)) {
9901 fRet = true;
9902 }
9903 }
9904 if (false == fRet) {
Krunal Soni20126cb2017-02-15 16:26:57 -08009905 csr_nonscan_pending_ll_lock(pMac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009906 pEntry = csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009907 LL_ACCESS_NOLOCK);
9908 while (pEntry) {
9909 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9910 if ((eSmeCommandRoam == pCommand->command)
9911 && (sessionId == pCommand->sessionId)) {
9912 fRet = true;
9913 break;
9914 }
Krunal Soni72dba662017-02-15 20:13:17 -08009915 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
9916 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009917 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009918 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009919 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009920 csr_nonscan_active_ll_unlock(pMac);
9921
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009922 return fRet;
9923}
9924
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009925static void
9926csr_roaming_state_config_cnf_processor(tpAniSirGlobal mac_ctx,
Krunal Sonia8270f52017-02-23 19:51:25 -08009927 tSmeCmd *cmd, uint32_t result, uint8_t sme_session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009928{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05309929 struct tag_csrscan_result *scan_result = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009930 tSirBssDescription *bss_desc = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009931 uint32_t session_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309932 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009933 tDot11fBeaconIEs *local_ies = NULL;
Jianmin Zhua0d8e002018-07-26 19:40:25 +08009934 bool is_ies_malloced = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309935 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009936
Krunal Sonia8270f52017-02-23 19:51:25 -08009937 if (NULL == cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009938 sme_err("given sme cmd is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009939 return;
9940 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009941 session_id = cmd->sessionId;
9942 session = CSR_GET_SESSION(mac_ctx, session_id);
9943
9944 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009945 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009946 return;
9947 }
9948
9949 if (CSR_IS_ROAMING(session) && session->fCancelRoaming) {
9950 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009951 sme_warn("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08009952 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL,
9953 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009954 return;
9955 }
9956
Jeff Johnsonc09caa42018-06-07 22:58:55 -07009957 if (!QDF_IS_STATUS_SUCCESS(result)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009958 /*
9959 * In the event the configuration failed, for infra let the roam
9960 * processor attempt to join something else...
9961 */
9962 if (cmd->u.roamCmd.pRoamBssEntry
9963 && CSR_IS_INFRASTRUCTURE(&cmd->u.roamCmd.roamProfile)) {
9964 csr_roam(mac_ctx, cmd);
9965 } else {
9966 /* We need to complete the command */
9967 if (csr_is_bss_type_ibss
9968 (cmd->u.roamCmd.roamProfile.BSSType)) {
9969 csr_roam_complete(mac_ctx, eCsrStartBssFailure,
Krunal Sonif3583022017-02-10 17:18:10 -08009970 NULL, sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009971 } else {
9972 csr_roam_complete(mac_ctx, eCsrNothingToJoin,
Krunal Sonif3583022017-02-10 17:18:10 -08009973 NULL, sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009974 }
9975 }
9976 return;
9977 }
9978
9979 /* we have active entry */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009980 sme_debug("Cfg sequence complete");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009981 /*
9982 * Successfully set the configuration parameters for the new Bss.
9983 * Attempt to join the roaming Bss
9984 */
9985 if (cmd->u.roamCmd.pRoamBssEntry) {
9986 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05309987 struct tag_csrscan_result,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009988 Link);
9989 bss_desc = &scan_result->Result.BssDescriptor;
9990 }
9991 if (csr_is_bss_type_ibss(cmd->u.roamCmd.roamProfile.BSSType)
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07009992 || CSR_IS_INFRA_AP(&cmd->u.roamCmd.roamProfile)
9993 || CSR_IS_NDI(&cmd->u.roamCmd.roamProfile)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309994 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_start_bss(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009995 session_id, &session->bssParams,
9996 &cmd->u.roamCmd.roamProfile,
9997 bss_desc,
9998 cmd->u.roamCmd.roamId))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009999 sme_err("CSR start BSS failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010000 /* We need to complete the command */
Krunal Sonif3583022017-02-10 17:18:10 -080010001 csr_roam_complete(mac_ctx, eCsrStartBssFailure, NULL,
10002 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010003 }
10004 return;
10005 }
10006
10007 if (!cmd->u.roamCmd.pRoamBssEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010008 sme_err("pRoamBssEntry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010009 /* We need to complete the command */
Krunal Sonif3583022017-02-10 17:18:10 -080010010 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL,
10011 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010012 return;
10013 }
10014
10015 if (NULL == scan_result) {
10016 /* If we are roaming TO an Infrastructure BSS... */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010017 QDF_ASSERT(scan_result != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010018 return;
10019 }
10020
10021 if (!csr_is_infra_bss_desc(bss_desc)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010022 sme_warn("found BSSType mismatching the one in BSS descp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010023 return;
10024 }
10025
10026 local_ies = (tDot11fBeaconIEs *) scan_result->Result.pvIes;
10027 if (!local_ies) {
10028 status = csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
10029 &local_ies);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010030 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010031 return;
Jianmin Zhua0d8e002018-07-26 19:40:25 +080010032 is_ies_malloced = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010033 }
10034
10035 if (csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
10036 if (csr_is_ssid_equal(mac_ctx, session->pConnectBssDesc,
10037 bss_desc, local_ies)) {
10038 cmd->u.roamCmd.fReassoc = true;
10039 csr_roam_issue_reassociate(mac_ctx, session_id,
10040 bss_desc, local_ies,
10041 &cmd->u.roamCmd.roamProfile);
10042 } else {
10043 /*
10044 * otherwise, we have to issue a new Join request to LIM
10045 * because we disassociated from the previously
10046 * associated AP.
10047 */
10048 status = csr_roam_issue_join(mac_ctx, session_id,
10049 bss_desc, local_ies,
10050 &cmd->u.roamCmd.roamProfile,
10051 cmd->u.roamCmd.roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010052 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010053 /* try something else */
10054 csr_roam(mac_ctx, cmd);
10055 }
10056 }
10057 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010058 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010059 /*
10060 * We need to come with other way to figure out that this is
10061 * because of HO in BMP The below API will be only available for
10062 * Android as it uses a different HO algorithm. Reassoc request
10063 * will be used only for ESE and 11r handoff whereas other
10064 * legacy roaming should use join request
10065 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010066 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
10067 && csr_roam_is11r_assoc(mac_ctx, session_id)) {
10068 status = csr_roam_issue_reassociate(mac_ctx,
10069 session_id, bss_desc,
Will Huang03b54ee2017-06-21 10:57:05 +080010070 local_ies,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010071 &cmd->u.roamCmd.roamProfile);
10072 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010073#ifdef FEATURE_WLAN_ESE
10074 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
10075 && csr_roam_is_ese_assoc(mac_ctx, session_id)) {
10076 /* Now serialize the reassoc command. */
10077 status = csr_roam_issue_reassociate_cmd(mac_ctx,
10078 session_id);
10079 } else
10080#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010081 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
10082 && csr_roam_is_fast_roam_enabled(mac_ctx, session_id)) {
10083 /* Now serialize the reassoc command. */
10084 status = csr_roam_issue_reassociate_cmd(mac_ctx,
10085 session_id);
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080010086 } else {
10087 /*
10088 * else we are not connected and attempting to Join.
10089 * Issue the Join request.
10090 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010091 status = csr_roam_issue_join(mac_ctx, session_id,
10092 bss_desc,
Will Huang03b54ee2017-06-21 10:57:05 +080010093 local_ies,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010094 &cmd->u.roamCmd.roamProfile,
10095 cmd->u.roamCmd.roamId);
10096 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010097 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010098 /* try something else */
10099 csr_roam(mac_ctx, cmd);
10100 }
10101 }
Jianmin Zhua0d8e002018-07-26 19:40:25 +080010102 if (is_ies_malloced) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010103 /* Locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010104 qdf_mem_free(local_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010105 }
10106}
10107
10108static void csr_roam_roaming_state_reassoc_rsp_processor(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010109 tpSirSmeJoinRsp pSmeJoinRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010110{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053010111 enum csr_roamcomplete_result result;
gaurank kathpaliab4d44722018-07-04 11:32:47 +053010112 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Jeff Johnson172237b2017-11-07 15:32:59 -080010113 struct csr_roam_info roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010114 uint32_t roamId = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010115 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010116
gaurank kathpaliab4d44722018-07-04 11:32:47 +053010117 if (pSmeJoinRsp->sessionId >= CSR_ROAM_SESSION_MAX) {
10118 sme_err("Invalid session ID received %d",
10119 pSmeJoinRsp->sessionId);
10120 return;
10121 }
10122
10123 pNeighborRoamInfo =
10124 &pMac->roam.neighborRoamInfo[pSmeJoinRsp->sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010125 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010126 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010127 "CSR SmeReassocReq Successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010128 result = eCsrReassocSuccess;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -070010129 csr_session = CSR_GET_SESSION(pMac, pSmeJoinRsp->sessionId);
10130 if (NULL != csr_session) {
10131 csr_session->supported_nss_1x1 =
10132 pSmeJoinRsp->supported_nss_1x1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010133 sme_debug("SME session supported nss: %d",
Archana Ramachandran5482d6a2016-03-29 17:09:22 -070010134 csr_session->supported_nss_1x1);
10135 }
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080010136 /*
10137 * Since the neighbor roam algorithm uses reassoc req for
10138 * handoff instead of join, we need the response contents while
10139 * processing the result in csr_roam_process_results()
10140 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010141 if (csr_roam_is_handoff_in_progress(pMac,
10142 pSmeJoinRsp->sessionId)) {
10143 /* Need to dig more on indicating events to
10144 * SME QoS module
10145 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010146 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010147 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
Krunal Sonif3583022017-02-10 17:18:10 -080010148 csr_roam_complete(pMac, result, pSmeJoinRsp,
10149 pSmeJoinRsp->sessionId);
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080010150 } else {
Krunal Sonif3583022017-02-10 17:18:10 -080010151 csr_roam_complete(pMac, result, NULL,
10152 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010153 }
10154 }
10155 /* Should we handle this similar to handling the join failure? Is it ok
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010156 * to call csr_roam_complete() with state as CsrJoinFailure
10157 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010158 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010159 sme_warn(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010160 "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]",
10161 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
10162 result = eCsrReassocFailure;
Abhishek Singh5ea86532016-04-27 14:10:53 +053010163 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
10164 WLAN_LOG_INDICATOR_HOST_DRIVER,
10165 WLAN_LOG_REASON_ROAM_FAIL,
10166 true, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010167 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE ==
10168 pSmeJoinRsp->statusCode)
10169 || (eSIR_SME_FT_REASSOC_FAILURE ==
10170 pSmeJoinRsp->statusCode)
10171 || (eSIR_SME_INVALID_PARAMETERS ==
10172 pSmeJoinRsp->statusCode)) {
10173 /* Inform HDD to turn off FT flag in HDD */
10174 if (pNeighborRoamInfo) {
Jeff Johnson172237b2017-11-07 15:32:59 -080010175 qdf_mem_zero(&roamInfo, sizeof(roamInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010176 csr_roam_call_callback(pMac,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070010177 pSmeJoinRsp->sessionId,
10178 &roamInfo, roamId,
10179 eCSR_ROAM_FT_REASSOC_FAILED,
10180 eCSR_ROAM_RESULT_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010181 /*
10182 * Since the above callback sends a disconnect
10183 * to HDD, we should clean-up our state
10184 * machine as well to be in sync with the upper
10185 * layers. There is no need to send a disassoc
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010186 * since: 1) we will never reassoc to the
10187 * current AP in LFR, and 2) there is no need
10188 * to issue a disassoc to the AP with which we
10189 * were trying to reassoc.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010190 */
Krunal Sonif3583022017-02-10 17:18:10 -080010191 csr_roam_complete(pMac, eCsrJoinFailure, NULL,
10192 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010193 return;
10194 }
10195 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010196 /* In the event that the Reassociation fails, then we need to
10197 * Disassociate the current association and keep roaming. Note
10198 * that we will attempt to Join the AP instead of a Reassoc
10199 * since we may have attempted a 'Reassoc to self', which AP's
10200 * that don't support Reassoc will force a Disassoc. The
10201 * isassoc rsp message will remove the command from active list
10202 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010203 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010204 (csr_roam_issue_disassociate
10205 (pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010206 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE,
10207 false))) {
Krunal Sonif3583022017-02-10 17:18:10 -080010208 csr_roam_complete(pMac, eCsrJoinFailure, NULL,
10209 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010210 }
10211 }
10212}
10213
10214static void csr_roam_roaming_state_stop_bss_rsp_processor(tpAniSirGlobal pMac,
10215 tSirSmeRsp *pSmeRsp)
10216{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053010217 enum csr_roamcomplete_result result_code = eCsrNothingToJoin;
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010218 struct csr_roam_profile *profile;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070010219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010220#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10221 {
10222 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010223
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010224 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
10225 LOG_WLAN_IBSS_C);
10226 if (pIbssLog) {
10227 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010228 if (eSIR_SME_SUCCESS != pSmeRsp->statusCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010229 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
10231 }
10232 }
10233#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10234 pMac->roam.roamSession[pSmeRsp->sessionId].connectState =
10235 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10236 if (CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(pMac, pSmeRsp->sessionId)) {
Naveen Rawatefd71c32016-10-25 17:05:47 -070010237 profile =
10238 pMac->roam.roamSession[pSmeRsp->sessionId].pCurRoamProfile;
10239 if (profile && CSR_IS_CONN_NDI(profile)) {
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070010240 result_code = eCsrStopBssSuccess;
10241 if (pSmeRsp->statusCode != eSIR_SME_SUCCESS)
10242 result_code = eCsrStopBssFailure;
10243 }
Krunal Sonif3583022017-02-10 17:18:10 -080010244 csr_roam_complete(pMac, result_code, NULL, pSmeRsp->sessionId);
Naveen Rawatefd71c32016-10-25 17:05:47 -070010245 } else if (CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE(pMac,
10246 pSmeRsp->sessionId)) {
Krunal Sonif3583022017-02-10 17:18:10 -080010247 csr_roam_reissue_roam_command(pMac, pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010248 }
10249}
10250
10251/**
10252 * csr_dequeue_command() - removes a command from active cmd list
10253 * @pMac: mac global context
10254 *
10255 * Return: void
10256 */
10257static void
10258csr_dequeue_command(tpAniSirGlobal mac_ctx)
10259{
10260 bool fRemoveCmd;
10261 tSmeCmd *cmd = NULL;
Krunal Sonia8270f52017-02-23 19:51:25 -080010262 tListElem *entry = csr_nonscan_active_ll_peek_head(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010263 LL_ACCESS_LOCK);
10264 if (!entry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010265 sme_err("NO commands are active");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010266 return;
10267 }
10268
10269 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
10270 /*
10271 * If the head of the queue is Active and it is a given cmd type, remove
10272 * and put this on the Free queue.
10273 */
10274 if (eSmeCommandRoam != cmd->command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010275 sme_err("Roam command not active");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010276 return;
10277 }
10278 /*
10279 * we need to process the result first before removing it from active
10280 * list because state changes still happening insides
10281 * roamQProcessRoamResults so no other roam command should be issued.
10282 */
Krunal Soni72dba662017-02-15 20:13:17 -080010283 fRemoveCmd = csr_nonscan_active_ll_remove_entry(mac_ctx, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010284 LL_ACCESS_LOCK);
10285 if (cmd->u.roamCmd.fReleaseProfile) {
10286 csr_release_profile(mac_ctx, &cmd->u.roamCmd.roamProfile);
10287 cmd->u.roamCmd.fReleaseProfile = false;
10288 }
10289 if (fRemoveCmd)
Krunal Sonidea45952017-02-15 11:58:15 -080010290 csr_release_command(mac_ctx, cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010291 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010292 sme_err("fail to remove cmd reason %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010293 cmd->u.roamCmd.roamReason);
10294}
10295
10296/**
10297 * csr_post_roam_failure() - post roam failure back to csr and issues a disassoc
10298 * @pMac: mac global context
10299 * @session_id: session id
10300 * @roam_info: roam info struct
10301 * @scan_filter: scan filter to free
10302 * @cur_roam_profile: current csr roam profile
10303 *
10304 * Return: void
10305 */
10306static void
10307csr_post_roam_failure(tpAniSirGlobal mac_ctx,
10308 uint32_t session_id,
Jeff Johnson172237b2017-11-07 15:32:59 -080010309 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010310 tCsrScanResultFilter *scan_filter,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010311 struct csr_roam_profile *cur_roam_profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010312{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010313 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010314
10315 if (scan_filter) {
10316 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010317 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010318 }
10319 if (cur_roam_profile)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010320 qdf_mem_free(cur_roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010321
10322#ifdef WLAN_FEATURE_ROAM_OFFLOAD
10323 csr_roam_synch_clean_up(mac_ctx, session_id);
10324#endif
10325 /* Inform the upper layers that the reassoc failed */
Jeff Johnson172237b2017-11-07 15:32:59 -080010326 qdf_mem_zero(roam_info, sizeof(struct csr_roam_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010327 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070010328 eCSR_ROAM_FT_REASSOC_FAILED,
10329 eCSR_ROAM_RESULT_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010330 /*
10331 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT
10332 * session. Upon success, we would re-enter this routine after receiving
10333 * the disassoc response and will fall into the reassoc fail sub-state.
10334 * And, eventually call csr_roam_complete which would remove the roam
10335 * command from SME active queue.
10336 */
10337 status = csr_roam_issue_disassociate(mac_ctx, session_id,
10338 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010339 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010340 sme_err(
10341 "csr_roam_issue_disassociate failed, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010342 status);
Krunal Sonif3583022017-02-10 17:18:10 -080010343 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010344 }
10345}
10346
10347/**
10348 * csr_check_profile_in_scan_cache() - finds if roam profile is present in scan
10349 * cache or not
10350 * @pMac: mac global context
10351 * @scan_filter: out param, scan filter
10352 * @neighbor_roam_info: roam info struct
10353 * @hBSSList: scan result
10354 *
10355 * Return: true if found else false.
10356 */
10357static bool
10358csr_check_profile_in_scan_cache(tpAniSirGlobal mac_ctx,
10359 tCsrScanResultFilter **scan_filter,
10360 tpCsrNeighborRoamControlInfo neighbor_roam_info,
10361 tScanResultHandle *hBSSList)
10362{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010363 QDF_STATUS status;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010364 *scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010365 if (NULL == *scan_filter) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010366 sme_err("alloc for ScanFilter failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010367 return false;
10368 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010369 (*scan_filter)->scan_filter_for_roam = 1;
10370 status = csr_roam_prepare_filter_from_profile(mac_ctx,
10371 &neighbor_roam_info->csrNeighborRoamProfile,
10372 *scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010373 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010374 sme_err(
10375 "failed to prepare scan filter, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010376 status);
10377 return false;
10378 }
10379 status = csr_scan_get_result(mac_ctx, *scan_filter, hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010380 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010381 sme_err(
10382 "csr_scan_get_result failed, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010383 status);
10384 return false;
10385 }
10386 return true;
10387}
10388
Jeff Johnson29e2ca12016-10-14 12:50:38 -070010389static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010390void csr_roam_roaming_state_disassoc_rsp_processor(tpAniSirGlobal pMac,
10391 tSirSmeDisassocRsp *pSmeRsp)
10392{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010393 tScanResultHandle hBSSList;
Jeff Johnson172237b2017-11-07 15:32:59 -080010394 struct csr_roam_info *roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010395 tCsrScanResultFilter *pScanFilter = NULL;
10396 uint32_t roamId = 0;
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010397 struct csr_roam_profile *pCurRoamProfile = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010398 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010399 uint32_t sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010400 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010401 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
10402 tSirSmeDisassocRsp SmeDisassocRsp;
10403
10404 csr_ser_des_unpack_diassoc_rsp((uint8_t *) pSmeRsp, &SmeDisassocRsp);
10405 sessionId = SmeDisassocRsp.sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010406 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, "sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010407 sessionId);
10408
10409 if (csr_is_conn_state_infra(pMac, sessionId)) {
10410 pMac->roam.roamSession[sessionId].connectState =
10411 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10412 }
10413
10414 pSession = CSR_GET_SESSION(pMac, sessionId);
10415 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010416 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010417 return;
10418 }
10419
Kapil Guptaffa26022017-08-16 12:20:09 +053010420 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
10421
10422 if (!roamInfo) {
10423 sme_err("failed to allocate memory");
10424 return;
10425 }
10426
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010428 sme_debug("***eCsrNothingToJoin***");
Krunal Sonif3583022017-02-10 17:18:10 -080010429 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010430 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac, sessionId) ||
10431 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, sessionId)) {
10432 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010433 sme_debug("CSR force disassociated successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010434 /*
10435 * A callback to HDD will be issued from
10436 * csr_roam_complete so no need to do anything here
10437 */
10438 }
Krunal Sonif3583022017-02-10 17:18:10 -080010439 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010440 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010441 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010442 "CSR SmeDisassocReq due to HO on session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010443 sessionId);
10444 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010445 /*
10446 * First ensure if the roam profile is in the scan cache.
10447 * If not, post a reassoc failure and disconnect.
10448 */
10449 if (!csr_check_profile_in_scan_cache(pMac, &pScanFilter,
10450 pNeighborRoamInfo, &hBSSList))
10451 goto POST_ROAM_FAILURE;
10452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453 /* notify HDD about handoff and provide the BSSID too */
Kapil Guptaffa26022017-08-16 12:20:09 +053010454 roamInfo->reasonCode = eCsrRoamReasonBetterAP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010455
Kapil Guptaffa26022017-08-16 12:20:09 +053010456 qdf_copy_macaddr(&roamInfo->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010457 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid);
10458
Kapil Guptaffa26022017-08-16 12:20:09 +053010459 csr_roam_call_callback(pMac, sessionId, roamInfo, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010460 eCSR_ROAM_ROAMING_START,
10461 eCSR_ROAM_RESULT_NONE);
10462
10463 /*
10464 * Copy the connected profile to apply the same for this
10465 * connection as well
10466 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010467 pCurRoamProfile = qdf_mem_malloc(sizeof(*pCurRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010468 if (pCurRoamProfile != NULL) {
10469 /*
10470 * notify sub-modules like QoS etc. that handoff
10471 * happening
10472 */
10473 sme_qos_csr_event_ind(pMac, sessionId,
10474 SME_QOS_CSR_HANDOFF_ASSOC_REQ,
10475 NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010476 csr_roam_copy_profile(pMac, pCurRoamProfile,
10477 pSession->pCurRoamProfile);
Zhu Jianmin3c83a842018-03-14 20:50:24 +080010478 /*
10479 * After ensuring that the roam profile is in the scan
10480 * result list, and pSession->pCurRoamProfile is saved,
10481 * dequeue the command from the active list.
10482 */
10483 csr_dequeue_command(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010484 /* make sure to put it at the head of the cmd queue */
10485 status = csr_roam_issue_connect(pMac, sessionId,
10486 pCurRoamProfile, hBSSList,
10487 eCsrSmeIssuedAssocToSimilarAP,
10488 roamId, true, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010489 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010490 sme_err(
10491 "issue_connect failed. status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010492 status);
10493
10494 csr_release_profile(pMac, pCurRoamProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010495 qdf_mem_free(pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010496 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010497 qdf_mem_free(pScanFilter);
Kapil Guptaffa26022017-08-16 12:20:09 +053010498 qdf_mem_free(roamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010499 return;
Arif Hussainfdb25e22017-02-05 17:38:16 -080010500 } else {
Zhu Jianmin3c83a842018-03-14 20:50:24 +080010501 sme_err("pCurRoamProfile memory alloc failed");
10502 QDF_ASSERT(0);
10503 csr_dequeue_command(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010504 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010505 csr_scan_result_purge(pMac, hBSSList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010506
10507POST_ROAM_FAILURE:
Kapil Guptaffa26022017-08-16 12:20:09 +053010508 csr_post_roam_failure(pMac, sessionId, roamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010509 pScanFilter, pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010510 } /* else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) ) */
10511 else if (CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac, sessionId)) {
10512 /* Disassoc due to Reassoc failure falls into this codepath */
Krunal Sonif3583022017-02-10 17:18:10 -080010513 csr_roam_complete(pMac, eCsrJoinFailure, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010514 } else {
10515 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
10516 /*
10517 * Successfully disassociated from the 'old' Bss.
10518 * We get Disassociate response in three conditions.
10519 * 1) The case where we are disasociating from an Infra
10520 * Bss to start an IBSS.
10521 * 2) When we are disassociating from an Infra Bss to
10522 * join an IBSS or a new infra network.
10523 * 3) Where we are doing an Infra to Infra roam between
10524 * networks with different SSIDs.
10525 * In all cases, we set the new Bss configuration here
10526 * and attempt to join
10527 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010528 sme_debug("Disassociated successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010529 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010530 sme_err(
10531 "DisassocReq failed, statusCode= 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010532 SmeDisassocRsp.statusCode);
10533 }
10534 /* We are not done yet. Get the data and continue roaming */
Krunal Sonif3583022017-02-10 17:18:10 -080010535 csr_roam_reissue_roam_command(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010536 }
Kapil Guptaffa26022017-08-16 12:20:09 +053010537 qdf_mem_free(roamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010538}
10539
10540static void csr_roam_roaming_state_deauth_rsp_processor(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010541 tSirSmeDeauthRsp *pSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010542{
10543 tSirResultCodes statusCode;
10544 /* No one is sending eWNI_SME_DEAUTH_REQ to PE. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010545 sme_debug("is no-op");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010546 statusCode = csr_get_de_auth_rsp_status_code(pSmeRsp);
10547 pMac->roam.deauthRspStatus = statusCode;
10548 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId)) {
Krunal Sonif3583022017-02-10 17:18:10 -080010549 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
10550 pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010551 } else {
10552 if (eSIR_SME_SUCCESS == statusCode) {
10553 /* Successfully deauth from the 'old' Bss... */
10554 /* */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010555 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010556 "CSR SmeDeauthReq disassociated Successfully");
10557 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010558 sme_warn(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010559 "SmeDeauthReq failed with statusCode= 0x%08X",
10560 statusCode);
10561 }
10562 /* We are not done yet. Get the data and continue roaming */
Krunal Sonif3583022017-02-10 17:18:10 -080010563 csr_roam_reissue_roam_command(pMac, pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010564 }
10565}
10566
10567static void csr_roam_roaming_state_start_bss_rsp_processor(tpAniSirGlobal pMac,
10568 tSirSmeStartBssRsp *
10569 pSmeStartBssRsp)
10570{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053010571 enum csr_roamcomplete_result result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010572
10573 if (eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010574 sme_debug("SmeStartBssReq Successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010575 result = eCsrStartBssSuccess;
10576 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010577 sme_warn("SmeStartBssReq failed with statusCode= 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010578 pSmeStartBssRsp->statusCode);
10579 /* Let csr_roam_complete decide what to do */
10580 result = eCsrStartBssFailure;
10581 }
Krunal Sonif3583022017-02-10 17:18:10 -080010582 csr_roam_complete(pMac, result, pSmeStartBssRsp,
10583 pSmeStartBssRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010584}
10585
10586/**
10587 * csr_roaming_state_msg_processor() - process roaming messages
10588 * @pMac: mac global context
10589 * @pMsgBuf: message buffer
10590 *
10591 * We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of
10592 * strucutres. It depends on how the message is constructed. If the message is
10593 * sent by lim_send_sme_rsp, the pMsgBuf is only a generic response and can only
10594 * be used as pointer to tSirSmeRsp. For the messages where sender allocates
10595 * memory for specific structures, then it can be cast accordingly.
10596 *
10597 * Return: status of operation
10598 */
10599void csr_roaming_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
10600{
10601 tSirSmeRsp *pSmeRsp;
10602 tSmeIbssPeerInd *pIbssPeerInd;
Rajeev Kumara57db6b2017-11-14 16:36:59 -080010603 struct csr_roam_info *roam_info;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010604
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010605 pSmeRsp = (tSirSmeRsp *) pMsgBuf;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010606 sme_debug("Message %d[0x%04X] received in substate %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010607 pSmeRsp->messageType, pSmeRsp->messageType,
10608 mac_trace_getcsr_roam_sub_state(
10609 pMac->roam.curSubState[pSmeRsp->sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010610
10611 switch (pSmeRsp->messageType) {
10612
10613 case eWNI_SME_JOIN_RSP:
10614 /* in Roaming state, process the Join response message... */
10615 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
10616 /* We sent a JOIN_REQ */
10617 csr_roam_join_rsp_processor(pMac,
10618 (tSirSmeJoinRsp *) pSmeRsp);
10619 break;
10620 case eWNI_SME_REASSOC_RSP:
10621 /* or the Reassociation response message... */
10622 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ(pMac, pSmeRsp->sessionId))
10623 csr_roam_roaming_state_reassoc_rsp_processor(pMac,
10624 (tpSirSmeJoinRsp) pSmeRsp);
10625 break;
10626 case eWNI_SME_STOP_BSS_RSP:
10627 /* or the Stop Bss response message... */
10628 csr_roam_roaming_state_stop_bss_rsp_processor(pMac, pSmeRsp);
10629 break;
10630 case eWNI_SME_DISASSOC_RSP:
10631 /* or the Disassociate response message... */
10632 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, pSmeRsp->sessionId)
10633 || CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac,
10634 pSmeRsp->sessionId)
10635 || CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac,
10636 pSmeRsp->sessionId)
10637 || CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac,
10638 pSmeRsp->sessionId)
10639 || CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE(pMac,
10640 pSmeRsp->sessionId)
10641 || CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac,
10642 pSmeRsp->sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010643 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010644 "eWNI_SME_DISASSOC_RSP subState = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010645 mac_trace_getcsr_roam_sub_state(
10646 pMac->roam.curSubState[pSmeRsp->sessionId]));
10647 csr_roam_roaming_state_disassoc_rsp_processor(pMac,
10648 (tSirSmeDisassocRsp *) pSmeRsp);
10649 }
10650 break;
10651 case eWNI_SME_DEAUTH_RSP:
10652 /* or the Deauthentication response message... */
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +053010653 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId)) {
Krunal Soni72dba662017-02-15 20:13:17 -080010654 csr_remove_nonscan_cmd_from_pending_list(pMac,
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +053010655 pSmeRsp->sessionId,
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +053010656 eSmeCommandWmStatusChange);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010657 csr_roam_roaming_state_deauth_rsp_processor(pMac,
10658 (tSirSmeDeauthRsp *) pSmeRsp);
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +053010659 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010660 break;
10661 case eWNI_SME_START_BSS_RSP:
10662 /* or the Start BSS response message... */
10663 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ(pMac,
10664 pSmeRsp->sessionId))
10665 csr_roam_roaming_state_start_bss_rsp_processor(pMac,
10666 (tSirSmeStartBssRsp *) pSmeRsp);
10667 break;
10668 /* In case CSR issues STOP_BSS, we need to tell HDD about peer departed
Jeff Johnson698eacd2018-05-12 17:00:03 -070010669 * because PE is removing them
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010670 */
10671 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10672 pIbssPeerInd = (tSmeIbssPeerInd *) pSmeRsp;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010673 sme_err("Peer departed ntf from LIM in joining state");
Rajeev Kumara57db6b2017-11-14 16:36:59 -080010674 roam_info = qdf_mem_malloc(sizeof(*roam_info));
10675 if (!roam_info) {
10676 sme_err("failed to allocate memory for roam_info");
10677 break;
10678 }
10679
10680 roam_info->staId = (uint8_t) pIbssPeerInd->staId;
Rajeev Kumara57db6b2017-11-14 16:36:59 -080010681 qdf_copy_macaddr(&roam_info->peerMac, &pIbssPeerInd->peer_addr);
10682 csr_roam_call_callback(pMac, pSmeRsp->sessionId, roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010683 eCSR_ROAM_CONNECT_STATUS_UPDATE,
10684 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
Rajeev Kumara57db6b2017-11-14 16:36:59 -080010685 qdf_mem_free(roam_info);
10686 roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 break;
10688 case eWNI_SME_GET_RSSI_REQ:
10689 {
10690 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010692 if (NULL != pGetRssiReq->rssiCallback)
10693 ((tCsrRssiCallback) pGetRssiReq->rssiCallback)
10694 (pGetRssiReq->lastRSSI, pGetRssiReq->staId,
10695 pGetRssiReq->pDevContext);
10696 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010697 sme_err("pGetRssiReq->rssiCallback is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010698 }
10699 break;
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +053010700 case eWNI_SME_TRIGGER_SAE:
10701 sme_debug("Invoke SAE callback");
10702 csr_sae_callback(pMac, pSmeRsp);
10703 break;
10704
Vignesh Viswanathan200f5c12018-02-27 14:01:59 +053010705 case eWNI_SME_SETCONTEXT_RSP:
10706 csr_roam_check_for_link_status_change(pMac, pSmeRsp);
10707 break;
10708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010709 default:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010710 sme_debug("Unexpected message type: %d[0x%X] received in substate %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010711 pSmeRsp->messageType, pSmeRsp->messageType,
10712 mac_trace_getcsr_roam_sub_state(
10713 pMac->roam.curSubState[pSmeRsp->sessionId]));
10714 /* If we are connected, check the link status change */
10715 if (!csr_is_conn_state_disconnected(pMac, pSmeRsp->sessionId))
10716 csr_roam_check_for_link_status_change(pMac, pSmeRsp);
10717 break;
10718 }
10719}
10720
10721void csr_roam_joined_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
10722{
10723 tSirSmeRsp *pSirMsg = (tSirSmeRsp *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010725 switch (pSirMsg->messageType) {
10726 case eWNI_SME_GET_STATISTICS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010727 sme_debug("Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010728 csr_roam_stats_rsp_processor(pMac, pSirMsg);
10729 break;
10730 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
10731 {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010732 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010733 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
Jeff Johnson172237b2017-11-07 15:32:59 -080010734 struct csr_roam_info roamInfo;
10735 struct csr_roam_info *roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010736 uint32_t sessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010737 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010738
10739 sme_debug("ASSOCIATION confirmation can be given to upper layer ");
Jeff Johnson172237b2017-11-07 15:32:59 -080010740 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010741 roam_info = &roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010742 pUpperLayerAssocCnf =
10743 (tSirSmeAssocIndToUpperLayerCnf *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010744 status = csr_roam_get_session_id_from_bssid(pMac,
10745 (struct qdf_mac_addr *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010746 pUpperLayerAssocCnf->
10747 bssId, &sessionId);
10748 pSession = CSR_GET_SESSION(pMac, sessionId);
10749
10750 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010751 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010752 return;
10753 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010754 /* send the status code as Success */
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010755 roam_info->statusCode = eSIR_SME_SUCCESS;
10756 roam_info->u.pConnectedProfile =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010757 &pSession->connectedProfile;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010758 roam_info->staId = (uint8_t) pUpperLayerAssocCnf->aid;
10759 roam_info->rsnIELen =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010760 (uint8_t) pUpperLayerAssocCnf->rsnIE.length;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010761 roam_info->prsnIE =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010762 pUpperLayerAssocCnf->rsnIE.rsnIEdata;
10763#ifdef FEATURE_WLAN_WAPI
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010764 roam_info->wapiIELen =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010765 (uint8_t) pUpperLayerAssocCnf->wapiIE.length;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010766 roam_info->pwapiIE =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010767 pUpperLayerAssocCnf->wapiIE.wapiIEdata;
10768#endif
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010769 roam_info->addIELen =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010770 (uint8_t) pUpperLayerAssocCnf->addIE.length;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010771 roam_info->paddIE =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010772 pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010773 qdf_mem_copy(roam_info->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010774 pUpperLayerAssocCnf->peerMacAddr,
10775 sizeof(tSirMacAddr));
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010776 qdf_mem_copy(&roam_info->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010777 pUpperLayerAssocCnf->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010778 sizeof(struct qdf_mac_addr));
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010779 roam_info->wmmEnabledSta =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010780 pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010781 roam_info->timingMeasCap =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010782 pUpperLayerAssocCnf->timingMeasCap;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010783 qdf_mem_copy(&roam_info->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010784 &pUpperLayerAssocCnf->chan_info,
10785 sizeof(tSirSmeChanInfo));
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010786 roam_info->ampdu = pUpperLayerAssocCnf->ampdu;
10787 roam_info->sgi_enable = pUpperLayerAssocCnf->sgi_enable;
10788 roam_info->tx_stbc = pUpperLayerAssocCnf->tx_stbc;
10789 roam_info->tx_stbc = pUpperLayerAssocCnf->rx_stbc;
10790 roam_info->ch_width = pUpperLayerAssocCnf->ch_width;
10791 roam_info->mode = pUpperLayerAssocCnf->mode;
10792 roam_info->max_supp_idx = pUpperLayerAssocCnf->max_supp_idx;
10793 roam_info->max_ext_idx = pUpperLayerAssocCnf->max_ext_idx;
10794 roam_info->max_mcs_idx = pUpperLayerAssocCnf->max_mcs_idx;
10795 roam_info->rx_mcs_map = pUpperLayerAssocCnf->rx_mcs_map;
10796 roam_info->tx_mcs_map = pUpperLayerAssocCnf->tx_mcs_map;
10797 roam_info->ecsa_capable = pUpperLayerAssocCnf->ecsa_capable;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053010798 if (pUpperLayerAssocCnf->ht_caps.present)
10799 roam_info->ht_caps = pUpperLayerAssocCnf->ht_caps;
10800 if (pUpperLayerAssocCnf->vht_caps.present)
10801 roam_info->vht_caps = pUpperLayerAssocCnf->vht_caps;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010802 if (CSR_IS_INFRA_AP(roam_info->u.pConnectedProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010803 pMac->roam.roamSession[sessionId].connectState =
10804 eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010805 roam_info->fReassocReq =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010806 pUpperLayerAssocCnf->reassocReq;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010807 status = csr_roam_call_callback(pMac, sessionId,
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010808 roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010809 eCSR_ROAM_INFRA_IND,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010810 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010811 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010812 }
10813 break;
10814 default:
10815 csr_roam_check_for_link_status_change(pMac, pSirMsg);
10816 break;
10817 }
10818}
10819
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010820QDF_STATUS csr_roam_issue_set_context_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010821 uint32_t sessionId,
10822 eCsrEncryptionType EncryptType,
10823 tSirBssDescription *pBssDescription,
10824 tSirMacAddr *bssId, bool addKey,
10825 bool fUnicast,
10826 tAniKeyDirection aniKeyDirection,
10827 uint8_t keyId, uint16_t keyLength,
10828 uint8_t *pKey, uint8_t paeRole)
10829{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010830 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010831 tAniEdType edType;
10832
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010833 sme_debug("sessionId: %d EncryptType: %d", sessionId, EncryptType);
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +053010834
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010835 if (eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010836 EncryptType = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010837
10838 edType = csr_translate_encrypt_type_to_ed_type(EncryptType);
10839
10840 /*
10841 * Allow 0 keys to be set for the non-WPA encrypt types. For WPA encrypt
10842 * types, the num keys must be non-zero or LIM will reject the set
10843 * context (assumes the SET_CONTEXT does not occur until the keys are
10844 * distrubuted).
10845 */
10846 if (CSR_IS_ENC_TYPE_STATIC(EncryptType) || addKey) {
10847 tCsrRoamSetKey setKey;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010849 setKey.encType = EncryptType;
10850 setKey.keyDirection = aniKeyDirection;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010851 qdf_mem_copy(&setKey.peerMac, bssId, sizeof(struct
10852 qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010853 /* 0 for supplicant */
10854 setKey.paeRole = paeRole;
10855 /* Key index */
10856 setKey.keyId = keyId;
10857 setKey.keyLength = keyLength;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010858 if (keyLength)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010859 qdf_mem_copy(setKey.Key, pKey, keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010860 status = csr_roam_issue_set_key_command(pMac, sessionId,
10861 &setKey, 0);
10862 }
10863 return status;
10864}
10865
10866/**
10867 * csr_update_key_cmd() - update key info in set key command
10868 * @mac_ctx: mac global context
10869 * @session: roam session
10870 * @set_key: input set key command
10871 * @set_key_cmd: set key command to update
Krunal Sonid3676732017-05-10 14:12:18 -070010872 * @is_key_valid: indicates if key is valid
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010873 *
Krunal Sonid3676732017-05-10 14:12:18 -070010874 * This function will validate the key length, adjust if too long. It will
Jeff Johnson11d7c9d2018-05-06 15:44:09 -070010875 * update is_key_valid flag to false if some error has occurred key are local.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010876 *
10877 * Return: status of operation
10878 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010879static QDF_STATUS
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010880csr_update_key_cmd(tpAniSirGlobal mac_ctx, struct csr_roam_session *session,
10881 tCsrRoamSetKey *set_key, struct setkey_cmd *set_key_cmd,
Krunal Sonid3676732017-05-10 14:12:18 -070010882 bool *is_key_valid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010883{
10884 switch (set_key->encType) {
10885 case eCSR_ENCRYPT_TYPE_WEP40:
10886 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
10887 /* KeyLength maybe 0 for static WEP */
10888 if (set_key->keyLength) {
10889 if (set_key->keyLength < CSR_WEP40_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010890 sme_warn("Invalid WEP40 keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010891 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010892 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010893 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010894 }
10895
Krunal Sonid3676732017-05-10 14:12:18 -070010896 set_key_cmd->keyLength = CSR_WEP40_KEY_LEN;
10897 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010898 CSR_WEP40_KEY_LEN);
10899 }
Krunal Sonid3676732017-05-10 14:12:18 -070010900 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010901 break;
10902 case eCSR_ENCRYPT_TYPE_WEP104:
10903 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
10904 /* KeyLength maybe 0 for static WEP */
10905 if (set_key->keyLength) {
10906 if (set_key->keyLength < CSR_WEP104_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010907 sme_warn("Invalid WEP104 keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010908 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010909 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010910 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010911 }
10912
Krunal Sonid3676732017-05-10 14:12:18 -070010913 set_key_cmd->keyLength = CSR_WEP104_KEY_LEN;
10914 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010915 CSR_WEP104_KEY_LEN);
10916 }
Krunal Sonid3676732017-05-10 14:12:18 -070010917 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010918 break;
10919 case eCSR_ENCRYPT_TYPE_TKIP:
10920 if (set_key->keyLength < CSR_TKIP_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010921 sme_warn("Invalid TKIP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010922 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010923 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010924 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010925 }
Krunal Sonid3676732017-05-10 14:12:18 -070010926 set_key_cmd->keyLength = CSR_TKIP_KEY_LEN;
10927 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010928 CSR_TKIP_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070010929 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010930 break;
10931 case eCSR_ENCRYPT_TYPE_AES:
10932 if (set_key->keyLength < CSR_AES_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010933 sme_warn("Invalid AES/CCMP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010934 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010935 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010936 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010937 }
Krunal Sonid3676732017-05-10 14:12:18 -070010938 set_key_cmd->keyLength = CSR_AES_KEY_LEN;
10939 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010940 CSR_AES_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070010941 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010942 break;
Mukul Sharma05504ac2017-06-08 12:35:53 +053010943 case eCSR_ENCRYPT_TYPE_AES_GCMP:
10944 if (set_key->keyLength < CSR_AES_GCMP_KEY_LEN) {
10945 sme_warn(
10946 "Invalid AES_GCMP keylength [= %d]",
10947 set_key->keyLength);
10948 *is_key_valid = false;
10949 return QDF_STATUS_E_INVAL;
10950 }
10951 set_key_cmd->keyLength = CSR_AES_GCMP_KEY_LEN;
10952 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
10953 CSR_AES_GCMP_KEY_LEN);
10954 *is_key_valid = true;
10955 break;
10956 case eCSR_ENCRYPT_TYPE_AES_GCMP_256:
10957 if (set_key->keyLength < CSR_AES_GCMP_256_KEY_LEN) {
10958 sme_warn(
10959 "Invalid AES_GCMP_256 keylength [= %d]",
10960 set_key->keyLength);
10961 *is_key_valid = false;
10962 return QDF_STATUS_E_INVAL;
10963 }
10964 set_key_cmd->keyLength = CSR_AES_GCMP_256_KEY_LEN;
10965 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
10966 CSR_AES_GCMP_256_KEY_LEN);
10967 *is_key_valid = true;
10968 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010969#ifdef FEATURE_WLAN_WAPI
10970 case eCSR_ENCRYPT_TYPE_WPI:
10971 if (set_key->keyLength < CSR_WAPI_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010972 sme_warn("Invalid WAPI keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010973 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010974 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010975 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010976 }
Krunal Sonid3676732017-05-10 14:12:18 -070010977 set_key_cmd->keyLength = CSR_WAPI_KEY_LEN;
10978 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010979 CSR_WAPI_KEY_LEN);
10980 if (session->pCurRoamProfile) {
10981 session->pCurRoamProfile->negotiatedUCEncryptionType =
10982 eCSR_ENCRYPT_TYPE_WPI;
10983 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010984 sme_err("pCurRoamProfile is NULL");
Krunal Sonid3676732017-05-10 14:12:18 -070010985 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010986 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010987 }
Krunal Sonid3676732017-05-10 14:12:18 -070010988 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010989 break;
10990#endif /* FEATURE_WLAN_WAPI */
10991#ifdef FEATURE_WLAN_ESE
10992 case eCSR_ENCRYPT_TYPE_KRK:
10993 /* no need to enqueue KRK key request, since they are local */
Krunal Sonid3676732017-05-10 14:12:18 -070010994 *is_key_valid = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010995 if (set_key->keyLength < CSR_KRK_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010996 sme_warn("Invalid KRK keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010997 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010998 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010999 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011000 qdf_mem_copy(session->eseCckmInfo.krk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011001 CSR_KRK_KEY_LEN);
11002 session->eseCckmInfo.reassoc_req_num = 1;
11003 session->eseCckmInfo.krk_plumbed = true;
11004 break;
11005#ifdef WLAN_FEATURE_ROAM_OFFLOAD
11006 case eCSR_ENCRYPT_TYPE_BTK:
11007 /* no need to enqueue KRK key request, since they are local */
Krunal Sonid3676732017-05-10 14:12:18 -070011008 *is_key_valid = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011009 if (set_key->keyLength < SIR_BTK_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070011010 sme_warn("LFR3:Invalid BTK keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011011 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011012 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011013 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011014 qdf_mem_copy(session->eseCckmInfo.btk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011015 SIR_BTK_KEY_LEN);
Padma, Santhosh Kumar2d1f77c2017-11-22 16:20:28 +053011016 /*
11017 * KRK and BTK are updated by upper layer back to back. Send
11018 * updated KRK and BTK together to FW here.
11019 */
11020 csr_roam_offload_scan(mac_ctx, session->sessionId,
11021 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11022 REASON_ROAM_PSK_PMK_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011023 break;
11024#endif
11025#endif /* FEATURE_WLAN_ESE */
11026#ifdef WLAN_FEATURE_11W
11027 /* Check for 11w BIP */
11028 case eCSR_ENCRYPT_TYPE_AES_CMAC:
11029 if (set_key->keyLength < CSR_AES_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070011030 sme_warn("Invalid AES/CCMP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011031 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070011032 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011033 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011034 }
Krunal Sonid3676732017-05-10 14:12:18 -070011035 set_key_cmd->keyLength = CSR_AES_KEY_LEN;
11036 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011037 CSR_AES_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070011038 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011039 break;
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +053011040
11041 case eCSR_ENCRYPT_TYPE_AES_GMAC_128:
11042 if (set_key->keyLength < CSR_AES_GMAC_128_KEY_LEN) {
11043 sme_warn("Invalid AES GMAC 128 keylength [= %d]",
11044 set_key->keyLength);
11045 *is_key_valid = false;
11046 return QDF_STATUS_E_INVAL;
11047 }
11048 set_key_cmd->keyLength = CSR_AES_GMAC_128_KEY_LEN;
11049 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
11050 CSR_AES_GMAC_128_KEY_LEN);
11051 *is_key_valid = true;
11052 break;
11053
11054 case eCSR_ENCRYPT_TYPE_AES_GMAC_256:
11055 if (set_key->keyLength < CSR_AES_GMAC_256_KEY_LEN) {
11056 sme_warn("Invalid AES GMAC 256 keylength [= %d]",
11057 set_key->keyLength);
11058 *is_key_valid = false;
11059 return QDF_STATUS_E_INVAL;
11060 }
11061 set_key_cmd->keyLength = CSR_AES_GMAC_256_KEY_LEN;
11062 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
11063 CSR_AES_GMAC_256_KEY_LEN);
11064 *is_key_valid = true;
11065 break;
11066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011067#endif /* WLAN_FEATURE_11W */
11068 default:
11069 /* for open security also we want to enqueue command */
Krunal Sonid3676732017-05-10 14:12:18 -070011070 *is_key_valid = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011071 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011072 } /* end of switch */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011073 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011074}
11075
11076
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011077static QDF_STATUS csr_roam_issue_set_key_command(
11078tpAniSirGlobal mac_ctx, uint32_t session_id,
11079 tCsrRoamSetKey *set_key,
11080 uint32_t roam_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011081{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011082 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Sonid3676732017-05-10 14:12:18 -070011083 bool is_key_valid = true;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011084 struct setkey_cmd set_key_cmd;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011085#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_WAPI)
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011086 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011087
Krunal Sonid3676732017-05-10 14:12:18 -070011088 if (NULL == session) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011089 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Krunal Sonid3676732017-05-10 14:12:18 -070011090 "session %d not found", session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011091 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011092 }
11093#endif /* FEATURE_WLAN_ESE */
11094
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011095 qdf_mem_zero(&set_key_cmd, sizeof(struct setkey_cmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011096 /*
11097 * following function will validate the key length, Adjust if too long.
11098 * for static WEP the keys are not set thru' SetContextReq
11099 *
Jeff Johnson11d7c9d2018-05-06 15:44:09 -070011100 * it will update bool is_key_valid, to false if some error has occurred
Krunal Sonid3676732017-05-10 14:12:18 -070011101 * key are local. enqueue sme command only if is_key_valid is true
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011102 * status is indication of success or failure and will be returned to
11103 * called of current function if command is not enqueued due to key req
11104 * being local
11105 */
Krunal Sonid3676732017-05-10 14:12:18 -070011106 status = csr_update_key_cmd(mac_ctx, session, set_key,
11107 &set_key_cmd, &is_key_valid);
11108 if (is_key_valid) {
11109 set_key_cmd.roamId = roam_id;
11110 set_key_cmd.encType = set_key->encType;
11111 set_key_cmd.keyDirection = set_key->keyDirection;
11112 qdf_copy_macaddr(&set_key_cmd.peermac,
11113 &set_key->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011114 /* 0 for supplicant */
Krunal Sonid3676732017-05-10 14:12:18 -070011115 set_key_cmd.paeRole = set_key->paeRole;
11116 set_key_cmd.keyId = set_key->keyId;
11117 qdf_mem_copy(set_key_cmd.keyRsc, set_key->keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011118 CSR_MAX_RSC_LEN);
11119 /*
11120 * Always put set key to the head of the Q because it is the
11121 * only thing to get executed in case of WT_KEY state
11122 */
Krunal Sonid3676732017-05-10 14:12:18 -070011123 sme_debug("set key req for session-%d authtype-%d",
11124 session_id, set_key->encType);
11125 status = csr_roam_send_set_key_cmd(mac_ctx, session_id,
11126 &set_key_cmd);
11127 if (!QDF_IS_STATUS_SUCCESS(status))
11128 sme_err("fail to send message status = %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011129 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011130 return status;
11131}
11132
Krunal Sonid3676732017-05-10 14:12:18 -070011133QDF_STATUS csr_roam_send_set_key_cmd(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011134 uint32_t session_id,
11135 struct setkey_cmd *set_key_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011136{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011137 QDF_STATUS status;
Krunal Sonid3676732017-05-10 14:12:18 -070011138 uint8_t num_keys = (set_key_cmd->keyLength) ? 1 : 0;
11139 tAniEdType ed_type = csr_translate_encrypt_type_to_ed_type(
11140 set_key_cmd->encType);
11141 bool unicast = (set_key_cmd->peermac.bytes[0] == 0xFF) ? false : true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011142#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011143 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011145 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
11146 host_event_wlan_security_payload_type);
11147
Krunal Sonid3676732017-05-10 14:12:18 -070011148 if (NULL == session) {
11149 sme_err("session %d not found", session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011150 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011151 }
11152
Krunal Sonid3676732017-05-10 14:12:18 -070011153 if (eSIR_ED_NONE != ed_type) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011154 qdf_mem_set(&setKeyEvent,
Krunal Sonid3676732017-05-10 14:12:18 -070011155 sizeof(host_event_wlan_security_payload_type), 0);
11156 if (qdf_is_macaddr_group(&set_key_cmd->peermac)) {
Abhishek Singh7a995582016-04-27 13:53:36 +053011157 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011158 setKeyEvent.encryptionModeMulticast =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011159 (uint8_t) diag_enc_type_from_csr_type(
Krunal Sonid3676732017-05-10 14:12:18 -070011160 set_key_cmd->encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161 setKeyEvent.encryptionModeUnicast =
Krunal Sonid3676732017-05-10 14:12:18 -070011162 (uint8_t) diag_enc_type_from_csr_type(session->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011163 connectedProfile.
11164 EncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011165 } else {
Abhishek Singh7a995582016-04-27 13:53:36 +053011166 setKeyEvent.eventId =
11167 WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011168 setKeyEvent.encryptionModeUnicast =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011169 (uint8_t) diag_enc_type_from_csr_type(
Krunal Sonid3676732017-05-10 14:12:18 -070011170 set_key_cmd->encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011171 setKeyEvent.encryptionModeMulticast =
Krunal Sonid3676732017-05-10 14:12:18 -070011172 (uint8_t) diag_enc_type_from_csr_type(session->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011173 connectedProfile.
11174 mcEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011175 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011176 qdf_mem_copy(setKeyEvent.bssid,
Krunal Sonid3676732017-05-10 14:12:18 -070011177 session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011178 QDF_MAC_ADDR_SIZE);
Krunal Sonid3676732017-05-10 14:12:18 -070011179 if (CSR_IS_ENC_TYPE_STATIC(set_key_cmd->encType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011180 uint32_t defKeyId;
11181 /* It has to be static WEP here */
Jeff Johnsonc09caa42018-06-07 22:58:55 -070011182 if (QDF_IS_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011183 WNI_CFG_WEP_DEFAULT_KEYID,
11184 &defKeyId))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011185 setKeyEvent.keyId = (uint8_t) defKeyId;
11186 }
11187 } else {
Krunal Sonid3676732017-05-10 14:12:18 -070011188 setKeyEvent.keyId = set_key_cmd->keyId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011189 }
11190 setKeyEvent.authMode =
Krunal Sonid3676732017-05-10 14:12:18 -070011191 (uint8_t) diag_auth_type_from_csr_type(session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011192 connectedProfile.
11193 AuthType);
11194 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
11195 }
11196#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
Krunal Sonid3676732017-05-10 14:12:18 -070011197 if (csr_is_set_key_allowed(mac_ctx, session_id)) {
11198 status = csr_send_mb_set_context_req_msg(mac_ctx, session_id,
11199 set_key_cmd->peermac,
11200 num_keys, ed_type, unicast,
11201 set_key_cmd->keyDirection,
11202 set_key_cmd->keyId,
11203 set_key_cmd->keyLength,
11204 set_key_cmd->Key,
11205 set_key_cmd->paeRole,
11206 set_key_cmd->keyRsc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011207 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011208 sme_warn(" cannot process not connected");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011209 /* Set this status so the error handling take
11210 * care of the case.
11211 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011212 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011213 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011214 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011215 sme_err(" error status %d", status);
Krunal Sonid3676732017-05-10 14:12:18 -070011216 csr_roam_call_callback(mac_ctx, session_id, NULL,
11217 set_key_cmd->roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011218 eCSR_ROAM_SET_KEY_COMPLETE,
11219 eCSR_ROAM_RESULT_FAILURE);
11220#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Krunal Sonid3676732017-05-10 14:12:18 -070011221 if (eSIR_ED_NONE != ed_type) {
11222 if (qdf_is_macaddr_group(&set_key_cmd->peermac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011223 setKeyEvent.eventId =
Abhishek Singh7a995582016-04-27 13:53:36 +053011224 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Krunal Sonid3676732017-05-10 14:12:18 -070011225 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011226 setKeyEvent.eventId =
Abhishek Singh7a995582016-04-27 13:53:36 +053011227 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011228 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
11229 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent,
11230 EVENT_WLAN_SECURITY);
11231 }
11232#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11233 }
11234 return status;
11235}
11236
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011237QDF_STATUS csr_roam_set_key(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011238 tCsrRoamSetKey *pSetKey, uint32_t roamId)
11239{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011240 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011241
11242 if (!csr_is_set_key_allowed(pMac, sessionId)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011243 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011244 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011245 status = csr_roam_issue_set_key_command(pMac, sessionId,
11246 pSetKey, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011247 }
11248 return status;
11249}
11250
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011251#ifdef WLAN_FEATURE_FILS_SK
11252/*
11253 * csr_create_fils_realm_hash: API to create hash using realm
11254 * @fils_con_info: fils connection info obtained from supplicant
11255 * @tmp_hash: pointer to new hash
11256 *
11257 * Return: None
11258 */
11259static bool
11260csr_create_fils_realm_hash(struct cds_fils_connection_info *fils_con_info,
11261 uint8_t *tmp_hash)
11262{
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053011263 uint8_t *hash;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011264 uint8_t *data[1];
11265
11266 if (!fils_con_info->realm_len)
11267 return false;
11268
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053011269 hash = qdf_mem_malloc(SHA256_DIGEST_SIZE);
11270 if (!hash) {
11271 sme_err("malloc fails in fils realm");
11272 return false;
11273 }
11274
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011275 data[0] = fils_con_info->realm;
11276 qdf_get_hash(SHA256_CRYPTO_TYPE, 1, data,
11277 &fils_con_info->realm_len, hash);
11278 qdf_trace_hex_dump(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
11279 hash, SHA256_DIGEST_SIZE);
11280 qdf_mem_copy(tmp_hash, hash, 2);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053011281 qdf_mem_free(hash);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011282 return true;
11283}
11284
11285/*
11286 * csr_update_fils_scan_filter: update scan filter in case of fils session
11287 * @scan_fltr: pointer to scan filer
11288 * @profile: csr profile pointer
11289 *
11290 * Return: None
11291 */
11292static void csr_update_fils_scan_filter(tCsrScanResultFilter *scan_fltr,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070011293 struct csr_roam_profile *profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011294{
11295 if (profile->fils_con_info &&
11296 profile->fils_con_info->is_fils_connection) {
11297 uint8_t realm_hash[2];
11298
11299 sme_debug("creating realm based on fils info %d",
11300 profile->fils_con_info->is_fils_connection);
11301 scan_fltr->realm_check = csr_create_fils_realm_hash(
11302 profile->fils_con_info, realm_hash);
11303 memcpy(scan_fltr->fils_realm, realm_hash,
11304 sizeof(uint8_t) * 2);
11305 }
11306
11307}
11308#else
11309static void csr_update_fils_scan_filter(tCsrScanResultFilter *scan_fltr,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070011310 struct csr_roam_profile *profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011311{ }
11312#endif
11313
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011314/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011315 * Prepare a filter base on a profile for parsing the scan results.
11316 * Upon successful return, caller MUST call csr_free_scan_filter on
11317 *pScanFilter when it is done with the filter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011318 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011319QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011320csr_roam_prepare_filter_from_profile(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070011321 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011322 tCsrScanResultFilter *scan_fltr)
11323{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011324 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011325 uint32_t size = 0;
11326 uint8_t idx = 0;
11327 tCsrChannelInfo *fltr_ch_info = &scan_fltr->ChannelInfo;
11328 tCsrChannelInfo *profile_ch_info = &profile->ChannelInfo;
11329 struct roam_ext_params *roam_params;
11330 uint8_t i;
11331
11332 roam_params = &mac_ctx->roam.configParam.roam_params;
11333
11334 if (profile->BSSIDs.numOfBSSIDs) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011335 size = sizeof(struct qdf_mac_addr) * profile->BSSIDs.
11336 numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011337 scan_fltr->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011338 if (NULL == scan_fltr->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011339 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011340 goto free_filter;
11341 }
11342 scan_fltr->BSSIDs.numOfBSSIDs = profile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011343 qdf_mem_copy(scan_fltr->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011344 profile->BSSIDs.bssid, size);
11345 }
11346
11347 if (profile->SSIDs.numOfSSIDs) {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070011348 scan_fltr->SSIDs.numOfSSIDs = profile->SSIDs.numOfSSIDs;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011349 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011350 ("No of Allowed List:%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011351 roam_params->num_ssid_allowed_list);
11352 if (scan_fltr->scan_filter_for_roam
11353 && roam_params->num_ssid_allowed_list) {
11354 scan_fltr->SSIDs.numOfSSIDs =
11355 roam_params->num_ssid_allowed_list;
11356 size = sizeof(tCsrSSIDInfo) *
11357 scan_fltr->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011358 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011359 if (NULL == scan_fltr->SSIDs.SSIDList)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011360 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011361 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011362 status = QDF_STATUS_SUCCESS;
11363 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011364 goto free_filter;
11365 for (i = 0;
11366 i < roam_params->num_ssid_allowed_list;
11367 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011368 qdf_mem_copy((void *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011369 scan_fltr->SSIDs.SSIDList[i].SSID.ssId,
11370 roam_params->ssid_allowed_list[i].ssId,
11371 roam_params->ssid_allowed_list[i].length);
11372 scan_fltr->SSIDs.SSIDList[i].SSID.length =
11373 roam_params->ssid_allowed_list[i].length;
11374 scan_fltr->SSIDs.SSIDList[i].handoffPermitted =
11375 1;
11376 scan_fltr->SSIDs.SSIDList[i].ssidHidden = 0;
11377 }
11378 } else {
11379 size = sizeof(tCsrSSIDInfo) *
11380 profile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011381 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011382 if (NULL == scan_fltr->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011383 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011384 goto free_filter;
11385 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011386 qdf_mem_copy(scan_fltr->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011387 profile->SSIDs.SSIDList, size);
11388 }
11389 }
11390
11391 if (!profile_ch_info->ChannelList
11392 || (profile_ch_info->ChannelList[0] == 0)) {
11393 fltr_ch_info->numOfChannels = 0;
11394 fltr_ch_info->ChannelList = NULL;
11395 } else if (profile_ch_info->numOfChannels) {
11396 fltr_ch_info->numOfChannels = 0;
11397 fltr_ch_info->ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011398 qdf_mem_malloc(sizeof(*(fltr_ch_info->ChannelList)) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011399 profile_ch_info->numOfChannels);
11400 if (NULL == fltr_ch_info->ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011401 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011402 goto free_filter;
11403 }
11404
11405 for (idx = 0; idx < profile_ch_info->numOfChannels; idx++) {
11406 if (csr_roam_is_channel_valid(mac_ctx,
11407 profile_ch_info->ChannelList[idx])) {
11408 fltr_ch_info->
11409 ChannelList[fltr_ch_info->numOfChannels]
11410 = profile_ch_info->ChannelList[idx];
11411 fltr_ch_info->numOfChannels++;
11412 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011413 sme_debug(
11414 "Channel (%d) is invalid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011415 profile_ch_info->ChannelList[idx]);
11416 }
11417 }
11418 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011419 sme_err("Channel list empty");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011420 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011421 goto free_filter;
11422 }
11423 scan_fltr->uapsd_mask = profile->uapsd_mask;
11424 scan_fltr->authType = profile->AuthType;
11425 scan_fltr->EncryptionType = profile->EncryptionType;
11426 scan_fltr->mcEncryptionType = profile->mcEncryptionType;
11427 scan_fltr->BSSType = profile->BSSType;
11428 scan_fltr->phyMode = profile->phyMode;
11429#ifdef FEATURE_WLAN_WAPI
11430 /*
11431 * check if user asked for WAPI with 11n or auto mode, in that
11432 * case modify the phymode to 11g
11433 */
11434 if (csr_is_profile_wapi(profile)) {
11435 if (scan_fltr->phyMode & eCSR_DOT11_MODE_11n)
11436 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_11n;
11437 if (scan_fltr->phyMode & eCSR_DOT11_MODE_AUTO)
11438 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_AUTO;
11439 if (!scan_fltr->phyMode)
11440 scan_fltr->phyMode = eCSR_DOT11_MODE_11g;
11441 }
11442#endif /* FEATURE_WLAN_WAPI */
11443 /*Save the WPS info */
11444 scan_fltr->bWPSAssociation = profile->bWPSAssociation;
11445 scan_fltr->bOSENAssociation = profile->bOSENAssociation;
11446 if (profile->countryCode[0]) {
11447 /*
11448 * This causes the matching function to use countryCode as one
11449 * of the criteria.
11450 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011451 qdf_mem_copy(scan_fltr->countryCode, profile->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011452 WNI_CFG_COUNTRY_CODE_LEN);
11453 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011454 if (profile->MDID.mdiePresent) {
11455 scan_fltr->MDID.mdiePresent = 1;
11456 scan_fltr->MDID.mobilityDomain = profile->MDID.mobilityDomain;
11457 }
Abhishek Singh3c9910e2017-01-06 17:56:47 +053011458 qdf_mem_copy(scan_fltr->bssid_hint.bytes,
11459 profile->bssid_hint.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011460
11461#ifdef WLAN_FEATURE_11W
11462 /* Management Frame Protection */
11463 scan_fltr->MFPEnabled = profile->MFPEnabled;
11464 scan_fltr->MFPRequired = profile->MFPRequired;
11465 scan_fltr->MFPCapable = profile->MFPCapable;
11466#endif
11467 scan_fltr->csrPersona = profile->csrPersona;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011468 csr_update_fils_scan_filter(scan_fltr, profile);
Abhishek Singhedb73602018-02-20 15:20:26 +053011469 scan_fltr->force_rsne_override = profile->force_rsne_override;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011470
11471free_filter:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011472 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011473 csr_free_scan_filter(mac_ctx, scan_fltr);
11474
11475 return status;
11476}
11477
Jeff Johnson29e2ca12016-10-14 12:50:38 -070011478static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011479bool csr_roam_issue_wm_status_change(tpAniSirGlobal pMac, uint32_t sessionId,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011480 enum csr_roam_wmstatus_changetypes Type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011481 tSirSmeRsp *pSmeRsp)
11482{
11483 bool fCommandQueued = false;
11484 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011485
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011486 do {
11487 /* Validate the type is ok... */
11488 if ((eCsrDisassociated != Type)
11489 && (eCsrDeauthenticated != Type))
11490 break;
11491 pCommand = csr_get_command_buffer(pMac);
11492 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011493 sme_err(" fail to get command buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011494 break;
11495 }
11496 /* Change the substate in case it is waiting for key */
11497 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
11498 csr_roam_stop_wait_for_key_timer(pMac);
11499 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
11500 sessionId);
11501 }
11502 pCommand->command = eSmeCommandWmStatusChange;
11503 pCommand->sessionId = (uint8_t) sessionId;
11504 pCommand->u.wmStatusChangeCmd.Type = Type;
11505 if (eCsrDisassociated == Type) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011506 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011507 DisassocIndMsg, pSmeRsp,
11508 sizeof(pCommand->u.wmStatusChangeCmd.u.
11509 DisassocIndMsg));
11510 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011511 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011512 DeauthIndMsg, pSmeRsp,
11513 sizeof(pCommand->u.wmStatusChangeCmd.u.
11514 DeauthIndMsg));
11515 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011516 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka6c909eb2018-07-31 18:28:32 +053011517 (csr_queue_sme_command(pMac, pCommand, false)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011518 fCommandQueued = true;
Krunal Soniaa179db2017-10-13 19:28:17 -070011519 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011520 sme_err("fail to send message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011521
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011522 /* AP has issued Dissac/Deauth, Set the operating mode
11523 * value to configured value
11524 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011525 csr_set_default_dot11_mode(pMac);
11526 } while (0);
11527 return fCommandQueued;
11528}
11529
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011530static QDF_STATUS csr_send_snr_request(void *pGetRssiReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011531{
11532 void *wma_handle;
11533
Anurag Chouhan6d760662016-02-20 16:05:43 +053011534 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011535 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011536 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011537 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011538 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011539 }
11540
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011541 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011542 wma_send_snr_request(wma_handle, pGetRssiReq)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011543 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011544 "Failed to Trigger wma stats request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011545 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011546 }
11547
11548 /* dont send success, otherwise call back
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011549 * will released with out values
11550 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011551 return QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011552}
11553
11554static void csr_update_rssi(tpAniSirGlobal pMac, void *pMsg)
11555{
11556 int8_t rssi = 0;
11557 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011558 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011559
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011560 if (pGetRssiReq) {
Jeff Johnson8bd23352017-09-26 11:39:24 -070011561 qdf_status = csr_send_snr_request(pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011562
11563 if (NULL != pGetRssiReq->rssiCallback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011564 if (qdf_status != QDF_STATUS_E_BUSY)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011565 ((tCsrRssiCallback) (pGetRssiReq->rssiCallback))
11566 (rssi, pGetRssiReq->staId,
11567 pGetRssiReq->pDevContext);
11568 else
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011569 sme_debug("rssi request is posted. waiting for reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011570 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011571 sme_err("GetRssiReq->rssiCallback is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011572 return;
11573 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011574 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011575 sme_err("pGetRssiReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011576
11577}
11578
11579static void csr_update_snr(tpAniSirGlobal pMac, void *pMsg)
11580{
11581 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq *) pMsg;
11582
11583 if (pGetSnrReq) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011584 if (QDF_STATUS_SUCCESS != wma_get_snr(pGetSnrReq)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011585 sme_err("Error in wma_get_snr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011586 return;
11587 }
11588
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011589 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011590 sme_err("pGetSnrReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011591}
11592
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011593static QDF_STATUS csr_send_reset_ap_caps_changed(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011594 struct qdf_mac_addr *bssId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011595{
11596 tpSirResetAPCapsChange pMsg;
11597 uint16_t len;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011598 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011599
11600 /* Create the message and send to lim */
11601 len = sizeof(tSirResetAPCapsChange);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011602 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011603 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011604 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011605 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011606 status = QDF_STATUS_SUCCESS;
Srinivas Girigowda40567b92015-09-24 15:17:25 -070011607
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011608 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011609 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
11610 pMsg->length = len;
Anurag Chouhanc5548422016-02-24 18:33:27 +053011611 qdf_copy_macaddr(&pMsg->bssId, bssId);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011612 sme_debug(
11613 "CSR reset caps change for Bssid= " MAC_ADDRESS_STR,
Srinivas Girigowda40567b92015-09-24 15:17:25 -070011614 MAC_ADDR_ARRAY(pMsg->bssId.bytes));
Rajeev Kumard138ac52017-01-30 18:38:37 -080011615 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011616 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011617 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011618 }
11619 return status;
11620}
11621
11622static void
11623csr_roam_chk_lnk_assoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11624{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011625 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011626 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011627 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080011628 struct csr_roam_info *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011629 tSirSmeAssocInd *pAssocInd;
Jeff Johnson172237b2017-11-07 15:32:59 -080011630 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011631
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011632 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011633 sme_debug("Receive WNI_SME_ASSOC_IND from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011634 pAssocInd = (tSirSmeAssocInd *) msg_ptr;
11635 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011636 (struct qdf_mac_addr *) pAssocInd->bssId,
11637 &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011638 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011639 sme_debug("Couldn't find session_id for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011640 return;
11641 }
11642 session = CSR_GET_SESSION(mac_ctx, sessionId);
11643 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011644 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011645 return;
11646 }
11647 roam_info_ptr = &roam_info;
11648 /* Required for indicating the frames to upper layer */
11649 roam_info_ptr->assocReqLength = pAssocInd->assocReqLength;
11650 roam_info_ptr->assocReqPtr = pAssocInd->assocReqPtr;
11651 roam_info_ptr->beaconPtr = pAssocInd->beaconPtr;
11652 roam_info_ptr->beaconLength = pAssocInd->beaconLength;
11653 roam_info_ptr->statusCode = eSIR_SME_SUCCESS;
11654 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
11655 roam_info_ptr->staId = (uint8_t) pAssocInd->staId;
11656 roam_info_ptr->rsnIELen = (uint8_t) pAssocInd->rsnIE.length;
11657 roam_info_ptr->prsnIE = pAssocInd->rsnIE.rsnIEdata;
11658#ifdef FEATURE_WLAN_WAPI
11659 roam_info_ptr->wapiIELen = (uint8_t) pAssocInd->wapiIE.length;
11660 roam_info_ptr->pwapiIE = pAssocInd->wapiIE.wapiIEdata;
11661#endif
11662 roam_info_ptr->addIELen = (uint8_t) pAssocInd->addIE.length;
11663 roam_info_ptr->paddIE = pAssocInd->addIE.addIEdata;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011664 qdf_mem_copy(roam_info_ptr->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011665 pAssocInd->peerMacAddr,
11666 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011667 qdf_mem_copy(roam_info_ptr->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011668 pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011669 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011670 roam_info_ptr->wmmEnabledSta = pAssocInd->wmmEnabledSta;
11671 roam_info_ptr->timingMeasCap = pAssocInd->timingMeasCap;
gaolez7bb1e742017-03-21 16:37:38 +080011672 roam_info_ptr->ecsa_capable = pAssocInd->ecsa_capable;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011673 qdf_mem_copy(&roam_info_ptr->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011674 &pAssocInd->chan_info,
11675 sizeof(tSirSmeChanInfo));
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053011676
11677 if (pAssocInd->HTCaps.present)
11678 qdf_mem_copy(&roam_info_ptr->ht_caps,
11679 &pAssocInd->HTCaps,
11680 sizeof(tDot11fIEHTCaps));
11681 if (pAssocInd->VHTCaps.present)
11682 qdf_mem_copy(&roam_info_ptr->vht_caps,
11683 &pAssocInd->VHTCaps,
11684 sizeof(tDot11fIEVHTCaps));
11685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011686 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)) {
11687 if (session->pCurRoamProfile &&
11688 CSR_IS_ENC_TYPE_STATIC(
11689 session->pCurRoamProfile->negotiatedUCEncryptionType)) {
11690 /* NO keys... these key parameters don't matter. */
11691 csr_roam_issue_set_context_req(mac_ctx, sessionId,
11692 session->pCurRoamProfile->negotiatedUCEncryptionType,
11693 session->pConnectBssDesc,
11694 &(roam_info_ptr->peerMac.bytes),
11695 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
11696 roam_info_ptr->fAuthRequired = false;
11697 } else {
11698 roam_info_ptr->fAuthRequired = true;
11699 }
11700 status = csr_roam_call_callback(mac_ctx, sessionId,
11701 roam_info_ptr, 0, eCSR_ROAM_INFRA_IND,
11702 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011703 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011704 /* Refused due to Mac filtering */
11705 roam_info_ptr->statusCode = eSIR_SME_ASSOC_REFUSED;
11706 }
11707
11708 /* Send Association completion message to PE */
11709 status = csr_send_assoc_cnf_msg(mac_ctx, pAssocInd, status);
11710 /*
11711 * send a message to CSR itself just to avoid the EAPOL frames going
11712 * OTA before association response
11713 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070011714 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011715 && (roam_info_ptr->statusCode != eSIR_SME_ASSOC_REFUSED)) {
11716 roam_info_ptr->fReassocReq = pAssocInd->reassocReq;
11717 status = csr_send_assoc_ind_to_upper_layer_cnf_msg(mac_ctx,
11718 pAssocInd, status, sessionId);
11719 }
11720}
11721
Yeshwanth Sriram Guntukad8987cf2018-06-13 14:57:54 +053011722/*
11723 * csr_is_deauth_disassoc_already_active() - Function to check if deauth or
11724 * disassoc is already in progress.
11725 * @mac_ctx: Global MAC context
11726 * @session_id: session id
11727 * @peer_macaddr: Peer MAC address
11728 *
11729 * Return: True if deauth/disassoc indication can be dropped
11730 * else false
11731 */
11732static bool csr_is_deauth_disassoc_already_active(tpAniSirGlobal mac_ctx,
11733 uint8_t session_id,
11734 struct qdf_mac_addr peer_macaddr)
11735{
11736 bool ret = false;
11737 tSmeCmd *sme_cmd;
11738
11739 sme_cmd = wlan_serialization_get_active_cmd(mac_ctx->psoc, session_id,
11740 WLAN_SER_CMD_FORCE_DEAUTH_STA);
11741 if (!sme_cmd) {
11742 sme_cmd = wlan_serialization_get_active_cmd(mac_ctx->psoc,
11743 session_id,
11744 WLAN_SER_CMD_FORCE_DISASSOC_STA);
11745 if (!sme_cmd)
11746 return ret;
11747 }
11748
11749 if ((mac_ctx->roam.curSubState[session_id] ==
11750 eCSR_ROAM_SUBSTATE_DEAUTH_REQ ||
11751 mac_ctx->roam.curSubState[session_id] ==
11752 eCSR_ROAM_SUBSTATE_DISASSOC_REQ) &&
11753 !qdf_mem_cmp(peer_macaddr.bytes, sme_cmd->u.roamCmd.peerMac,
11754 QDF_MAC_ADDR_SIZE)) {
Sandeep Puligilla1f1e4002018-08-18 12:15:01 -070011755 sme_debug("Ignore DEAUTH_IND/DIASSOC_IND as Deauth/Disassoc already in progress");
Yeshwanth Sriram Guntukad8987cf2018-06-13 14:57:54 +053011756 ret = true;
11757 }
11758
11759 return ret;
11760}
11761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011762static void
11763csr_roam_chk_lnk_disassoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11764{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011765 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011766 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011767 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011768 tSirSmeDisassocInd *pDisassocInd;
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011769 tSmeCmd *cmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011770
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011771 cmd = qdf_mem_malloc(sizeof(*cmd));
11772 if (NULL == cmd) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011773 sme_err("memory allocation failed for size: %zu", sizeof(*cmd));
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011774 return;
11775 }
11776
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011777 /*
11778 * Check if AP dis-associated us because of MIC failure. If so,
11779 * then we need to take action immediately and not wait till the
11780 * the WmStatusChange requests is pushed and processed
11781 */
11782 pDisassocInd = (tSirSmeDisassocInd *) msg_ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011783 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011784 &pDisassocInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011785 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011786 sme_err("Session Id not found for BSSID "MAC_ADDRESS_STR,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011787 MAC_ADDR_ARRAY(pDisassocInd->bssid.bytes));
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011788 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011789 return;
11790 }
11791
Yeshwanth Sriram Guntukad8987cf2018-06-13 14:57:54 +053011792 if (csr_is_deauth_disassoc_already_active(mac_ctx, sessionId,
11793 pDisassocInd->peer_macaddr)) {
11794 qdf_mem_free(cmd);
11795 return;
11796 }
11797
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011798 sme_err("DISASSOCIATION from peer =" MAC_ADDRESS_STR "reason: %d status: %d session: %d",
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011799 MAC_ADDR_ARRAY(pDisassocInd->peer_macaddr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011800 pDisassocInd->reasonCode,
Srinivas Girigowda0ee96442016-08-17 19:10:56 -070011801 pDisassocInd->statusCode, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011802 /*
11803 * If we are in neighbor preauth done state then on receiving
11804 * disassoc or deauth we dont roam instead we just disassoc
11805 * from current ap and then go to disconnected state
11806 * This happens for ESE and 11r FT connections ONLY.
11807 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011808 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
11809 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11810 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11811 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011812#ifdef FEATURE_WLAN_ESE
11813 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
11814 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11815 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11816 mac_ctx, sessionId);
11817#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011818 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
11819 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11820 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11821 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011822 session = CSR_GET_SESSION(mac_ctx, sessionId);
11823 if (!session) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011824 sme_err("session: %d not found", sessionId);
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011825 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011826 return;
11827 }
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053011828
11829 /* Update the disconnect stats */
11830 session->disconnect_stats.disconnection_cnt++;
11831 session->disconnect_stats.disassoc_by_peer++;
11832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011833 if (csr_is_conn_state_infra(mac_ctx, sessionId))
11834 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
11835#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11836 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
11837 SME_QOS_CSR_DISCONNECT_IND, NULL);
11838#endif
11839 csr_roam_link_down(mac_ctx, sessionId);
11840 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
11841 eCsrDisassociated, msg_ptr);
11842 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011843 /*
11844 * STA/P2P client got disassociated so remove any pending
11845 * deauth commands in sme pending list
11846 */
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011847 cmd->command = eSmeCommandRoam;
11848 cmd->sessionId = (uint8_t) sessionId;
11849 cmd->u.roamCmd.roamReason = eCsrForcedDeauthSta;
11850 qdf_mem_copy(cmd->u.roamCmd.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011851 pDisassocInd->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011852 QDF_MAC_ADDR_SIZE);
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011853 csr_roam_remove_duplicate_command(mac_ctx, sessionId, cmd,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011854 eCsrForcedDeauthSta);
11855 }
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011856 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011857}
11858
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011859/**
11860 * csr_roam_send_disconnect_done_indication() - Send disconnect ind to HDD.
11861 *
11862 * @mac_ctx: mac global context
11863 * @msg_ptr: incoming message
11864 *
11865 * This function gives final disconnect event to HDD after all cleanup in
11866 * lower layers is done.
11867 *
11868 * Return: None
11869 */
11870static void
11871csr_roam_send_disconnect_done_indication(tpAniSirGlobal mac_ctx, tSirSmeRsp
11872 *msg_ptr)
11873{
11874 struct sir_sme_discon_done_ind *discon_ind =
11875 (struct sir_sme_discon_done_ind *)(msg_ptr);
Jeff Johnson172237b2017-11-07 15:32:59 -080011876 struct csr_roam_info roam_info;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011877 struct csr_roam_session *session;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011878
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011879 sme_debug("eWNI_SME_DISCONNECT_DONE_IND RC:%d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011880 discon_ind->reason_code);
11881
11882 if (CSR_IS_SESSION_VALID(mac_ctx, discon_ind->session_id)) {
11883 roam_info.reasonCode = discon_ind->reason_code;
11884 roam_info.statusCode = eSIR_SME_STA_NOT_ASSOCIATED;
11885 qdf_mem_copy(roam_info.peerMac.bytes, discon_ind->peer_mac,
11886 ETH_ALEN);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053011887
11888 roam_info.rssi = mac_ctx->peer_rssi;
11889 roam_info.tx_rate = mac_ctx->peer_txrate;
11890 roam_info.rx_rate = mac_ctx->peer_rxrate;
Ashish Kumar Dhanotiyad39c8b52018-03-27 18:18:52 +053011891 roam_info.disassoc_reason = discon_ind->reason_code;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053011892
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011893 csr_roam_call_callback(mac_ctx, discon_ind->session_id,
11894 &roam_info, 0, eCSR_ROAM_LOSTLINK,
11895 eCSR_ROAM_RESULT_DISASSOC_IND);
11896 session = CSR_GET_SESSION(mac_ctx, discon_ind->session_id);
11897 if (session &&
11898 !CSR_IS_INFRA_AP(&session->connectedProfile))
11899 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
11900 discon_ind->session_id);
11901
11902 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011903 sme_err("Inactive session %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011904 discon_ind->session_id);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +053011905
11906 /*
11907 * Release WM status change command as eWNI_SME_DISCONNECT_DONE_IND
11908 * has been sent to HDD and there is nothing else left to do.
11909 */
11910 csr_roam_wm_status_change_complete(mac_ctx, discon_ind->session_id);
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011911}
11912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011913static void
11914csr_roam_chk_lnk_deauth_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11915{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011916 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011917 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011918 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011919 tSirSmeDeauthInd *pDeauthInd;
Jeff Johnson172237b2017-11-07 15:32:59 -080011920 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011921
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011922 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011923 sme_debug("DEAUTHENTICATION Indication from MAC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011924 pDeauthInd = (tpSirSmeDeauthInd) msg_ptr;
11925 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080011926 &pDeauthInd->bssid,
11927 &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011928 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011929 return;
Yeshwanth Sriram Guntukad8987cf2018-06-13 14:57:54 +053011930
11931 if (csr_is_deauth_disassoc_already_active(mac_ctx, sessionId,
11932 pDeauthInd->peer_macaddr))
11933 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011934 /* If we are in neighbor preauth done state then on receiving
11935 * disassoc or deauth we dont roam instead we just disassoc
11936 * from current ap and then go to disconnected state
11937 * This happens for ESE and 11r FT connections ONLY.
11938 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011939 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
11940 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11941 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11942 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011943#ifdef FEATURE_WLAN_ESE
11944 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
11945 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11946 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11947 mac_ctx, sessionId);
11948#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011949 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
11950 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11951 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11952 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011953 session = CSR_GET_SESSION(mac_ctx, sessionId);
11954 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011955 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011956 return;
11957 }
11958
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053011959 /* Update the disconnect stats */
11960 switch (pDeauthInd->reasonCode) {
11961 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
11962 session->disconnect_stats.disconnection_cnt++;
11963 session->disconnect_stats.peer_kickout++;
11964 break;
11965 case eSIR_MAC_UNSPEC_FAILURE_REASON:
11966 case eSIR_MAC_PREV_AUTH_NOT_VALID_REASON:
11967 case eSIR_MAC_DEAUTH_LEAVING_BSS_REASON:
11968 case eSIR_MAC_CLASS2_FRAME_FROM_NON_AUTH_STA_REASON:
11969 case eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON:
11970 case eSIR_MAC_STA_NOT_PRE_AUTHENTICATED_REASON:
11971 session->disconnect_stats.disconnection_cnt++;
11972 session->disconnect_stats.deauth_by_peer++;
11973 break;
11974 case eSIR_BEACON_MISSED:
11975 session->disconnect_stats.disconnection_cnt++;
11976 session->disconnect_stats.bmiss++;
11977 break;
11978 default:
11979 /* Unknown reason code */
11980 break;
11981 }
11982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011983 if (csr_is_conn_state_infra(mac_ctx, sessionId))
11984 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
11985#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11986 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
11987 SME_QOS_CSR_DISCONNECT_IND, NULL);
11988#endif
11989 csr_roam_link_down(mac_ctx, sessionId);
11990 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
11991 eCsrDeauthenticated,
11992 msg_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011993}
11994
11995static void
11996csr_roam_chk_lnk_swt_ch_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11997{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011998 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011999 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012000 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012001 tpSirSmeSwitchChannelInd pSwitchChnInd;
Jeff Johnson172237b2017-11-07 15:32:59 -080012002 struct csr_roam_info roamInfo;
Himanshu Agarwal71b93972018-06-14 01:16:01 +053012003 tSirMacDsParamSetIE *ds_params_ie;
12004 tDot11fIEHTInfo *ht_info_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012005
12006 /* in case of STA, the SWITCH_CHANNEL originates from its AP */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012007 sme_debug("eWNI_SME_SWITCH_CHL_IND from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012008 pSwitchChnInd = (tpSirSmeSwitchChannelInd) msg_ptr;
12009 /* Update with the new channel id. The channel id is hidden in the
12010 * statusCode.
12011 */
12012 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda591c5652015-12-30 17:39:50 -080012013 &pSwitchChnInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012014 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012015 session = CSR_GET_SESSION(mac_ctx, sessionId);
12016 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012017 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012018 return;
12019 }
12020 session->connectedProfile.operationChannel =
12021 (uint8_t) pSwitchChnInd->newChannelId;
12022 if (session->pConnectBssDesc) {
12023 session->pConnectBssDesc->channelId =
12024 (uint8_t) pSwitchChnInd->newChannelId;
12025 }
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053012026
Himanshu Agarwal71b93972018-06-14 01:16:01 +053012027 ds_params_ie = (tSirMacDsParamSetIE *)wlan_get_ie_ptr_from_eid(
12028 DOT11F_EID_DSPARAMS,
12029 (uint8_t *)session->pConnectBssDesc->
12030 ieFields,
12031 csr_get_ielen_from_bss_description(
12032 session->pConnectBssDesc));
12033 if (ds_params_ie)
12034 ds_params_ie->channelNumber =
12035 (uint8_t)pSwitchChnInd->newChannelId;
12036
12037 ht_info_ie = (tDot11fIEHTInfo *)wlan_get_ie_ptr_from_eid(
12038 DOT11F_EID_HTINFO,
12039 (uint8_t *)session->pConnectBssDesc->
12040 ieFields,
12041 csr_get_ielen_from_bss_description(
12042 session->pConnectBssDesc));
12043 if (ht_info_ie) {
12044 ht_info_ie->primaryChannel =
12045 (uint8_t)pSwitchChnInd->newChannelId;
12046 ht_info_ie->secondaryChannelOffset =
12047 pSwitchChnInd->chan_params.sec_ch_offset;
12048 }
12049
Jeff Johnson172237b2017-11-07 15:32:59 -080012050 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053012051 roamInfo.chan_info.chan_id = pSwitchChnInd->newChannelId;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +053012052 roamInfo.chan_info.ch_width =
12053 pSwitchChnInd->chan_params.ch_width;
12054 roamInfo.chan_info.sec_ch_offset =
12055 pSwitchChnInd->chan_params.sec_ch_offset;
12056 roamInfo.chan_info.band_center_freq1 =
12057 pSwitchChnInd->chan_params.center_freq_seg0;
12058 roamInfo.chan_info.band_center_freq2 =
12059 pSwitchChnInd->chan_params.center_freq_seg1;
bings58ce8622017-07-10 15:55:36 +080012060 if (CSR_IS_PHY_MODE_11ac(mac_ctx->roam.configParam.phyMode))
12061 roamInfo.mode = SIR_SME_PHY_MODE_VHT;
12062 else if (CSR_IS_PHY_MODE_11n(mac_ctx->roam.configParam.phyMode))
12063 roamInfo.mode = SIR_SME_PHY_MODE_HT;
12064 else
12065 roamInfo.mode = SIR_SME_PHY_MODE_LEGACY;
12066
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053012067 status = csr_roam_call_callback(mac_ctx, sessionId,
12068 &roamInfo, 0, eCSR_ROAM_STA_CHANNEL_SWITCH,
12069 eCSR_ROAM_RESULT_NONE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012070 }
12071}
12072
12073static void
12074csr_roam_chk_lnk_deauth_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12075{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012076 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012077 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012078 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012079 struct csr_roam_info *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012080 tSirSmeDeauthRsp *pDeauthRsp = (tSirSmeDeauthRsp *) msg_ptr;
Jeff Johnson172237b2017-11-07 15:32:59 -080012081 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012082
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012083 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012084 sme_debug("eWNI_SME_DEAUTH_RSP from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012085 sessionId = pDeauthRsp->sessionId;
12086 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12087 return;
12088 session = CSR_GET_SESSION(mac_ctx, sessionId);
12089 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
12090 roam_info_ptr = &roam_info;
12091 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053012092 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -080012093 &pDeauthRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012094 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
12095 roam_info_ptr->statusCode = pDeauthRsp->statusCode;
12096 status = csr_roam_call_callback(mac_ctx, sessionId,
12097 roam_info_ptr, 0,
12098 eCSR_ROAM_LOSTLINK,
12099 eCSR_ROAM_RESULT_FORCED);
12100 }
12101}
12102
12103static void
12104csr_roam_chk_lnk_disassoc_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12105{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012106 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012107 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012108 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012109 struct csr_roam_info *roam_info_ptr = NULL;
12110 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012111 /*
12112 * session id is invalid here so cant use it to access the array
12113 * curSubstate as index
12114 */
12115 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *) msg_ptr;
12116
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012117 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012118 sme_debug("eWNI_SME_DISASSOC_RSP from SME ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012119 sessionId = pDisassocRsp->sessionId;
12120 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12121 return;
12122 session = CSR_GET_SESSION(mac_ctx, sessionId);
12123 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
12124 roam_info_ptr = &roam_info;
12125 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053012126 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -080012127 &pDisassocRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012128 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
12129 roam_info_ptr->statusCode = pDisassocRsp->statusCode;
12130 status = csr_roam_call_callback(mac_ctx, sessionId,
12131 roam_info_ptr, 0,
12132 eCSR_ROAM_LOSTLINK,
12133 eCSR_ROAM_RESULT_FORCED);
12134 }
12135}
12136
12137#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12138static void
12139csr_roam_diag_mic_fail(tpAniSirGlobal mac_ctx, uint32_t sessionId)
12140{
12141 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
12142 host_event_wlan_security_payload_type);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012143 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012145 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012146 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012147 return;
12148 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012149 qdf_mem_set(&secEvent, sizeof(host_event_wlan_security_payload_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012150 0);
12151 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
12152 secEvent.encryptionModeMulticast =
12153 (uint8_t) diag_enc_type_from_csr_type(
12154 session->connectedProfile.mcEncryptionType);
12155 secEvent.encryptionModeUnicast =
12156 (uint8_t) diag_enc_type_from_csr_type(
12157 session->connectedProfile.EncryptionType);
12158 secEvent.authMode =
12159 (uint8_t) diag_auth_type_from_csr_type(
12160 session->connectedProfile.AuthType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012161 qdf_mem_copy(secEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012162 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012163 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12164}
12165#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12166
12167static void
12168csr_roam_chk_lnk_mic_fail_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12169{
12170 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012171 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012172 struct csr_roam_info *roam_info_ptr = NULL;
12173 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012174 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd) msg_ptr;
12175 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
12176
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012177 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012178 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda37c133b2015-09-24 16:14:15 -070012179 &pMicInd->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012180 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson172237b2017-11-07 15:32:59 -080012181 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012182 roam_info.u.pMICFailureInfo = &pMicInd->info;
12183 roam_info_ptr = &roam_info;
12184 if (pMicInd->info.multicast)
12185 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
12186 else
12187 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
12188 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
12189 eCSR_ROAM_MIC_ERROR_IND, result);
12190 }
12191#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12192 csr_roam_diag_mic_fail(mac_ctx, sessionId);
12193#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12194}
12195
12196static void
12197csr_roam_chk_lnk_pbs_probe_req_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12198{
12199 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012200 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012201 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012202 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd) msg_ptr;
12203
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012204 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012205 sme_debug("WPS PBC Probe request Indication from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012206
12207 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdad6673be2015-11-24 14:18:13 -080012208 &pProbeReqInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012209 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson172237b2017-11-07 15:32:59 -080012210 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012211 roam_info.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
12212 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
12213 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
12214 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
12215 }
12216}
12217
12218#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12219static void
12220csr_roam_diag_joined_new_bss(tpAniSirGlobal mac_ctx,
12221 tSirSmeNewBssInfo *pNewBss)
12222{
12223 host_log_ibss_pkt_type *pIbssLog;
12224 uint32_t bi;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012226 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12227 LOG_WLAN_IBSS_C);
12228 if (!pIbssLog)
12229 return;
12230 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
12231 if (pNewBss) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053012232 qdf_copy_macaddr(&pIbssLog->bssid, &pNewBss->bssId);
Arif Hussain186d7a02018-05-08 23:20:43 -070012233 if (pNewBss->ssId.length > HOST_LOG_MAX_SSID_SIZE)
12234 pNewBss->ssId.length = HOST_LOG_MAX_SSID_SIZE;
12235 qdf_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
12236 pNewBss->ssId.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012237 pIbssLog->operatingChannel = pNewBss->channelNumber;
12238 }
Jeff Johnsonc09caa42018-06-07 22:58:55 -070012239 if (QDF_IS_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012240 WNI_CFG_BEACON_INTERVAL,
12241 &bi)))
12242 /* U8 is not enough for beacon interval */
12243 pIbssLog->beaconInterval = (uint8_t) bi;
12244 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12245}
12246#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12247
12248static void
12249csr_roam_chk_lnk_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
12250 tSirSmeRsp *msg_ptr)
12251{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012252 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012253 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012254 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012255 struct csr_roam_info *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012256 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
Jeff Johnson172237b2017-11-07 15:32:59 -080012257 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012258 tSirSmeApNewCaps *pApNewCaps;
12259 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
12260 tSirMacAddr Broadcastaddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
12261 tSirSmeNewBssInfo *pNewBss;
12262 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
12263
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012264 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012265 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *) msg_ptr;
12266 switch (pStatusChangeMsg->statusChangeCode) {
12267 case eSIR_SME_IBSS_ACTIVE:
12268 sessionId = csr_find_ibss_session(mac_ctx);
12269 if (CSR_SESSION_ID_INVALID == sessionId)
12270 break;
12271 session = CSR_GET_SESSION(mac_ctx, sessionId);
12272 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012273 sme_err("session %d not found",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012274 sessionId);
12275 return;
12276 }
12277 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
12278 if (session->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012279 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012280 session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012281 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012282 roam_info.u.pConnectedProfile =
12283 &session->connectedProfile;
12284 roam_info_ptr = &roam_info;
12285 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012286 sme_err("CSR: connected BSS is empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012287 }
12288 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
12289 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
12290 break;
12291
12292 case eSIR_SME_IBSS_INACTIVE:
12293 sessionId = csr_find_ibss_session(mac_ctx);
12294 if (CSR_SESSION_ID_INVALID != sessionId) {
12295 session = CSR_GET_SESSION(mac_ctx, sessionId);
12296 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012297 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012298 return;
12299 }
12300 session->connectState =
12301 eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
12302 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
12303 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
12304 }
12305 break;
12306
12307 case eSIR_SME_JOINED_NEW_BSS:
12308 /* IBSS coalescing. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012309 sme_debug("CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012310 sessionId = csr_find_ibss_session(mac_ctx);
12311 if (CSR_SESSION_ID_INVALID == sessionId)
12312 break;
12313 session = CSR_GET_SESSION(mac_ctx, sessionId);
12314 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012315 sme_err("session %d not found",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012316 sessionId);
12317 return;
12318 }
12319 /* update the connection state information */
12320 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
12321#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12322 csr_roam_diag_joined_new_bss(mac_ctx, pNewBss);
12323#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12324 csr_roam_update_connected_profile_from_new_bss(mac_ctx,
12325 sessionId,
12326 pNewBss);
12327
12328 if ((eCSR_ENCRYPT_TYPE_NONE ==
12329 session->connectedProfile.EncryptionType)) {
12330 csr_roam_issue_set_context_req(mac_ctx,
12331 sessionId,
12332 session->connectedProfile.EncryptionType,
12333 session->pConnectBssDesc,
12334 &Broadcastaddr, false, false,
12335 eSIR_TX_RX, 0, 0, NULL, 0);
12336 }
12337 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
12338 roamStatus = eCSR_ROAM_IBSS_IND;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012339 qdf_mem_copy(&roam_info.bssid, &pNewBss->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012340 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012341 roam_info_ptr = &roam_info;
12342 /* This BSSID is the real BSSID, save it */
12343 if (session->pConnectBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012344 qdf_mem_copy(session->pConnectBssDesc->bssId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012345 &pNewBss->bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012346 break;
12347
12348 /*
12349 * detection by LIM that the capabilities of the associated
12350 * AP have changed.
12351 */
12352 case eSIR_SME_AP_CAPS_CHANGED:
12353 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012354 sme_debug("CSR handling eSIR_SME_AP_CAPS_CHANGED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012355 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda26ebb192015-09-24 15:12:09 -070012356 &pApNewCaps->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012357 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012358 break;
12359 if (eCSR_ROAMING_STATE_JOINED ==
Jeff Johnson64c2b552018-06-09 22:51:38 -070012360 sme_get_current_roam_state(MAC_HANDLE(mac_ctx), sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012361 && ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC
12362 == mac_ctx->roam.curSubState[sessionId])
12363 || (eCSR_ROAM_SUBSTATE_NONE ==
12364 mac_ctx->roam.curSubState[sessionId])
12365 || (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC
12366 == mac_ctx->roam.curSubState[sessionId])
12367 || (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC ==
12368 mac_ctx->roam.curSubState[sessionId]))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012369 sme_warn("Calling csr_roam_disconnect_internal");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012370 csr_roam_disconnect_internal(mac_ctx, sessionId,
12371 eCSR_DISCONNECT_REASON_UNSPECIFIED);
12372 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012373 sme_warn("Skipping the new scan as CSR is in state: %s and sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012374 mac_trace_getcsr_roam_state(
12375 mac_ctx->roam.curState[sessionId]),
12376 mac_trace_getcsr_roam_sub_state(
12377 mac_ctx->roam.curSubState[sessionId]));
12378 /* We ignore the caps change event if CSR is not in full
12379 * connected state. Send one event to PE to reset
12380 * limSentCapsChangeNtf Once limSentCapsChangeNtf set
12381 * 0, lim can send sub sequent CAPS change event
12382 * otherwise lim cannot send any CAPS change events to
12383 * SME
12384 */
12385 csr_send_reset_ap_caps_changed(mac_ctx,
12386 &pApNewCaps->bssId);
12387 }
12388 break;
12389
12390 default:
12391 roamStatus = eCSR_ROAM_FAILED;
12392 result = eCSR_ROAM_RESULT_NONE;
12393 break;
12394 } /* end switch on statusChangeCode */
12395 if (eCSR_ROAM_RESULT_NONE != result) {
12396 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
12397 roamStatus, result);
12398 }
12399}
12400
12401static void
12402csr_roam_chk_lnk_ibss_new_peer_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12403{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012404 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012405 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012406 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012407 struct csr_roam_info *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012408 tSmeIbssPeerInd *pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
Jeff Johnson172237b2017-11-07 15:32:59 -080012409 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012410#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12411 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012412
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012413 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12414 LOG_WLAN_IBSS_C);
12415 if (pIbssLog) {
12416 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Anurag Chouhanc5548422016-02-24 18:33:27 +053012417 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080012418 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012419 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12420 }
12421#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12422
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012423 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012424 sessionId = csr_find_ibss_session(mac_ctx);
12425 if (CSR_SESSION_ID_INVALID == sessionId)
12426 return;
12427 session = CSR_GET_SESSION(mac_ctx, sessionId);
12428 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012429 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012430 return;
12431 }
12432 /*
12433 * Issue the set Context request to LIM to establish the Unicast STA
12434 * context for the new peer...
12435 */
12436 if (!session->pConnectBssDesc) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012437 sme_warn("CSR: connected BSS is empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012438 goto callback_and_free;
12439 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053012440 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012441 qdf_mem_copy(&roam_info.bssid, session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012442 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012443 if (pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012444 roam_info.pbFrames = qdf_mem_malloc((pIbssPeerInd->mesgLen -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012445 sizeof(tSmeIbssPeerInd)));
12446 if (NULL == roam_info.pbFrames) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012447 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012448 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012449 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012450 roam_info.nBeaconLength = pIbssPeerInd->mesgLen -
12451 sizeof(tSmeIbssPeerInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012452 qdf_mem_copy(roam_info.pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012453 ((uint8_t *) pIbssPeerInd) +
12454 sizeof(tSmeIbssPeerInd),
12455 roam_info.nBeaconLength);
12456 }
12457 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012458 roam_info.pBssDesc = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012459 session->pConnectBssDesc->length);
12460 if (NULL == roam_info.pBssDesc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012461 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012462 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012463 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012464 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012465 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012466 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012467 status = QDF_STATUS_SUCCESS;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012468 qdf_mem_copy(roam_info.pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012469 session->pConnectBssDesc,
12470 session->pConnectBssDesc->length);
12471 roam_info_ptr = &roam_info;
12472 }
12473 } else {
12474 roam_info_ptr = &roam_info;
12475 }
12476 if ((eCSR_ENCRYPT_TYPE_NONE ==
12477 session->connectedProfile.EncryptionType)) {
12478 /* NO keys. these key parameters don't matter */
12479 csr_roam_issue_set_context_req(mac_ctx, sessionId,
12480 session->connectedProfile.EncryptionType,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080012481 session->pConnectBssDesc,
12482 &pIbssPeerInd->peer_addr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012483 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
12484 }
12485
12486callback_and_free:
12487 /* send up the sec type for the new peer */
12488 if (roam_info_ptr)
12489 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
12490 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
12491 eCSR_ROAM_CONNECT_STATUS_UPDATE,
12492 eCSR_ROAM_RESULT_IBSS_NEW_PEER);
12493 if (roam_info_ptr) {
12494 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012495 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012496 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012497 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012498 }
12499}
12500
12501static void
12502csr_roam_chk_lnk_ibss_peer_departed_ind(tpAniSirGlobal mac_ctx,
12503 tSirSmeRsp *msg_ptr)
12504{
12505 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson172237b2017-11-07 15:32:59 -080012506 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012507 tSmeIbssPeerInd *pIbssPeerInd;
12508
12509 if (NULL == msg_ptr) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012510 sme_err("IBSS peer ind. message is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012511 return;
12512 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012513 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012514 pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
12515 sessionId = csr_find_ibss_session(mac_ctx);
12516 if (CSR_SESSION_ID_INVALID != sessionId) {
12517#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12518 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012519
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012520 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12521 LOG_WLAN_IBSS_C);
12522 if (pIbssLog) {
12523 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
12524 if (pIbssPeerInd) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053012525 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080012526 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012527 }
12528 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12529 }
12530#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012531 sme_debug("CSR: Peer departed notification from LIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012532 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053012533 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012534 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
12535 eCSR_ROAM_CONNECT_STATUS_UPDATE,
12536 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
12537 }
12538}
12539
12540#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12541static void
12542csr_roam_diag_set_ctx_rsp(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012543 struct csr_roam_session *session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012544 tSirSmeSetContextRsp *pRsp)
12545{
12546 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
12547 host_event_wlan_security_payload_type);
12548 if (eCSR_ENCRYPT_TYPE_NONE ==
12549 session->connectedProfile.EncryptionType)
12550 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012551 qdf_mem_set(&setKeyEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012552 sizeof(host_event_wlan_security_payload_type), 0);
Anurag Chouhanc5548422016-02-24 18:33:27 +053012553 if (qdf_is_macaddr_group(&pRsp->peer_macaddr))
Abhishek Singh7a995582016-04-27 13:53:36 +053012554 setKeyEvent.eventId =
12555 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012556 else
Abhishek Singh7a995582016-04-27 13:53:36 +053012557 setKeyEvent.eventId =
12558 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012559 setKeyEvent.encryptionModeMulticast =
12560 (uint8_t) diag_enc_type_from_csr_type(
12561 session->connectedProfile.mcEncryptionType);
12562 setKeyEvent.encryptionModeUnicast =
12563 (uint8_t) diag_enc_type_from_csr_type(
12564 session->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012565 qdf_mem_copy(setKeyEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012566 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012567 setKeyEvent.authMode =
12568 (uint8_t) diag_auth_type_from_csr_type(
12569 session->connectedProfile.AuthType);
12570 if (eSIR_SME_SUCCESS != pRsp->statusCode)
12571 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
12572 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
12573}
12574#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12575
12576static void
12577csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12578{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012579 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012580 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012581 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012582 struct csr_roam_info *roam_info_ptr = NULL;
12583 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012584 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
12585 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *) msg_ptr;
Krunal Sonid3676732017-05-10 14:12:18 -070012586
12587
12588 if (!pRsp) {
12589 sme_err("set key response is NULL");
12590 return;
12591 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012592
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012593 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Krunal Sonid3676732017-05-10 14:12:18 -070012594 sessionId = pRsp->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012595 session = CSR_GET_SESSION(mac_ctx, sessionId);
12596 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012597 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012598 return;
12599 }
12600#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12601 csr_roam_diag_set_ctx_rsp(mac_ctx, session, pRsp);
12602#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12603 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sessionId)) {
12604 csr_roam_stop_wait_for_key_timer(mac_ctx);
12605 /* We are done with authentication, whethere succeed or not */
12606 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
12607 sessionId);
12608 /* We do it here because this linkup function is not called
12609 * after association when a key needs to be set.
12610 */
12611 if (csr_is_conn_state_connected_infra(mac_ctx, sessionId))
12612 csr_roam_link_up(mac_ctx,
12613 session->connectedProfile.bssid);
12614 }
12615 if (eSIR_SME_SUCCESS == pRsp->statusCode) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053012616 qdf_copy_macaddr(&roam_info.peerMac, &pRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012617 /* Make sure we install the GTK before indicating to HDD as
12618 * authenticated. This is to prevent broadcast packets go out
12619 * after PTK and before GTK.
12620 */
Anurag Chouhanc5548422016-02-24 18:33:27 +053012621 if (qdf_is_macaddr_broadcast(&pRsp->peer_macaddr)) {
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012622 /*
12623 * OBSS SCAN Indication will be sent to Firmware
12624 * to start OBSS Scan
12625 */
Liangwei Dong0da14262018-07-03 03:30:23 -040012626 if (mac_ctx->obss_scan_offload &&
12627 CSR_IS_CHANNEL_24GHZ(
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012628 session->connectedProfile.operationChannel)
12629 && (session->connectState ==
12630 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
12631 && session->pCurRoamProfile
12632 && ((QDF_P2P_CLIENT_MODE ==
12633 session->pCurRoamProfile->csrPersona)
12634 || (QDF_STA_MODE ==
12635 session->pCurRoamProfile->csrPersona))) {
12636 struct sme_obss_ht40_scanind_msg *msg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012637
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012638 msg = qdf_mem_malloc(sizeof(
12639 struct sme_obss_ht40_scanind_msg));
Naveen Rawat63ad2b62016-11-17 11:38:21 -080012640 if (NULL == msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012641 sme_err("Malloc failed");
Krunal Sonid3676732017-05-10 14:12:18 -070012642 return;
Naveen Rawat63ad2b62016-11-17 11:38:21 -080012643 }
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012644 msg->msg_type = eWNI_SME_HT40_OBSS_SCAN_IND;
12645 msg->length =
12646 sizeof(struct sme_obss_ht40_scanind_msg);
12647 qdf_copy_macaddr(&msg->mac_addr,
12648 &session->connectedProfile.bssid);
Rajeev Kumard138ac52017-01-30 18:38:37 -080012649 status = umac_send_mb_message_to_mac(msg);
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012650 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012651 result = eCSR_ROAM_RESULT_AUTHENTICATED;
12652 } else {
12653 result = eCSR_ROAM_RESULT_NONE;
12654 }
12655 roam_info_ptr = &roam_info;
12656 } else {
12657 result = eCSR_ROAM_RESULT_FAILURE;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012658 sme_err(
12659 "CSR: setkey command failed(err=%d) PeerMac "
12660 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080012661 pRsp->statusCode,
12662 MAC_ADDR_ARRAY(pRsp->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012663 }
Krunal Sonid3676732017-05-10 14:12:18 -070012664 /* keeping roam_id = 0 as nobody is using roam_id for set_key */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012665 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
Krunal Sonid3676732017-05-10 14:12:18 -070012666 0, eCSR_ROAM_SET_KEY_COMPLETE, result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012667 /* Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
12668 * can go ahead and initiate the TSPEC if any are pending
12669 */
12670 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
12671 SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
12672#ifdef FEATURE_WLAN_ESE
12673 /* Send Adjacent AP repot to new AP. */
12674 if (result == eCSR_ROAM_RESULT_AUTHENTICATED
12675 && session->isPrevApInfoValid
12676 && session->connectedProfile.isESEAssoc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012677 csr_send_ese_adjacent_ap_rep_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012678 session->isPrevApInfoValid = false;
12679 }
12680#endif
Krunal Sonia8270f52017-02-23 19:51:25 -080012681 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012682}
12683
12684
12685static void
12686csr_roam_chk_lnk_max_assoc_exceeded(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12687{
12688 uint32_t sessionId = CSR_SESSION_ID_INVALID;
12689 tSmeMaxAssocInd *pSmeMaxAssocInd;
Jeff Johnson172237b2017-11-07 15:32:59 -080012690 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012691
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012692 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012693 pSmeMaxAssocInd = (tSmeMaxAssocInd *) msg_ptr;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012694 sme_debug(
12695 "max assoc have been reached, new peer cannot be accepted");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012696 sessionId = pSmeMaxAssocInd->sessionId;
12697 roam_info.sessionId = sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053012698 qdf_copy_macaddr(&roam_info.peerMac, &pSmeMaxAssocInd->peer_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012699 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
12700 eCSR_ROAM_INFRA_IND,
12701 eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
12702}
12703
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012704void csr_roam_check_for_link_status_change(tpAniSirGlobal pMac,
12705 tSirSmeRsp *pSirMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012706{
12707 if (NULL == pSirMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012708 sme_err("pSirMsg is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012709 return;
12710 }
12711 switch (pSirMsg->messageType) {
12712 case eWNI_SME_ASSOC_IND:
12713 csr_roam_chk_lnk_assoc_ind(pMac, pSirMsg);
12714 break;
12715 case eWNI_SME_DISASSOC_IND:
12716 csr_roam_chk_lnk_disassoc_ind(pMac, pSirMsg);
12717 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053012718 case eWNI_SME_DISCONNECT_DONE_IND:
12719 csr_roam_send_disconnect_done_indication(pMac, pSirMsg);
12720 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012721 case eWNI_SME_DEAUTH_IND:
12722 csr_roam_chk_lnk_deauth_ind(pMac, pSirMsg);
12723 break;
12724 case eWNI_SME_SWITCH_CHL_IND:
12725 csr_roam_chk_lnk_swt_ch_ind(pMac, pSirMsg);
12726 break;
12727 case eWNI_SME_DEAUTH_RSP:
12728 csr_roam_chk_lnk_deauth_rsp(pMac, pSirMsg);
12729 break;
12730 case eWNI_SME_DISASSOC_RSP:
12731 csr_roam_chk_lnk_disassoc_rsp(pMac, pSirMsg);
12732 break;
12733 case eWNI_SME_MIC_FAILURE_IND:
12734 csr_roam_chk_lnk_mic_fail_ind(pMac, pSirMsg);
12735 break;
12736 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
12737 csr_roam_chk_lnk_pbs_probe_req_ind(pMac, pSirMsg);
12738 break;
12739 case eWNI_SME_WM_STATUS_CHANGE_NTF:
12740 csr_roam_chk_lnk_wm_status_change_ntf(pMac, pSirMsg);
12741 break;
12742 case eWNI_SME_IBSS_NEW_PEER_IND:
12743 csr_roam_chk_lnk_ibss_new_peer_ind(pMac, pSirMsg);
12744 break;
12745 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
12746 csr_roam_chk_lnk_ibss_peer_departed_ind(pMac, pSirMsg);
12747 break;
12748 case eWNI_SME_SETCONTEXT_RSP:
12749 csr_roam_chk_lnk_set_ctx_rsp(pMac, pSirMsg);
12750 break;
12751 case eWNI_SME_GET_STATISTICS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012752 sme_debug("Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012753 csr_roam_stats_rsp_processor(pMac, pSirMsg);
12754 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080012755#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012756 case eWNI_SME_GET_TSM_STATS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012757 sme_debug("TSM Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012758 csr_tsm_stats_rsp_processor(pMac, pSirMsg);
12759 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080012760#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012761 case eWNI_SME_GET_RSSI_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012762 sme_debug("GetRssiReq from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012763 csr_update_rssi(pMac, pSirMsg);
12764 break;
12765 case eWNI_SME_GET_SNR_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012766 sme_debug("GetSnrReq from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012767 csr_update_snr(pMac, pSirMsg);
12768 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012769 case eWNI_SME_FT_PRE_AUTH_RSP:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012770 csr_roam_ft_pre_auth_rsp_processor(pMac,
12771 (tpSirFTPreAuthRsp) pSirMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012772 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012773 case eWNI_SME_MAX_ASSOC_EXCEEDED:
12774 csr_roam_chk_lnk_max_assoc_exceeded(pMac, pSirMsg);
12775 break;
12776 case eWNI_SME_CANDIDATE_FOUND_IND:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012777 sme_debug("Candidate found indication from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012778 csr_neighbor_roam_candidate_found_ind_hdlr(pMac, pSirMsg);
12779 break;
12780 case eWNI_SME_HANDOFF_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012781 sme_debug("Handoff Req from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012782 csr_neighbor_roam_handoff_req_hdlr(pMac, pSirMsg);
12783 break;
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +053012784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012785 default:
12786 break;
12787 } /* end switch on message type */
12788}
12789
12790void csr_call_roaming_completion_callback(tpAniSirGlobal pMac,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012791 struct csr_roam_session *pSession,
Jeff Johnson172237b2017-11-07 15:32:59 -080012792 struct csr_roam_info *roam_info,
12793 uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012794 eCsrRoamResult roamResult)
12795{
12796 if (pSession) {
12797 if (pSession->bRefAssocStartCnt) {
12798 pSession->bRefAssocStartCnt--;
12799
12800 if (0 != pSession->bRefAssocStartCnt) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012801 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012802 return;
12803 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012804 /* Need to call association_completion because there
12805 * is an assoc_start pending.
12806 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012807 csr_roam_call_callback(pMac, pSession->sessionId, NULL,
12808 roamId,
12809 eCSR_ROAM_ASSOCIATION_COMPLETION,
12810 eCSR_ROAM_RESULT_FAILURE);
12811 }
Jeff Johnsoneddf5442017-10-04 10:55:53 -070012812 csr_roam_call_callback(pMac, pSession->sessionId, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012813 roamId, eCSR_ROAM_ROAMING_COMPLETION,
12814 roamResult);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012815 } else
12816 sme_err("pSession is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012817}
12818
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012819/* return a bool to indicate whether roaming completed or continue. */
12820bool csr_roam_complete_roaming(tpAniSirGlobal pMac, uint32_t sessionId,
12821 bool fForce, eCsrRoamResult roamResult)
12822{
12823 bool fCompleted = true;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012824 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012825
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012826 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012827 sme_err("session %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012828 return false;
12829 }
12830 /* Check whether time is up */
12831 if (pSession->fCancelRoaming || fForce ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012832 eCsrReassocRoaming == pSession->roamingReason ||
12833 eCsrDynamicRoaming == pSession->roamingReason) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012834 sme_debug("indicates roaming completion");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012835 if (pSession->fCancelRoaming
12836 && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012837 /* roaming is cancelled, tell HDD to indicate disconnect
12838 * Because LIM overload deauth_ind for both deauth frame
12839 * and missed beacon we need to use this logic to
12840 * detinguish it. For missed beacon, LIM set reason to
12841 * be eSIR_BEACON_MISSED
12842 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012843 if (eSIR_BEACON_MISSED == pSession->roamingStatusCode) {
12844 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
12845 } else if (eCsrLostlinkRoamingDisassoc ==
12846 pSession->roamingReason) {
12847 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
12848 } else if (eCsrLostlinkRoamingDeauth ==
12849 pSession->roamingReason) {
12850 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
12851 } else {
12852 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
12853 }
12854 }
12855 csr_call_roaming_completion_callback(pMac, pSession, NULL, 0,
12856 roamResult);
12857 pSession->roamingReason = eCsrNotRoaming;
12858 } else {
12859 pSession->roamResult = roamResult;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012860 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_roaming_timer(pMac,
12861 sessionId, QDF_MC_TIMER_TO_SEC_UNIT))) {
12862 csr_call_roaming_completion_callback(pMac, pSession,
12863 NULL, 0, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012864 pSession->roamingReason = eCsrNotRoaming;
12865 } else {
12866 fCompleted = false;
12867 }
12868 }
12869 return fCompleted;
12870}
12871
12872void csr_roam_cancel_roaming(tpAniSirGlobal pMac, uint32_t sessionId)
12873{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012874 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012875
12876 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012877 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012878 return;
12879 }
12880
12881 if (CSR_IS_ROAMING(pSession)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012882 sme_debug("Cancel roaming");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012883 pSession->fCancelRoaming = true;
12884 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
12885 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012886 /* No need to do anything in here because the handler
12887 * takes care of it
12888 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012889 } else {
12890 eCsrRoamResult roamResult =
12891 CSR_IS_LOSTLINK_ROAMING(pSession->
12892 roamingReason) ?
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012893 eCSR_ROAM_RESULT_LOSTLINK :
12894 eCSR_ROAM_RESULT_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012895 /* Roaming is stopped after here */
12896 csr_roam_complete_roaming(pMac, sessionId, true,
12897 roamResult);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012898 /* Since CSR may be in lostlink roaming situation,
12899 * abort all roaming related activities
12900 */
Abhishek Singh9fabbbb2018-01-29 17:38:36 +053012901 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012902 csr_roam_stop_roaming_timer(pMac, sessionId);
12903 }
12904 }
12905}
12906
12907void csr_roam_roaming_timer_handler(void *pv)
12908{
12909 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
12910 tpAniSirGlobal pMac = pInfo->pMac;
12911 uint32_t sessionId = pInfo->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012912 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012913
12914 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012915 sme_err(" session %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012916 return;
12917 }
12918
12919 if (false == pSession->fCancelRoaming) {
Abhinav Kumarf9989582018-02-06 17:42:22 +053012920 csr_call_roaming_completion_callback(pMac, pSession,
12921 NULL, 0,
12922 pSession->roamResult);
12923 pSession->roamingReason = eCsrNotRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012924 }
12925}
12926
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012927/**
12928 * csr_roam_roaming_offload_timeout_handler() - Handler for roaming failure
12929 * @timer_data: Carries the mac_ctx and session info
12930 *
12931 * This function would be invoked when the roaming_offload_timer expires.
12932 * The timer is waiting in anticipation of a related roaming event from
12933 * the firmware after receiving the ROAM_START event.
12934 *
12935 * Return: None
12936 */
12937void csr_roam_roaming_offload_timeout_handler(void *timer_data)
12938{
12939 tCsrTimerInfo *timer_info = (tCsrTimerInfo *) timer_data;
12940
12941 if (timer_info) {
12942 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012943 "LFR3:roaming offload timer expired, session: %d",
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012944 timer_info->sessionId);
12945 } else {
12946 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012947 "Invalid Session");
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012948 return;
12949 }
12950 csr_roam_disconnect(timer_info->pMac, timer_info->sessionId,
12951 eCSR_DISCONNECT_REASON_UNSPECIFIED);
12952}
12953
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012954QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012955 uint32_t interval)
12956{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012957 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012958 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012959
12960 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012961 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012962 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012963 }
12964
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012965 sme_debug("csrScanStartRoamingTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012966 pSession->roamingTimerInfo.sessionId = (uint8_t) sessionId;
Anurag Chouhan210db072016-02-22 18:42:15 +053012967 status = qdf_mc_timer_start(&pSession->hTimerRoaming,
12968 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012969
12970 return status;
12971}
12972
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012973QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac,
12974 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012975{
Anurag Chouhan210db072016-02-22 18:42:15 +053012976 return qdf_mc_timer_stop
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012977 (&pMac->roam.roamSession[sessionId].hTimerRoaming);
12978}
12979
12980void csr_roam_wait_for_key_time_out_handler(void *pv)
12981{
12982 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
12983 tpAniSirGlobal pMac = pInfo->pMac;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012984 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
12985 pInfo->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012986 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012987
12988 if (pSession == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012989 sme_err("session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012990 return;
12991 }
12992
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012993 sme_debug("WaitForKey timer expired in state: %s sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012994 mac_trace_get_neighbour_roam_state(pMac->roam.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012995 neighborRoamInfo[pInfo->sessionId].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012996 neighborRoamState),
12997 mac_trace_getcsr_roam_sub_state(pMac->roam.
12998 curSubState[pInfo->sessionId]));
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +053012999 spin_lock(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013000 if (CSR_IS_WAIT_FOR_KEY(pMac, pInfo->sessionId)) {
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +053013001 /* Change the substate so command queue is unblocked. */
13002 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
13003 pMac->roam.curSubState[pInfo->sessionId] =
13004 eCSR_ROAM_SUBSTATE_NONE;
13005 spin_unlock(&pMac->roam.roam_state_lock);
13006
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013007 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
13008 pInfo->sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013009 /*
13010 * Enable heartbeat timer when hand-off is in progress
13011 * and Key Wait timer expired.
13012 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013013 sme_debug("Enabling HB timer after WaitKey expiry nHBCount: %d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013014 pMac->roam.configParam.HeartbeatThresh24);
13015 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013016 pMac->roam.configParam.HeartbeatThresh24);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013017 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013018 sme_debug("SME pre-auth state timeout");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013020 if (csr_is_conn_state_connected_infra(pMac, pInfo->sessionId)) {
13021 csr_roam_link_up(pMac,
13022 pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013023 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013024 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013025 csr_roam_disconnect(pMac, pInfo->sessionId,
13026 eCSR_DISCONNECT_REASON_UNSPECIFIED);
13027 sme_release_global_lock(&pMac->sme);
13028 }
13029 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013030 sme_err("session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013031 }
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +053013032 } else {
13033 spin_unlock(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013034 }
13035
13036}
13037
Yingying Tang87f01392017-03-22 17:29:54 +080013038#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070013039/**
13040 * csr_roam_roaming_offload_timer_action() - API to start/stop the timer
13041 * @mac_ctx: MAC Context
13042 * @interval: Value to be set for the timer
13043 * @session_id: Session on which the timer should be operated
13044 * @action: Start/Stop action for the timer
13045 *
13046 * API to start/stop the roaming offload timer
13047 *
13048 * Return: None
13049 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013050void csr_roam_roaming_offload_timer_action(
13051 tpAniSirGlobal mac_ctx, uint32_t interval, uint8_t session_id,
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070013052 uint8_t action)
13053{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013054 struct csr_roam_session *csr_session = CSR_GET_SESSION(mac_ctx,
13055 session_id);
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070013056
13057 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013058 ("LFR3: timer action %d, session %d, intvl %d"),
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070013059 action, session_id, interval);
13060 if (mac_ctx) {
13061 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13062 } else {
13063 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013064 ("LFR3: Invalid MAC Context"));
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070013065 return;
13066 }
13067 if (!csr_session) {
13068 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013069 ("LFR3: session %d not found"), session_id);
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070013070 return;
13071 }
13072 csr_session->roamingTimerInfo.sessionId = (uint8_t) session_id;
13073 if (action == ROAMING_OFFLOAD_TIMER_START)
13074 qdf_mc_timer_start(&csr_session->roaming_offload_timer,
13075 interval / QDF_MC_TIMER_TO_MS_UNIT);
13076 if (action == ROAMING_OFFLOAD_TIMER_STOP)
13077 qdf_mc_timer_stop(&csr_session->roaming_offload_timer);
13078
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070013079}
Yingying Tang87f01392017-03-22 17:29:54 +080013080#endif
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070013081
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013082static QDF_STATUS csr_roam_start_wait_for_key_timer(
13083 tpAniSirGlobal pMac, uint32_t interval)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013084{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013085 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013086 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
13087 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
13088 sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013089 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080013090 pMac->roam.WaitForKeyTimerInfo.
13091 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013092 /* Disable heartbeat timer when hand-off is in progress */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013093 sme_debug("disabling HB timer in state: %s sub-state: %s",
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080013094 mac_trace_get_neighbour_roam_state(
13095 pNeighborRoamInfo->neighborRoamState),
13096 mac_trace_getcsr_roam_sub_state(
13097 pMac->roam.curSubState[pMac->roam.
13098 WaitForKeyTimerInfo.sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013099 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0);
13100 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013101 sme_debug("csrScanStartWaitForKeyTimer");
Anurag Chouhan210db072016-02-22 18:42:15 +053013102 status = qdf_mc_timer_start(&pMac->roam.hTimerWaitForKey,
13103 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013104
13105 return status;
13106}
13107
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013108QDF_STATUS csr_roam_stop_wait_for_key_timer(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013109{
13110 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
13111 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
13112 sessionId];
13113
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013114 sme_debug("WaitForKey timer stopped in state: %s sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013115 mac_trace_get_neighbour_roam_state(pNeighborRoamInfo->
13116 neighborRoamState),
13117 mac_trace_getcsr_roam_sub_state(pMac->roam.
13118 curSubState[pMac->roam.
13119 WaitForKeyTimerInfo.
13120 sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013121 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013122 pMac->roam.WaitForKeyTimerInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013123 sessionId)) {
13124 /*
13125 * Enable heartbeat timer when hand-off is in progress
13126 * and Key Wait timer got stopped for some reason
13127 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013128 sme_debug("Enabling HB timer after WaitKey stop nHBCount: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013129 pMac->roam.configParam.HeartbeatThresh24);
13130 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
13131 pMac->roam.configParam.HeartbeatThresh24);
13132 }
Anurag Chouhan210db072016-02-22 18:42:15 +053013133 return qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013134}
13135
13136void csr_roam_completion(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson172237b2017-11-07 15:32:59 -080013137 struct csr_roam_info *roam_info, tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013138 eCsrRoamResult roamResult, bool fSuccess)
13139{
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013140 eRoamCmdStatus roamStatus = csr_get_roam_complete_status(pMac,
13141 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013142 uint32_t roamId = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013143 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013144
13145 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013146 sme_err("session: %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013147 return;
13148 }
13149
13150 if (pCommand) {
13151 roamId = pCommand->u.roamCmd.roamId;
13152 if (sessionId != pCommand->sessionId) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013153 QDF_ASSERT(sessionId == pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013154 return;
13155 }
13156 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013157 if (eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013158 /* if success, force roaming completion */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013159 csr_roam_complete_roaming(pMac, sessionId, fSuccess,
13160 roamResult);
13161 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013162 if (pSession->bRefAssocStartCnt != 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013163 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013164 return;
13165 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013166 sme_debug("indicates association completion roamResult: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013167 roamResult);
Jeff Johnsoneddf5442017-10-04 10:55:53 -070013168 csr_roam_call_callback(pMac, sessionId, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013169 roamStatus, roamResult);
13170 }
13171}
13172
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013173static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013174QDF_STATUS csr_roam_lost_link(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013175 uint32_t type, tSirSmeRsp *pSirMsg)
13176{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013177 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013178 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
13179 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
13180 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Jeff Johnson172237b2017-11-07 15:32:59 -080013181 struct csr_roam_info roamInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013182 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013183
13184 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013185 sme_err("session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013186 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013187 }
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053013188 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013189 if (eWNI_SME_DISASSOC_IND == type) {
13190 result = eCSR_ROAM_RESULT_DISASSOC_IND;
13191 pDisassocIndMsg = (tSirSmeDisassocInd *) pSirMsg;
13192 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
13193 pSession->joinFailStatusCode.reasonCode =
13194 pDisassocIndMsg->reasonCode;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053013195
13196 qdf_copy_macaddr(&roamInfo.peerMac,
13197 &pDisassocIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013198 } else if (eWNI_SME_DEAUTH_IND == type) {
13199 result = eCSR_ROAM_RESULT_DEAUTH_IND;
13200 pDeauthIndMsg = (tSirSmeDeauthInd *) pSirMsg;
13201 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +053013202 pSession->joinFailStatusCode.reasonCode =
13203 pDeauthIndMsg->reasonCode;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053013204
13205 qdf_copy_macaddr(&roamInfo.peerMac,
13206 &pDeauthIndMsg->peer_macaddr);
13207
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013208 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013209 sme_warn("gets an unknown type (%d)", type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013210 result = eCSR_ROAM_RESULT_NONE;
13211 pSession->joinFailStatusCode.reasonCode = 1;
13212 }
13213
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053013214 if (type == eWNI_SME_DISASSOC_IND || type == eWNI_SME_DEAUTH_IND) {
13215 struct sir_peer_info_req req;
13216
13217 req.sessionid = sessionId;
13218 req.peer_macaddr = roamInfo.peerMac;
13219 sme_get_peer_stats(pMac, req);
13220 }
13221 csr_roam_call_callback(pMac, sessionId, NULL, 0,
13222 eCSR_ROAM_LOSTLINK_DETECTED, result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013223
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013224 if (eWNI_SME_DISASSOC_IND == type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013225 status = csr_send_mb_disassoc_cnf_msg(pMac, pDisassocIndMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013226 else if (eWNI_SME_DEAUTH_IND == type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013227 status = csr_send_mb_deauth_cnf_msg(pMac, pDeauthIndMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013229 /* prepare to tell HDD to disconnect */
Jeff Johnson172237b2017-11-07 15:32:59 -080013230 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013231 roamInfo.statusCode = (tSirResultCodes) pSession->roamingStatusCode;
13232 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
13233 if (eWNI_SME_DISASSOC_IND == type) {
13234 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053013235 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080013236 &pDisassocIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013237 roamInfo.staId = (uint8_t) pDisassocIndMsg->staId;
13238 roamInfo.reasonCode = pDisassocIndMsg->reasonCode;
13239 } else if (eWNI_SME_DEAUTH_IND == type) {
13240 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053013241 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080013242 &pDeauthIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013243 roamInfo.staId = (uint8_t) pDeauthIndMsg->staId;
13244 roamInfo.reasonCode = pDeauthIndMsg->reasonCode;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -080013245 roamInfo.rxRssi = pDeauthIndMsg->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013246 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013247 sme_debug("roamInfo.staId: %d", roamInfo.staId);
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -080013248/* Dont initiate internal driver based roaming after disconnection*/
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013249 return status;
13250}
13251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013252
Himanshu Agarwald519b4a2018-03-27 15:36:09 +053013253void csr_roam_wm_status_change_complete(tpAniSirGlobal pMac,
13254 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013255{
13256 tListElem *pEntry;
13257 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013258
Krunal Sonia8270f52017-02-23 19:51:25 -080013259 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013260 if (pEntry) {
13261 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
13262 if (eSmeCommandWmStatusChange == pCommand->command) {
13263 /* Nothing to process in a Lost Link completion.... It just kicks off a */
13264 /* roaming sequence. */
Krunal Soni72dba662017-02-15 20:13:17 -080013265 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013266 LL_ACCESS_LOCK)) {
Krunal Sonidea45952017-02-15 11:58:15 -080013267 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013268 } else {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013269 sme_err(
13270 " ******csr_roam_wm_status_change_complete fail to release command");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013271 }
13272
13273 } else {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013274 sme_warn(
13275"CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013276 }
13277 } else {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013278 sme_warn(
13279 "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013280 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013281}
13282
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013283void csr_roam_process_wm_status_change_command(
13284 tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013285{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013286 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013287 tSirSmeRsp *pSirSmeMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013288 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
13289 pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013290
13291 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013292 sme_err("session %d not found", pCommand->sessionId);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +053013293 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013294 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013295 sme_debug("session:%d, CmdType : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013296 pCommand->sessionId, pCommand->u.wmStatusChangeCmd.Type);
13297
13298 switch (pCommand->u.wmStatusChangeCmd.Type) {
13299 case eCsrDisassociated:
13300 pSirSmeMsg =
13301 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
13302 DisassocIndMsg;
13303 status =
13304 csr_roam_lost_link(pMac, pCommand->sessionId,
13305 eWNI_SME_DISASSOC_IND, pSirSmeMsg);
13306 break;
13307 case eCsrDeauthenticated:
13308 pSirSmeMsg =
13309 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
13310 DeauthIndMsg;
13311 status =
13312 csr_roam_lost_link(pMac, pCommand->sessionId,
13313 eWNI_SME_DEAUTH_IND, pSirSmeMsg);
13314 break;
13315 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013316 sme_warn("gets an unknown command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013317 pCommand->u.wmStatusChangeCmd.Type);
13318 break;
13319 }
Himanshu Agarwald519b4a2018-03-27 15:36:09 +053013320
13321end:
13322 if (status != QDF_STATUS_SUCCESS) {
13323 /*
13324 * As status returned is not success, there is nothing else
13325 * left to do so release WM status change command here.
13326 */
13327 csr_roam_wm_status_change_complete(pMac, pCommand->sessionId);
13328 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013329}
13330
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +053013331QDF_STATUS csr_process_del_sta_session_command(tpAniSirGlobal mac_ctx,
13332 tSmeCmd *sme_command)
13333{
13334 struct del_sta_self_params *del_sta_self_req;
13335 struct scheduler_msg msg = {0};
13336 QDF_STATUS status;
13337
13338 del_sta_self_req = qdf_mem_malloc(sizeof(struct del_sta_self_params));
13339 if (NULL == del_sta_self_req) {
13340 sme_err(" mem alloc failed for tDelStaSelfParams");
13341 return QDF_STATUS_E_NOMEM;
13342 }
13343
13344 qdf_mem_copy(del_sta_self_req->self_mac_addr,
13345 sme_command->u.delStaSessionCmd.selfMacAddr,
13346 sizeof(tSirMacAddr));
13347
13348 del_sta_self_req->session_id = sme_command->sessionId;
13349 del_sta_self_req->sme_callback =
13350 sme_command->u.delStaSessionCmd.session_close_cb;
13351 del_sta_self_req->sme_ctx = sme_command->u.delStaSessionCmd.context;
13352 msg.type = WMA_DEL_STA_SELF_REQ;
13353 msg.reserved = 0;
13354 msg.bodyptr = del_sta_self_req;
13355 msg.bodyval = 0;
13356
13357 sme_debug("sending WMA_DEL_STA_SELF_REQ");
13358 status = wma_post_ctrl_msg(mac_ctx, &msg);
13359 if (status != QDF_STATUS_SUCCESS) {
13360 sme_err("wma_post_ctrl_msg failed");
13361 qdf_mem_free(del_sta_self_req);
13362 return QDF_STATUS_E_FAILURE;
13363 }
13364 return QDF_STATUS_SUCCESS;
13365}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013366
13367/**
13368 * csr_compute_mode_and_band() - computes dot11mode
13369 * @pMac: mac global context
13370 * @dot11_mode: out param, do11 mode calculated
13371 * @band: out param, band caclculated
13372 * @opr_ch: operating channels
13373 *
13374 * This function finds dot11 mode based on current mode, operating channel and
13375 * fw supported modes.
13376 *
13377 * Return: void
13378 */
13379static void
13380csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013381 enum csr_cfgdot11mode *dot11_mode,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013382 enum band_info *band,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013383 uint8_t opr_ch)
13384{
13385 bool vht_24_ghz = mac_ctx->roam.configParam.enableVhtFor24GHz;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080013386
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013387 switch (mac_ctx->roam.configParam.uCfgDot11Mode) {
13388 case eCSR_CFG_DOT11_MODE_11A:
13389 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013390 *band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013391 break;
13392 case eCSR_CFG_DOT11_MODE_11B:
13393 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013394 *band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013395 break;
13396 case eCSR_CFG_DOT11_MODE_11G:
13397 *dot11_mode = eCSR_CFG_DOT11_MODE_11G;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013398 *band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013399 break;
13400 case eCSR_CFG_DOT11_MODE_11N:
13401 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13402 *band = CSR_GET_BAND(opr_ch);
13403 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013404 case eCSR_CFG_DOT11_MODE_11AC:
13405 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
13406 /*
13407 * If the operating channel is in 2.4 GHz band, check
13408 * for INI item to disable VHT operation in 2.4 GHz band
13409 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013410 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013411 /* Disable 11AC operation */
13412 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13413 else
13414 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
13415 } else {
13416 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13417 }
13418 *band = CSR_GET_BAND(opr_ch);
13419 break;
13420 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
13421 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
13422 /*
13423 * If the operating channel is in 2.4 GHz band, check
13424 * for INI item to disable VHT operation in 2.4 GHz band
13425 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013426 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013427 /* Disable 11AC operation */
13428 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13429 else
13430 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
13431 } else {
13432 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13433 }
13434 *band = CSR_GET_BAND(opr_ch);
13435 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080013436 case eCSR_CFG_DOT11_MODE_11AX:
13437 case eCSR_CFG_DOT11_MODE_11AX_ONLY:
13438 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) {
13439 *dot11_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
13440 } else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
13441 /*
13442 * If the operating channel is in 2.4 GHz band, check
13443 * for INI item to disable VHT operation in 2.4 GHz band
13444 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013445 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080013446 /* Disable 11AC operation */
13447 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13448 else
13449 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
13450 } else {
13451 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13452 }
13453 *band = CSR_GET_BAND(opr_ch);
13454 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013455 case eCSR_CFG_DOT11_MODE_AUTO:
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080013456 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) {
13457 *dot11_mode = eCSR_CFG_DOT11_MODE_11AX;
13458 } else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013459 /*
13460 * If the operating channel is in 2.4 GHz band,
13461 * check for INI item to disable VHT operation
13462 * in 2.4 GHz band
13463 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013464 if (WLAN_REG_IS_24GHZ_CH(opr_ch)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013465 && !vht_24_ghz)
13466 /* Disable 11AC operation */
13467 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13468 else
13469 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
13470 } else {
13471 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13472 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013473 *band = CSR_GET_BAND(opr_ch);
13474 break;
13475 default:
13476 /*
13477 * Global dot11 Mode setting is 11a/b/g. use the channel number
13478 * to determine the Mode setting.
13479 */
13480 if (eCSR_OPERATING_CHANNEL_AUTO == opr_ch) {
13481 *band = mac_ctx->roam.configParam.eBand;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013482 if (BAND_2G == *band) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013483 /*
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013484 * See reason in else if ( WLAN_REG_IS_24GHZ_CH
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013485 * (opr_ch) ) to pick 11B
13486 */
13487 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
13488 } else {
13489 /* prefer 5GHz */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013490 *band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013491 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
13492 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013493 } else if (WLAN_REG_IS_24GHZ_CH(opr_ch)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013494 /*
13495 * WiFi tests require IBSS networks to start in 11b mode
13496 * without any change to the default parameter settings
13497 * on the adapter. We use ACU to start an IBSS through
13498 * creation of a startIBSS profile. This startIBSS
13499 * profile has Auto MACProtocol and the adapter property
13500 * setting for dot11Mode is also AUTO. So in this case,
13501 * let's start the IBSS network in 11b mode instead of
13502 * 11g mode. So this is for Auto=profile->MacProtocol &&
13503 * Auto=Global. dot11Mode && profile->channel is < 14,
13504 * then start the IBSS in b mode.
13505 *
13506 * Note: we used to have this start as an 11g IBSS for
13507 * best performance. now to specify that the user will
13508 * have to set the do11Mode in the property page to 11g
13509 * to force it.
13510 */
13511 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013512 *band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013513 } else {
13514 /* else, it's a 5.0GHz channel. Set mode to 11a. */
13515 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013516 *band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013517 }
13518 break;
13519 } /* switch */
13520}
13521
13522/**
13523 * csr_roam_get_phy_mode_band_for_bss() - This function returns band and mode
13524 * information.
13525 * @mac_ctx: mac global context
13526 * @profile: bss profile
13527 * @band: out param, band caclculated
13528 * @opr_ch: operating channels
13529 *
13530 * This function finds dot11 mode based on current mode, operating channel and
13531 * fw supported modes. The only tricky part is that if phyMode is set to 11abg,
13532 * this function may return eCSR_CFG_DOT11_MODE_11B instead of
13533 * eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
13534 *
13535 * Return: dot11mode
13536 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013537static enum csr_cfgdot11mode
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013538csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070013539 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013540 uint8_t opr_chn,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013541 enum band_info *p_band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013542{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013543 enum band_info band;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013544enum csr_cfgdot11mode curr_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
13545 enum csr_cfgdot11mode cfg_dot11_mode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013546 csr_get_cfg_dot11_mode_from_csr_phy_mode(profile,
13547 (eCsrPhyMode) profile->phyMode,
13548 mac_ctx->roam.configParam.ProprietaryRatesEnabled);
13549
13550 /*
13551 * If the global setting for dot11Mode is set to auto/abg, we overwrite
13552 * the setting in the profile.
13553 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070013554 if ((!CSR_IS_INFRA_AP(profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013555 && ((eCSR_CFG_DOT11_MODE_AUTO == curr_mode)
13556 || (eCSR_CFG_DOT11_MODE_ABG == curr_mode)))
13557 || (eCSR_CFG_DOT11_MODE_AUTO == cfg_dot11_mode)
13558 || (eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode)) {
13559 csr_compute_mode_and_band(mac_ctx, &cfg_dot11_mode,
13560 &band, opr_chn);
13561 } /* if( eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode ) */
13562 else {
13563 /* dot11 mode is set, lets pick the band */
13564 if (eCSR_OPERATING_CHANNEL_AUTO == opr_chn) {
13565 /* channel is Auto also. */
13566 band = mac_ctx->roam.configParam.eBand;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013567 if (BAND_ALL == band) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013568 /* prefer 5GHz */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013569 band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013570 }
13571 } else{
13572 band = CSR_GET_BAND(opr_chn);
13573 }
13574 }
13575 if (p_band)
13576 *p_band = band;
13577
13578 if (opr_chn == 14) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013579 sme_err("Switching to Dot11B mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013580 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11B;
13581 }
13582
Gupta, Kapil76ed25e2016-04-22 15:13:55 +053013583 if (IS_24G_CH(opr_chn) &&
13584 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
13585 (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode ||
13586 eCSR_CFG_DOT11_MODE_11AC_ONLY == cfg_dot11_mode))
13587 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013588 /*
13589 * Incase of WEP Security encryption type is coming as part of add key.
13590 * So while STart BSS dont have information
13591 */
13592 if ((!CSR_IS_11n_ALLOWED(profile->EncryptionType.encryptionType[0])
13593 || ((profile->privacy == 1)
13594 && (profile->EncryptionType.encryptionType[0] ==
13595 eCSR_ENCRYPT_TYPE_NONE)))
13596 && ((eCSR_CFG_DOT11_MODE_11N == cfg_dot11_mode) ||
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -080013597 (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode) ||
13598 (eCSR_CFG_DOT11_MODE_11AX == cfg_dot11_mode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013599 /* We cannot do 11n here */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013600 if (WLAN_REG_IS_24GHZ_CH(opr_chn))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013601 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11G;
13602 else
13603 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11A;
13604 }
Srinivas Girigowda2c263352017-03-17 17:49:53 -070013605 sme_debug("dot11mode: %d", cfg_dot11_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013606 return cfg_dot11_mode;
13607}
13608
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013609QDF_STATUS csr_roam_issue_stop_bss(tpAniSirGlobal pMac,
13610 uint32_t sessionId, enum csr_roam_substate NewSubstate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013611{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013612 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013613 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013614
13615 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013616 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013617 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013618 }
13619#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
13620 {
13621 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013622
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013623 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
13624 LOG_WLAN_IBSS_C);
13625 if (pIbssLog) {
13626 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
13627 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
13628 }
13629 }
13630#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
13631 /* Set the roaming substate to 'stop Bss request'... */
13632 csr_roam_substate_change(pMac, NewSubstate, sessionId);
13633
13634 /* attempt to stop the Bss (reason code is ignored...) */
13635 status = csr_send_mb_stop_bss_req_msg(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013636 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013637 sme_warn(
13638 "csr_send_mb_stop_bss_req_msg failed with status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013639 status);
13640 }
13641 return status;
13642}
13643
13644/* pNumChan is a caller allocated space with the sizeof pChannels */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013645QDF_STATUS csr_get_cfg_valid_channels(tpAniSirGlobal pMac, uint8_t *pChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013646 uint32_t *pNumChan)
13647{
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053013648 uint8_t num_chan_temp = 0;
13649 int i;
13650
Jeff Johnsonc09caa42018-06-07 22:58:55 -070013651 if (!QDF_IS_STATUS_SUCCESS(wlan_cfg_get_str(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013652 WNI_CFG_VALID_CHANNEL_LIST,
13653 (uint8_t *) pChannels, pNumChan)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013654 return QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053013655
13656 for (i = 0; i < *pNumChan; i++) {
Kiran Kumar Lokere1a43bcf2018-05-15 15:51:58 -070013657 if (!wlan_reg_is_dsrc_chan(pMac->pdev, pChannels[i])) {
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053013658 pChannels[num_chan_temp] = pChannels[i];
13659 num_chan_temp++;
13660 }
13661 }
13662
13663 *pNumChan = num_chan_temp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013664 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013665}
13666
Amar Singhala297bfa2015-10-15 15:07:29 -070013667int8_t csr_get_cfg_max_tx_power(tpAniSirGlobal pMac, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013668{
13669 uint32_t cfgLength = 0;
13670 uint16_t cfgId = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -070013671 int8_t maxTxPwr = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013672 uint8_t *pCountryInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013673 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013674 uint8_t count = 0;
13675 uint8_t firstChannel;
13676 uint8_t maxChannels;
13677
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013678 if (WLAN_REG_IS_5GHZ_CH(channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013679 cfgId = WNI_CFG_MAX_TX_POWER_5;
13680 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013681 } else if (WLAN_REG_IS_24GHZ_CH(channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013682 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
13683 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
13684 } else
13685 return maxTxPwr;
13686
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013687 pCountryInfo = qdf_mem_malloc(cfgLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013688 if (NULL == pCountryInfo)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013689 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013690 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013691 status = QDF_STATUS_SUCCESS;
13692 if (status != QDF_STATUS_SUCCESS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013693 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013694 "%s: failed to allocate memory, status = %d",
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013695 __func__, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013696 goto error;
13697 }
13698 if (wlan_cfg_get_str(pMac, cfgId, (uint8_t *)pCountryInfo,
Jeff Johnsonc09caa42018-06-07 22:58:55 -070013699 &cfgLength) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013700 goto error;
13701 }
13702 /* Identify the channel and maxtxpower */
13703 while (count <= (cfgLength - (sizeof(tSirMacChanInfo)))) {
13704 firstChannel = pCountryInfo[count++];
13705 maxChannels = pCountryInfo[count++];
13706 maxTxPwr = pCountryInfo[count++];
13707
13708 if ((channel >= firstChannel) &&
13709 (channel < (firstChannel + maxChannels))) {
13710 break;
13711 }
13712 }
13713
13714error:
13715 if (NULL != pCountryInfo)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013716 qdf_mem_free(pCountryInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013717
13718 return maxTxPwr;
13719}
13720
13721bool csr_roam_is_channel_valid(tpAniSirGlobal pMac, uint8_t channel)
13722{
13723 bool fValid = false;
13724 uint32_t idxValidChannels;
13725 uint32_t len = sizeof(pMac->roam.validChannelList);
13726
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013727 if (QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels(pMac,
13728 pMac->roam.validChannelList, &len))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013729 for (idxValidChannels = 0; (idxValidChannels < len);
13730 idxValidChannels++) {
13731 if (channel ==
13732 pMac->roam.validChannelList[idxValidChannels]) {
13733 fValid = true;
13734 break;
13735 }
13736 }
13737 }
13738 pMac->roam.numValidChannels = len;
13739 return fValid;
13740}
13741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013742/* This function check and validate whether the NIC can do CB (40MHz) */
13743static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
Abhishek Singh78f654b2018-08-29 12:23:00 +053013744 uint8_t chan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013745 tDot11fBeaconIEs *pIes)
13746{
13747 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Abhishek Singh78f654b2018-08-29 12:23:00 +053013748 uint8_t sec_ch = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013749 uint32_t ChannelBondingMode;
Abhishek Singh08b06b72017-08-21 14:12:58 +053013750 struct ch_params ch_params = {0};
13751
Abhishek Singh78f654b2018-08-29 12:23:00 +053013752 if (WLAN_REG_IS_24GHZ_CH(chan)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013753 ChannelBondingMode =
13754 pMac->roam.configParam.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013755 } else {
13756 ChannelBondingMode =
13757 pMac->roam.configParam.channelBondingMode5GHz;
13758 }
13759
13760 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE == ChannelBondingMode)
13761 return PHY_SINGLE_CHANNEL_CENTERED;
13762
13763 /* Figure what the other side's CB mode */
13764 if (!(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ ==
13765 pIes->HTCaps.supportedChannelWidthSet))) {
13766 return PHY_SINGLE_CHANNEL_CENTERED;
13767 }
13768
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053013769 /* In Case WPA2 and TKIP is the only one cipher suite in Pairwise */
13770 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013771 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053013772 "\x00\x0f\xac\x02", 4))
Abhishek Singh1e39fc22015-12-18 11:23:44 +053013773 /* In Case only WPA1 is supported and TKIP is
13774 * the only one cipher suite in Unicast.
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053013775 */
Abhishek Singh1e39fc22015-12-18 11:23:44 +053013776 || (!pIes->RSN.present && (pIes->WPA.present &&
13777 (pIes->WPA.unicast_cipher_count == 1) &&
13778 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
13779 "\x00\x50\xf2\x02", 4)))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013780 sme_debug("No channel bonding in TKIP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013781 return PHY_SINGLE_CHANNEL_CENTERED;
13782 }
13783
13784 if (!pIes->HTInfo.present)
13785 return PHY_SINGLE_CHANNEL_CENTERED;
13786
13787 /*
13788 * This is called during INFRA STA/CLIENT and should use the merged
13789 * value of supported channel width and recommended tx width as per
13790 * standard
13791 */
Abhishek Singh78f654b2018-08-29 12:23:00 +053013792 sme_debug("chan %d scws %u rtws %u sco %u", chan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013793 pIes->HTCaps.supportedChannelWidthSet,
13794 pIes->HTInfo.recommendedTxWidthSet,
13795 pIes->HTInfo.secondaryChannelOffset);
13796
13797 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
13798 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
13799 else
13800 eRet = PHY_SINGLE_CHANNEL_CENTERED;
13801
13802 switch (eRet) {
13803 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Abhishek Singh78f654b2018-08-29 12:23:00 +053013804 sec_ch = chan + CSR_SEC_CHANNEL_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013805 break;
13806 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Abhishek Singh78f654b2018-08-29 12:23:00 +053013807 sec_ch = chan - CSR_SEC_CHANNEL_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013808 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013809 default:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013810 break;
13811 }
13812
Abhishek Singh78f654b2018-08-29 12:23:00 +053013813 if (eRet != PHY_SINGLE_CHANNEL_CENTERED) {
13814 ch_params.ch_width = CH_WIDTH_40MHZ;
13815 wlan_reg_set_channel_params(pMac->pdev, chan,
13816 sec_ch, &ch_params);
13817 if (ch_params.ch_width == CH_WIDTH_20MHZ ||
13818 ch_params.sec_ch_offset != eRet) {
13819 sme_err("chan %d :: Supported HT BW %d and cbmode %d, APs HT BW %d and cbmode %d, so switch to 20Mhz",
13820 chan, ch_params.ch_width,
13821 ch_params.sec_ch_offset,
13822 pIes->HTInfo.recommendedTxWidthSet, eRet);
Abhishek Singh08b06b72017-08-21 14:12:58 +053013823 eRet = PHY_SINGLE_CHANNEL_CENTERED;
13824 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013825 }
Abhishek Singh78f654b2018-08-29 12:23:00 +053013826
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013827 return eRet;
13828}
13829
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013830static bool csr_is_encryption_in_list(tpAniSirGlobal pMac,
13831 tCsrEncryptionList *pCipherList,
13832 eCsrEncryptionType encryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013833{
13834 bool fFound = false;
13835 uint32_t idx;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013836
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013837 for (idx = 0; idx < pCipherList->numEntries; idx++) {
13838 if (pCipherList->encryptionType[idx] == encryptionType) {
13839 fFound = true;
13840 break;
13841 }
13842 }
13843 return fFound;
13844}
13845
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013846static bool csr_is_auth_in_list(tpAniSirGlobal pMac, tCsrAuthList *pAuthList,
13847 eCsrAuthType authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013848{
13849 bool fFound = false;
13850 uint32_t idx;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013852 for (idx = 0; idx < pAuthList->numEntries; idx++) {
13853 if (pAuthList->authType[idx] == authType) {
13854 fFound = true;
13855 break;
13856 }
13857 }
13858 return fFound;
13859}
13860
13861bool csr_is_same_profile(tpAniSirGlobal pMac,
13862 tCsrRoamConnectedProfile *pProfile1,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070013863 struct csr_roam_profile *pProfile2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013864{
13865 uint32_t i;
13866 bool fCheck = false;
13867 tCsrScanResultFilter *pScanFilter = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013868 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013869
13870 if (!(pProfile1 && pProfile2))
13871 return fCheck;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013872 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013873 if (NULL == pScanFilter)
13874 return fCheck;
13875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013876 status = csr_roam_prepare_filter_from_profile(pMac, pProfile2,
13877 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013878 if (!(QDF_IS_STATUS_SUCCESS(status)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013879 goto free_scan_filter;
13880
13881 for (i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++) {
13882 fCheck = csr_is_ssid_match(pMac,
13883 pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
13884 pScanFilter->SSIDs.SSIDList[i].SSID.length,
13885 pProfile1->SSID.ssId,
13886 pProfile1->SSID.length,
13887 false);
13888 if (fCheck)
13889 break;
13890 }
13891 if (!fCheck)
13892 goto free_scan_filter;
13893
13894 if (!csr_is_auth_in_list(pMac, &pProfile2->AuthType,
13895 pProfile1->AuthType)
13896 || (pProfile2->BSSType != pProfile1->BSSType)
13897 || !csr_is_encryption_in_list(pMac, &pProfile2->EncryptionType,
13898 pProfile1->EncryptionType)) {
13899 fCheck = false;
13900 goto free_scan_filter;
13901 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013902 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent) {
13903 if (pProfile1->MDID.mobilityDomain
13904 != pProfile2->MDID.mobilityDomain) {
13905 fCheck = false;
13906 goto free_scan_filter;
13907 }
13908 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013909 /* Match found */
13910 fCheck = true;
13911free_scan_filter:
13912 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013913 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013914 return fCheck;
13915}
13916
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013917static bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013918 tCsrRoamConnectedProfile *pConnProfile,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070013919 struct csr_roam_profile *pProfile2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013920{
13921 bool fCheck = false;
13922 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013923
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013924 do {
13925 /* Only check for static WEP */
13926 if (!csr_is_encryption_in_list
13927 (pMac, &pProfile2->EncryptionType,
13928 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
13929 && !csr_is_encryption_in_list(pMac,
13930 &pProfile2->EncryptionType,
13931 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
13932 fCheck = true;
13933 break;
13934 }
13935 if (!csr_is_encryption_in_list
13936 (pMac, &pProfile2->EncryptionType,
13937 pConnProfile->EncryptionType))
13938 break;
13939 if (pConnProfile->Keys.defaultIndex !=
13940 pProfile2->Keys.defaultIndex)
13941 break;
13942 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
13943 if (pConnProfile->Keys.KeyLength[i] !=
13944 pProfile2->Keys.KeyLength[i])
13945 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013946 if (qdf_mem_cmp(&pConnProfile->Keys.KeyMaterial[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013947 &pProfile2->Keys.KeyMaterial[i],
13948 pProfile2->Keys.KeyLength[i])) {
13949 break;
13950 }
13951 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013952 if (i == CSR_MAX_NUM_KEY)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013953 fCheck = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013954 } while (0);
13955 return fCheck;
13956}
13957
13958/* IBSS */
13959
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013960static uint8_t csr_roam_get_ibss_start_channel_number50(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013961{
13962 uint8_t channel = 0;
13963 uint32_t idx;
13964 uint32_t idxValidChannels;
13965 bool fFound = false;
13966 uint32_t len = sizeof(pMac->roam.validChannelList);
13967
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013968 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.
13969 AdHocChannel5G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013970 channel = pMac->roam.configParam.AdHocChannel5G;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013971 if (!csr_roam_is_channel_valid(pMac, channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013972 channel = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013973 }
13974 if (0 == channel
13975 &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013976 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013977 (pMac, (uint8_t *) pMac->roam.
13978 validChannelList, &len))) {
Sandeep Puligilla80038de2017-05-10 10:43:29 -070013979 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHAN_50) && !fFound;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013980 idx++) {
13981 for (idxValidChannels = 0;
13982 (idxValidChannels < len) && !fFound;
13983 idxValidChannels++) {
13984 if (csr_start_ibss_channels50[idx] ==
13985 pMac->roam.
13986 validChannelList[idxValidChannels]) {
13987 fFound = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013988 channel =
13989 csr_start_ibss_channels50[idx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013990 }
13991 }
13992 }
13993 /*
13994 * this is rare, but if it does happen,
13995 * we find anyone in 11a bandwidth and
13996 * return the first 11a channel found!
13997 */
13998 if (!fFound) {
13999 for (idxValidChannels = 0; idxValidChannels < len;
14000 idxValidChannels++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014001 if (WLAN_REG_IS_5GHZ_CH(pMac->roam.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014002 validChannelList[idxValidChannels])) {
14003 /* the max channel# in 11g is 14 */
14004 if (idxValidChannels <
Sandeep Puligilla80038de2017-05-10 10:43:29 -070014005 CSR_NUM_IBSS_START_CHAN_50) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014006 channel =
14007 pMac->roam.validChannelList
14008 [idxValidChannels];
14009 }
14010 break;
14011 }
14012 }
14013 }
14014 } /* if */
14015
14016 return channel;
14017}
14018
Jeff Johnson29e2ca12016-10-14 12:50:38 -070014019static uint8_t csr_roam_get_ibss_start_channel_number24(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014020{
14021 uint8_t channel = 1;
14022 uint32_t idx;
14023 uint32_t idxValidChannels;
14024 bool fFound = false;
14025 uint32_t len = sizeof(pMac->roam.validChannelList);
14026
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014027 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.
14028 AdHocChannel24) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014029 channel = pMac->roam.configParam.AdHocChannel24;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014030 if (!csr_roam_is_channel_valid(pMac, channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014031 channel = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014032 }
14033
14034 if (0 == channel
14035 &&
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014036 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels(pMac,
14037 (uint8_t *) pMac->roam.validChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014038 &len))) {
14039 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHANNELS_24) && !fFound;
14040 idx++) {
14041 for (idxValidChannels = 0;
14042 (idxValidChannels < len) && !fFound;
14043 idxValidChannels++) {
14044 if (csr_start_ibss_channels24[idx] ==
14045 pMac->roam.
14046 validChannelList[idxValidChannels]) {
14047 fFound = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014048 channel =
14049 csr_start_ibss_channels24[idx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014050 }
14051 }
14052 }
14053 }
14054
14055 return channel;
14056}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014057/**
14058 * csr_populate_basic_rates() - populates OFDM or CCK rates
14059 * @rates: rate struct to populate
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014060 * @is_ofdm_rates: true: ofdm rates, false: cck rates
14061 * @is_basic_rates: indicates if rates are to be masked with
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014062 * CSR_DOT11_BASIC_RATE_MASK
14063 *
14064 * This function will populate OFDM or CCK rates
14065 *
14066 * Return: void
14067 */
14068static void
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014069csr_populate_basic_rates(tSirMacRateSet *rate_set, bool is_ofdm_rates,
14070 bool is_basic_rates)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014071{
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014072 int i = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014073 uint8_t ofdm_rates[8] = {
14074 SIR_MAC_RATE_6,
14075 SIR_MAC_RATE_9,
14076 SIR_MAC_RATE_12,
14077 SIR_MAC_RATE_18,
14078 SIR_MAC_RATE_24,
14079 SIR_MAC_RATE_36,
14080 SIR_MAC_RATE_48,
14081 SIR_MAC_RATE_54
14082 };
14083 uint8_t cck_rates[4] = {
14084 SIR_MAC_RATE_1,
14085 SIR_MAC_RATE_2,
14086 SIR_MAC_RATE_5_5,
14087 SIR_MAC_RATE_11
14088 };
14089
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014090 if (is_ofdm_rates == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014091 rate_set->numRates = 8;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014092 qdf_mem_copy(rate_set->rate, ofdm_rates, sizeof(ofdm_rates));
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014093 if (is_basic_rates) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014094 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
14095 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
14096 rate_set->rate[4] |= CSR_DOT11_BASIC_RATE_MASK;
14097 }
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014098 for (i = 0; i < rate_set->numRates; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014099 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
14100 ("Default OFDM rate is %2x"), rate_set->rate[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014101 } else {
14102 rate_set->numRates = 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014103 qdf_mem_copy(rate_set->rate, cck_rates, sizeof(cck_rates));
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014104 if (is_basic_rates) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014105 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
14106 rate_set->rate[1] |= CSR_DOT11_BASIC_RATE_MASK;
14107 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
14108 rate_set->rate[3] |= CSR_DOT11_BASIC_RATE_MASK;
14109 }
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014110 for (i = 0; i < rate_set->numRates; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014111 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
14112 ("Default CCK rate is %2x"), rate_set->rate[i]);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014113
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014114 }
14115}
14116
14117/**
14118 * csr_convert_mode_to_nw_type() - convert mode into network type
14119 * @dot11_mode: dot11_mode
14120 * @band: 2.4 or 5 GHz
14121 *
14122 * Return: tSirNwType
14123 */
14124static tSirNwType
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014125csr_convert_mode_to_nw_type(enum csr_cfgdot11mode dot11_mode,
14126 enum band_info band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014127{
14128 switch (dot11_mode) {
14129 case eCSR_CFG_DOT11_MODE_11G:
14130 return eSIR_11G_NW_TYPE;
14131 case eCSR_CFG_DOT11_MODE_11B:
14132 return eSIR_11B_NW_TYPE;
14133 case eCSR_CFG_DOT11_MODE_11A:
14134 return eSIR_11A_NW_TYPE;
14135 case eCSR_CFG_DOT11_MODE_11N:
14136 default:
14137 /*
14138 * Because LIM only verifies it against 11a, 11b or 11g, set
14139 * only 11g or 11a here
14140 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014141 if (BAND_2G == band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014142 return eSIR_11G_NW_TYPE;
14143 else
14144 return eSIR_11A_NW_TYPE;
14145 }
14146 return eSIR_DONOT_USE_NW_TYPE;
14147}
14148
14149/**
hqu16d6e082017-09-04 10:52:31 +080014150 * csr_populate_supported_rates_from_hostapd() - populates operational
14151 * and extended rates.
14152 * from hostapd.conf file
14153 * @opr_rates: rate struct to populate operational rates
14154 * @ext_rates: rate struct to populate extended rates
14155 * @profile: bss profile
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014156 *
hqu16d6e082017-09-04 10:52:31 +080014157 * Return: void
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014158 */
hqu16d6e082017-09-04 10:52:31 +080014159static void csr_populate_supported_rates_from_hostapd(tSirMacRateSet *opr_rates,
14160 tSirMacRateSet *ext_rates,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014161 struct csr_roam_profile *profile)
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014162{
hqu16d6e082017-09-04 10:52:31 +080014163 int i = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014164
Ravi Joshib398c852017-07-18 17:55:21 -070014165 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
14166 FL("supported_rates: %d extended_rates: %d"),
hqu16d6e082017-09-04 10:52:31 +080014167 profile->supported_rates.numRates,
14168 profile->extended_rates.numRates);
Ravi Joshib398c852017-07-18 17:55:21 -070014169
hqu16d6e082017-09-04 10:52:31 +080014170 if (profile->supported_rates.numRates > SIR_MAC_RATESET_EID_MAX)
14171 profile->supported_rates.numRates = SIR_MAC_RATESET_EID_MAX;
Ravi Joshib398c852017-07-18 17:55:21 -070014172
hqu16d6e082017-09-04 10:52:31 +080014173 if (profile->extended_rates.numRates > SIR_MAC_RATESET_EID_MAX)
14174 profile->extended_rates.numRates = SIR_MAC_RATESET_EID_MAX;
Ravi Joshib398c852017-07-18 17:55:21 -070014175
hqu16d6e082017-09-04 10:52:31 +080014176 if (profile->supported_rates.numRates) {
14177 opr_rates->numRates = profile->supported_rates.numRates;
14178 qdf_mem_copy(opr_rates->rate,
14179 profile->supported_rates.rate,
14180 profile->supported_rates.numRates);
14181 for (i = 0; i < opr_rates->numRates; i++)
14182 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
14183 FL("Supported Rate is %2x"), opr_rates->rate[i]);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014184 }
hqu16d6e082017-09-04 10:52:31 +080014185 if (profile->extended_rates.numRates) {
14186 ext_rates->numRates =
14187 profile->extended_rates.numRates;
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014188 qdf_mem_copy(ext_rates->rate,
hqu16d6e082017-09-04 10:52:31 +080014189 profile->extended_rates.rate,
14190 profile->extended_rates.numRates);
14191 for (i = 0; i < ext_rates->numRates; i++)
14192 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
14193 FL("Extended Rate is %2x"), ext_rates->rate[i]);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014194 }
14195}
lifenge9245fc2017-02-22 17:23:19 +080014196
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014197/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014198 * csr_roam_get_bss_start_parms() - get bss start param from profile
14199 * @pMac: mac global context
14200 * @pProfile: roam profile
14201 * @pParam: out param, start bss params
Krunal Soni8f8507c2016-12-20 13:54:34 -080014202 * @skip_hostapd_rate: to skip given hostapd's rate
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014203 *
14204 * This function populates start bss param from roam profile
14205 *
14206 * Return: void
14207 */
Bala Venkateshb39ed152017-12-26 19:35:27 +053014208static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014209csr_roam_get_bss_start_parms(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014210 struct csr_roam_profile *pProfile,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014211 struct csr_roamstart_bssparams *pParam,
Krunal Soni8f8507c2016-12-20 13:54:34 -080014212 bool skip_hostapd_rate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014213{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014214 enum band_info band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014215 uint8_t opr_ch = 0;
14216 tSirNwType nw_type;
14217 uint8_t tmp_opr_ch = 0;
14218 tSirMacRateSet *opr_rates = &pParam->operationalRateSet;
14219 tSirMacRateSet *ext_rates = &pParam->extendedRateSet;
14220
14221 if (pProfile->ChannelInfo.numOfChannels
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014222 && pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014223 tmp_opr_ch = pProfile->ChannelInfo.ChannelList[0];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014224
14225 pParam->uCfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac,
14226 pProfile, tmp_opr_ch, &band);
14227
Anurag Chouhan6d760662016-02-20 16:05:43 +053014228 if (((pProfile->csrPersona == QDF_P2P_CLIENT_MODE)
14229 || (pProfile->csrPersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014230 && (pParam->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)) {
14231 /* This should never happen */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014232 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014233 "For P2P (persona %d) dot11_mode is 11B",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014234 pProfile->csrPersona);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014235 QDF_ASSERT(0);
Bala Venkateshb39ed152017-12-26 19:35:27 +053014236 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014237 }
14238
14239 nw_type = csr_convert_mode_to_nw_type(pParam->uCfgDot11Mode, band);
14240 ext_rates->numRates = 0;
hqu16d6e082017-09-04 10:52:31 +080014241 /*
14242 * hostapd.conf will populate its basic and extended rates
14243 * as per hw_mode, but if acs in ini is enabled driver should
14244 * ignore basic and extended rates from hostapd.conf and should
14245 * populate default rates.
14246 */
14247 if (!cds_is_sub_20_mhz_enabled() && !skip_hostapd_rate &&
14248 (pProfile->supported_rates.numRates ||
14249 pProfile->extended_rates.numRates)) {
14250 csr_populate_supported_rates_from_hostapd(opr_rates,
14251 ext_rates, pProfile);
14252 pParam->operationChn = tmp_opr_ch;
14253 } else {
14254 switch (nw_type) {
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014255 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014256 sme_err(
14257 "sees an unknown pSirNwType (%d)",
14258 nw_type);
Bala Venkateshb39ed152017-12-26 19:35:27 +053014259 return QDF_STATUS_E_INVAL;
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014260 case eSIR_11A_NW_TYPE:
14261 csr_populate_basic_rates(opr_rates, true, true);
14262 if (eCSR_OPERATING_CHANNEL_ANY != tmp_opr_ch) {
14263 opr_ch = tmp_opr_ch;
14264 break;
14265 }
14266 opr_ch = csr_roam_get_ibss_start_channel_number50(pMac);
14267 if (0 == opr_ch &&
hqu16d6e082017-09-04 10:52:31 +080014268 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
14269 CSR_IS_PHY_MODE_DUAL_BAND(
14270 pMac->roam.configParam.phyMode)) {
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014271 /*
14272 * We could not find a 5G channel by auto pick,
14273 * let's try 2.4G channels. We only do this here
14274 * because csr_roam_get_phy_mode_band_for_bss
14275 * always picks 11a for AUTO
14276 */
14277 nw_type = eSIR_11B_NW_TYPE;
14278 opr_ch =
14279 csr_roam_get_ibss_start_channel_number24(pMac);
14280 csr_populate_basic_rates(opr_rates, false,
hqu16d6e082017-09-04 10:52:31 +080014281 true);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014282 }
14283 break;
14284 case eSIR_11B_NW_TYPE:
14285 csr_populate_basic_rates(opr_rates, false, true);
14286 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
14287 opr_ch =
14288 csr_roam_get_ibss_start_channel_number24(pMac);
14289 else
14290 opr_ch = tmp_opr_ch;
14291 break;
14292 case eSIR_11G_NW_TYPE:
14293 /* For P2P Client and P2P GO, disable 11b rates */
14294 if ((pProfile->csrPersona == QDF_P2P_CLIENT_MODE) ||
hqu16d6e082017-09-04 10:52:31 +080014295 (pProfile->csrPersona == QDF_P2P_GO_MODE) ||
14296 (eCSR_CFG_DOT11_MODE_11G_ONLY ==
14297 pParam->uCfgDot11Mode)) {
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014298 csr_populate_basic_rates(opr_rates, true, true);
14299 } else {
14300 csr_populate_basic_rates(opr_rates, false,
hqu16d6e082017-09-04 10:52:31 +080014301 true);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014302 csr_populate_basic_rates(ext_rates, true,
hqu16d6e082017-09-04 10:52:31 +080014303 false);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014304 }
14305 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
14306 opr_ch =
14307 csr_roam_get_ibss_start_channel_number24(pMac);
14308 else
14309 opr_ch = tmp_opr_ch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014310 break;
14311 }
hqu16d6e082017-09-04 10:52:31 +080014312 pParam->operationChn = opr_ch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014313 }
lifenge9245fc2017-02-22 17:23:19 +080014314
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014315 pParam->sirNwType = nw_type;
14316 pParam->ch_params.ch_width = pProfile->ch_params.ch_width;
14317 pParam->ch_params.center_freq_seg0 =
14318 pProfile->ch_params.center_freq_seg0;
14319 pParam->ch_params.center_freq_seg1 =
14320 pProfile->ch_params.center_freq_seg1;
14321 pParam->ch_params.sec_ch_offset =
14322 pProfile->ch_params.sec_ch_offset;
Bala Venkateshb39ed152017-12-26 19:35:27 +053014323 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014324}
14325
14326static void
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014327csr_roam_get_bss_start_parms_from_bss_desc(
14328 tpAniSirGlobal pMac,
14329 tSirBssDescription *pBssDesc,
14330 tDot11fBeaconIEs *pIes,
14331 struct csr_roamstart_bssparams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014332{
14333 if (!pParam) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014334 sme_err("BSS param's pointer is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014335 return;
14336 }
14337
14338 pParam->sirNwType = pBssDesc->nwType;
14339 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
14340 pParam->operationChn = pBssDesc->channelId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014341 qdf_mem_copy(&pParam->bssid, pBssDesc->bssId,
14342 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014343
14344 if (!pIes) {
14345 pParam->ssId.length = 0;
14346 pParam->operationalRateSet.numRates = 0;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014347 sme_err("IEs struct pointer is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014348 return;
14349 }
14350
14351 if (pIes->SuppRates.present) {
14352 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
14353 if (pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014354 sme_err(
14355 "num_rates: %d > max val, resetting",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014356 pIes->SuppRates.num_rates);
14357 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
14358 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014359 qdf_mem_copy(pParam->operationalRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014360 pIes->SuppRates.rates,
14361 sizeof(*pIes->SuppRates.rates) *
14362 pIes->SuppRates.num_rates);
14363 }
14364 if (pIes->ExtSuppRates.present) {
14365 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
14366 if (pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014367 sme_err(
14368 "num_rates: %d > max val, resetting",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014369 pIes->ExtSuppRates.num_rates);
14370 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
14371 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014372 qdf_mem_copy(pParam->extendedRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014373 pIes->ExtSuppRates.rates,
14374 sizeof(*pIes->ExtSuppRates.rates) *
14375 pIes->ExtSuppRates.num_rates);
14376 }
14377 if (pIes->SSID.present) {
14378 pParam->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014379 qdf_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014380 pParam->ssId.length);
14381 }
14382 pParam->cbMode = csr_get_cb_mode_from_ies(pMac, pParam->operationChn,
14383 pIes);
14384}
14385
14386static void csr_roam_determine_max_rate_for_ad_hoc(tpAniSirGlobal pMac,
14387 tSirMacRateSet *pSirRateSet)
14388{
14389 uint8_t MaxRate = 0;
14390 uint32_t i;
14391 uint8_t *pRate;
14392
14393 pRate = pSirRateSet->rate;
14394 for (i = 0; i < pSirRateSet->numRates; i++) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014395 MaxRate = CSR_MAX(MaxRate, (pRate[i] &
14396 (~CSR_DOT11_BASIC_RATE_MASK)));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014397 }
14398
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014399 /* Save the max rate in the connected state information.
14400 * modify LastRates variable as well
14401 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014402
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014403}
14404
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014405QDF_STATUS csr_roam_issue_start_bss(tpAniSirGlobal pMac, uint32_t sessionId,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014406 struct csr_roamstart_bssparams *pParam,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014407 struct csr_roam_profile *pProfile,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014408 tSirBssDescription *pBssDesc,
14409 uint32_t roamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014410{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014411 QDF_STATUS status = QDF_STATUS_SUCCESS;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014412 enum band_info eBand;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014413 /* Set the roaming substate to 'Start BSS attempt'... */
14414 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ,
14415 sessionId);
14416#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
14417 /* Need to figure out whether we need to log WDS??? */
14418 if (CSR_IS_IBSS(pProfile)) {
14419 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014420
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014421 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
14422 LOG_WLAN_IBSS_C);
14423 if (pIbssLog) {
14424 if (pBssDesc) {
14425 pIbssLog->eventId =
14426 WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014427 qdf_mem_copy(pIbssLog->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014428 pBssDesc->bssId, QDF_MAC_ADDR_SIZE);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014429 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014430 pIbssLog->eventId =
14431 WLAN_IBSS_EVENT_START_IBSS_REQ;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014432
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014433 qdf_mem_copy(pIbssLog->ssid, pParam->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014434 pParam->ssId.length);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014435 if (pProfile->ChannelInfo.numOfChannels == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014436 pIbssLog->channelSetting = AUTO_PICK;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014437 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014438 pIbssLog->channelSetting = SPECIFIED;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014439
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014440 pIbssLog->operatingChannel = pParam->operationChn;
14441 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
14442 }
14443 }
14444#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
14445 /* Put RSN information in for Starting BSS */
14446 pParam->nRSNIELength = (uint16_t) pProfile->nRSNReqIELength;
14447 pParam->pRSNIE = pProfile->pRSNReqIE;
14448
14449 pParam->privacy = pProfile->privacy;
14450 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
14451 pParam->authType = pProfile->csr80211AuthType;
14452 pParam->beaconInterval = pProfile->beaconInterval;
14453 pParam->dtimPeriod = pProfile->dtimPeriod;
14454 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
14455 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
14456 if (CSR_IS_INFRA_AP(pProfile) && (pParam->operationChn != 0)) {
14457 if (csr_is_valid_channel(pMac, pParam->operationChn) !=
Himanshu Agarwal10b44362017-09-20 14:55:20 +053014458 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014459 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
Himanshu Agarwal10b44362017-09-20 14:55:20 +053014460 pParam->ch_params.ch_width = CH_WIDTH_20MHZ;
14461 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014462 }
14463 pParam->protEnabled = pProfile->protEnabled;
14464 pParam->obssProtEnabled = pProfile->obssProtEnabled;
14465 pParam->ht_protection = pProfile->cfg_protection;
14466 pParam->wps_state = pProfile->wps_state;
14467
14468 pParam->uCfgDot11Mode =
14469 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile,
14470 pParam->
14471 operationChn,
14472 &eBand);
14473 pParam->bssPersona = pProfile->csrPersona;
14474
14475#ifdef WLAN_FEATURE_11W
14476 pParam->mfpCapable = (0 != pProfile->MFPCapable);
14477 pParam->mfpRequired = (0 != pProfile->MFPRequired);
14478#endif
14479
14480 pParam->addIeParams.probeRespDataLen =
14481 pProfile->addIeParams.probeRespDataLen;
14482 pParam->addIeParams.probeRespData_buff =
14483 pProfile->addIeParams.probeRespData_buff;
14484
14485 pParam->addIeParams.assocRespDataLen =
14486 pProfile->addIeParams.assocRespDataLen;
14487 pParam->addIeParams.assocRespData_buff =
14488 pProfile->addIeParams.assocRespData_buff;
14489
14490 if (CSR_IS_IBSS(pProfile)) {
14491 pParam->addIeParams.probeRespBCNDataLen =
14492 pProfile->nWPAReqIELength;
14493 pParam->addIeParams.probeRespBCNData_buff = pProfile->pWPAReqIE;
14494 } else {
14495 pParam->addIeParams.probeRespBCNDataLen =
14496 pProfile->addIeParams.probeRespBCNDataLen;
14497 pParam->addIeParams.probeRespBCNData_buff =
14498 pProfile->addIeParams.probeRespBCNData_buff;
14499 }
14500 pParam->sap_dot11mc = pProfile->sap_dot11mc;
Arif Hussain671a1902017-03-17 09:08:32 -070014501 pParam->cac_duration_ms = pProfile->cac_duration_ms;
14502 pParam->dfs_regdomain = pProfile->dfs_regdomain;
Jiachao Wu712d4fd2017-08-23 16:52:34 +080014503 pParam->beacon_tx_rate = pProfile->beacon_tx_rate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014504
14505 /* When starting an IBSS, start on the channel from the Profile. */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014506 status = csr_send_mb_start_bss_req_msg(pMac, sessionId,
14507 pProfile->BSSType, pParam,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014508 pBssDesc);
14509 return status;
14510}
14511
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070014512void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014513 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014514 tSirBssDescription *pBssDesc,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014515 struct bss_config_param *pBssConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014516 tDot11fBeaconIEs *pIes)
14517{
14518 uint8_t Channel;
14519 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014520 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Ganesh Kondabattini4a7f5b92017-11-21 14:58:39 +053014521 bool skip_hostapd_rate = !pProfile->chan_switch_hostapd_rate_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014522
14523 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014524 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014525 return;
14526 }
14527
14528 if (pBssDesc) {
14529 csr_roam_get_bss_start_parms_from_bss_desc(pMac, pBssDesc, pIes,
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070014530 &pSession->bssParams);
14531 if (CSR_IS_NDI(pProfile)) {
14532 qdf_copy_macaddr(&pSession->bssParams.bssid,
14533 &pSession->selfMacAddr);
14534 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014535 } else {
Krunal Soni8f8507c2016-12-20 13:54:34 -080014536 csr_roam_get_bss_start_parms(pMac, pProfile,
Ganesh Kondabattini4a7f5b92017-11-21 14:58:39 +053014537 &pSession->bssParams,
14538 skip_hostapd_rate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014539 /* Use the first SSID */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014540 if (pProfile->SSIDs.numOfSSIDs)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014541 qdf_mem_copy(&pSession->bssParams.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014542 pProfile->SSIDs.SSIDList,
14543 sizeof(tSirMacSSid));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014544 if (pProfile->BSSIDs.numOfBSSIDs)
14545 /* Use the first BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014546 qdf_mem_copy(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014547 pProfile->BSSIDs.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014548 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014549 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014550 qdf_mem_set(&pSession->bssParams.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014551 sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014552 }
14553 Channel = pSession->bssParams.operationChn;
14554 /* Set operating channel in pProfile which will be used */
14555 /* in csr_roam_set_bss_config_cfg() to determine channel bonding */
14556 /* mode and will be configured in CFG later */
14557 pProfile->operationChannel = Channel;
14558
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014559 if (Channel == 0)
14560 sme_err("CSR cannot find a channel to start IBSS");
14561 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014562 csr_roam_determine_max_rate_for_ad_hoc(pMac,
14563 &pSession->bssParams.
14564 operationalRateSet);
14565 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS(pProfile)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014566 if (WLAN_REG_IS_24GHZ_CH(Channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014567 cbMode =
14568 pMac->roam.configParam.
14569 channelBondingMode24GHz;
14570 } else {
14571 cbMode =
14572 pMac->roam.configParam.
14573 channelBondingMode5GHz;
14574 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014575 sme_debug("## cbMode %d", cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014576 pBssConfig->cbMode = cbMode;
14577 pSession->bssParams.cbMode = cbMode;
14578 }
14579 }
14580}
14581
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014582static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014583 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014584 bool *pfSameIbss)
14585{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014586 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014587 bool fSameIbss = false;
14588
14589 if (csr_is_conn_state_ibss(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014590 /* Check if any profile parameter has changed ? If any profile
14591 * parameter has changed then stop old BSS and start a new one
14592 * with new parameters
14593 */
14594 if (csr_is_same_profile(pMac,
14595 &pMac->roam.roamSession[sessionId].
14596 connectedProfile, pProfile))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014597 fSameIbss = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014598 else
14599 status = csr_roam_issue_stop_bss(pMac, sessionId,
14600 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
14601
14602 } else if (csr_is_conn_state_connected_infra(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014603 /* Disassociate from the connected Infrastructure network... */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014604 status = csr_roam_issue_disassociate(pMac, sessionId,
14605 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014606 false);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014607 else {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014608 struct bss_config_param *pBssConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014609
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014610 pBssConfig = qdf_mem_malloc(sizeof(struct bss_config_param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014611 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014612 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014613 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014614 status = QDF_STATUS_SUCCESS;
14615 if (QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014616 /* there is no Bss description before we start an IBSS
14617 * so we need to adopt all Bss configuration parameters
14618 * from the Profile.
14619 */
14620 status = csr_roam_prepare_bss_config_from_profile(pMac,
14621 pProfile,
14622 pBssConfig,
14623 NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014624 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014625 /* save dotMode */
14626 pMac->roam.roamSession[sessionId].bssParams.
14627 uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
14628 /* Prepare some more parameters for this IBSS */
14629 csr_roam_prepare_bss_params(pMac, sessionId,
14630 pProfile, NULL,
14631 pBssConfig, NULL);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014632 status = csr_roam_set_bss_config_cfg(pMac,
14633 sessionId,
14634 pProfile, NULL,
14635 pBssConfig,
14636 NULL, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014637 }
14638
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014639 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014640 } /* Allocate memory */
14641 }
14642
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014643 if (pfSameIbss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014644 *pfSameIbss = fSameIbss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014645 return status;
14646}
14647
14648static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
14649 uint32_t sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014650 tSirSmeNewBssInfo *pNewBss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014651{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014652 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014653
14654 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014655 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014656 return;
14657 }
14658
14659 if (pNewBss) {
14660 /* Set the operating channel. */
14661 pSession->connectedProfile.operationChannel =
14662 pNewBss->channelNumber;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014663 /* move the BSSId from the BSS description into the connected
14664 * state information.
14665 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014666 qdf_mem_copy(&pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014667 &(pNewBss->bssId), sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014668 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014669}
14670
Abhinav Kumar7830d9c2018-06-27 17:57:48 +053014671#ifdef WLAN_FEATURE_ROAM_OFFLOAD
gaurank kathpalia99d06c12018-05-16 16:28:35 +053014672void csr_get_pmk_info(tpAniSirGlobal mac_ctx, uint8_t session_id,
14673 tPmkidCacheInfo *pmk_cache)
14674{
14675 struct csr_roam_session *session = NULL;
14676
14677 if (!mac_ctx) {
14678 sme_err("Mac_ctx is NULL");
14679 return;
14680 }
14681 session = CSR_GET_SESSION(mac_ctx, session_id);
14682 if (!session) {
14683 sme_err("session %d not found", session_id);
14684 return;
14685 }
14686 qdf_mem_copy(pmk_cache->pmk, session->psk_pmk,
14687 sizeof(session->psk_pmk));
14688 pmk_cache->pmk_len = session->pmk_len;
14689}
Abhinav Kumar7830d9c2018-06-27 17:57:48 +053014690
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014691QDF_STATUS csr_roam_set_psk_pmk(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014692 uint8_t *pPSK_PMK, size_t pmk_len)
14693{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014694 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014696 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014697 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014698 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014699 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014700 qdf_mem_copy(pSession->psk_pmk, pPSK_PMK, sizeof(pSession->psk_pmk));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014701 pSession->pmk_len = pmk_len;
Padma, Santhosh Kumar2d1f77c2017-11-22 16:20:28 +053014702
14703 if (csr_is_auth_type_ese(pMac->roam.roamSession[sessionId].
14704 connectedProfile.AuthType)) {
14705 sme_debug("PMK update is not required for ESE");
14706 return QDF_STATUS_SUCCESS;
14707 }
14708
Naveen Rawat5f1111b2017-03-31 17:36:20 -070014709 csr_roam_offload_scan(pMac, sessionId,
14710 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14711 REASON_ROAM_PSK_PMK_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014712 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014713}
14714#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
14715
14716#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
14717static void
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014718csr_roam_diag_set_pmkid(struct csr_roam_session *pSession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014719{
14720 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
14721 host_event_wlan_security_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014722 qdf_mem_set(&secEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014723 sizeof(host_event_wlan_security_payload_type), 0);
14724 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
14725 secEvent.encryptionModeMulticast =
14726 (uint8_t) diag_enc_type_from_csr_type(
14727 pSession->connectedProfile.mcEncryptionType);
14728 secEvent.encryptionModeUnicast =
14729 (uint8_t) diag_enc_type_from_csr_type(
14730 pSession->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014731 qdf_mem_copy(secEvent.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014732 pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014733 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014734 secEvent.authMode = (uint8_t) diag_auth_type_from_csr_type(
14735 pSession->connectedProfile.AuthType);
14736 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
14737}
14738#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
14739
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014740/**
14741 * csr_update_pmk_cache - API to update PMK cache
14742 * @pSession: pointer to session
14743 * @pmksa: pointer to PMKSA struct
14744 *
14745 * Return : None
14746 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014747static void csr_update_pmk_cache(struct csr_roam_session *session,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014748 tPmkidCacheInfo *pmksa)
14749{
14750 uint16_t cache_idx = session->curr_cache_idx;
14751
14752 /* Add entry to the cache */
14753 if (!pmksa->ssid_len) {
14754 qdf_copy_macaddr(
14755 &session->PmkidCacheInfo[cache_idx].BSSID,
14756 &pmksa->BSSID);
14757 session->PmkidCacheInfo[cache_idx].ssid_len = 0;
14758 } else {
14759 qdf_mem_copy(session->PmkidCacheInfo[cache_idx].ssid,
14760 pmksa->ssid, pmksa->ssid_len);
14761 session->PmkidCacheInfo[cache_idx].ssid_len =
14762 pmksa->ssid_len;
14763 qdf_mem_copy(session->PmkidCacheInfo[cache_idx].cache_id,
14764 pmksa->cache_id, CACHE_ID_LEN);
14765
14766 }
14767 qdf_mem_copy(
14768 session->PmkidCacheInfo[cache_idx].PMKID,
14769 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
14770
14771 if (pmksa->pmk_len)
14772 qdf_mem_copy(session->PmkidCacheInfo[cache_idx].pmk,
14773 pmksa->pmk, pmksa->pmk_len);
14774
14775 session->PmkidCacheInfo[cache_idx].pmk_len = pmksa->pmk_len;
14776
14777 /* Increment the CSR local cache index */
14778 if (cache_idx < (CSR_MAX_PMKID_ALLOWED - 1))
14779 session->curr_cache_idx++;
14780 else {
14781 sme_debug("max value reached, setting current index as 0");
14782 session->curr_cache_idx = 0;
14783 }
14784
14785 session->NumPmkidCache++;
14786 if (session->NumPmkidCache > CSR_MAX_PMKID_ALLOWED) {
14787 sme_debug("setting num pmkid cache to %d",
14788 CSR_MAX_PMKID_ALLOWED);
14789 session->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
14790 }
14791}
14792
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014793QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014794csr_roam_set_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
14795 tPmkidCacheInfo *pPMKIDCache, uint32_t numItems,
14796 bool update_entire_cache)
14797{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014798 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014799 uint32_t i = 0;
14800 tPmkidCacheInfo *pmksa;
14801
14802 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014803 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014804 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014805 }
14806
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014807 sme_debug("numItems = %d", numItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014808
14809 if (numItems > CSR_MAX_PMKID_ALLOWED)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014810 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014811
14812#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
14813 csr_roam_diag_set_pmkid(pSession);
14814#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
14815
14816 if (update_entire_cache) {
14817 if (numItems && pPMKIDCache) {
14818 pSession->NumPmkidCache = (uint16_t) numItems;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014819 qdf_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014820 sizeof(tPmkidCacheInfo) * numItems);
14821 pSession->curr_cache_idx = (uint16_t)numItems;
14822 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014823 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014824 }
14825
14826 for (i = 0; i < numItems; i++) {
14827 pmksa = &pPMKIDCache[i];
14828
14829 /* Delete the entry if present */
14830 csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014831 pmksa, false);
14832 /* Update new entry */
14833 csr_update_pmk_cache(pSession, pmksa);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014834
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014835 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014836 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014837}
14838
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014839QDF_STATUS csr_roam_del_pmkid_from_cache(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014840 uint32_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014841 tPmkidCacheInfo *pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014842 bool flush_cache)
14843{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014844 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014845 bool fMatchFound = false;
14846 uint32_t Index;
14847 uint32_t curr_idx;
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014848 tPmkidCacheInfo *cached_pmksa;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014849 uint32_t i;
14850
14851 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014852 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014853 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014854 }
14855
14856 /* Check if there are no entries to delete */
14857 if (0 == pSession->NumPmkidCache) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014858 sme_debug("No entries to delete/Flush");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014859 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014860 }
14861
14862 if (flush_cache) {
14863 /* Flush the entire cache */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014864 qdf_mem_zero(pSession->PmkidCacheInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014865 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
14866 pSession->NumPmkidCache = 0;
14867 pSession->curr_cache_idx = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014868 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014869 }
14870
14871 /* !flush_cache - so look up in the cache */
14872 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014873 cached_pmksa = &pSession->PmkidCacheInfo[Index];
14874 if ((!cached_pmksa->ssid_len) &&
14875 qdf_is_macaddr_equal(&cached_pmksa->BSSID,
14876 &pmksa->BSSID))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014877 fMatchFound = 1;
14878
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014879 else if (cached_pmksa->ssid_len &&
14880 (!qdf_mem_cmp(cached_pmksa->ssid,
14881 pmksa->ssid, pmksa->ssid_len)) &&
14882 (!qdf_mem_cmp(cached_pmksa->cache_id,
14883 pmksa->cache_id, CACHE_ID_LEN)))
14884 fMatchFound = 1;
14885
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014886 if (fMatchFound) {
14887 /* Clear this - matched entry */
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014888 qdf_mem_zero(cached_pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014889 sizeof(tPmkidCacheInfo));
14890 break;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014891 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014892 }
14893
14894 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014895 sme_debug("No such PMKSA entry exists");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014896 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014897 }
14898
14899 /* Match Found, Readjust the other entries */
14900 curr_idx = pSession->curr_cache_idx;
14901 if (Index < curr_idx) {
14902 for (i = Index; i < (curr_idx - 1); i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014903 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014904 &pSession->PmkidCacheInfo[i + 1],
14905 sizeof(tPmkidCacheInfo));
14906 }
14907
14908 pSession->curr_cache_idx--;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014909 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014910 [pSession->curr_cache_idx],
14911 sizeof(tPmkidCacheInfo));
14912 } else if (Index > curr_idx) {
14913 for (i = Index; i > (curr_idx); i--) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014914 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014915 &pSession->PmkidCacheInfo[i - 1],
14916 sizeof(tPmkidCacheInfo));
14917 }
14918
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014919 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014920 [pSession->curr_cache_idx],
14921 sizeof(tPmkidCacheInfo));
14922 }
14923
14924 /* Decrement the count since an entry has been deleted */
14925 pSession->NumPmkidCache--;
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014926 sme_debug("PMKID at index=%d deleted, current index=%d cache count=%d",
14927 Index, pSession->curr_cache_idx, pSession->NumPmkidCache);
14928
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014929 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014930}
14931
14932uint32_t csr_roam_get_num_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId)
14933{
14934 return pMac->roam.roamSession[sessionId].NumPmkidCache;
14935}
14936
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014937QDF_STATUS csr_roam_get_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014938 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014939{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014940 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014941 tPmkidCacheInfo *pmksa;
14942 uint16_t i, j;
14943
14944 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014945 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014946 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014947 }
14948
14949 if (!pNum || !pPmkidCache) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014950 sme_err("Either pNum or pPmkidCache is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014951 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014952 }
14953
14954 if (pSession->NumPmkidCache == 0) {
14955 *pNum = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014956 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014957 }
14958
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014959 if (*pNum < pSession->NumPmkidCache)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014960 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014961
14962 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014963 sme_err("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014964 pSession->NumPmkidCache);
14965 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
14966 }
14967
14968 for (i = 0, j = 0; ((j < pSession->NumPmkidCache) &&
14969 (i < CSR_MAX_PMKID_ALLOWED)); i++) {
14970 /* Fill the valid entries */
14971 pmksa = &pSession->PmkidCacheInfo[i];
Anurag Chouhanc5548422016-02-24 18:33:27 +053014972 if (!qdf_is_macaddr_zero(&pmksa->BSSID)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014973 qdf_mem_copy(pPmkidCache, pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014974 sizeof(tPmkidCacheInfo));
14975 pPmkidCache++;
14976 j++;
14977 }
14978 }
14979
14980 *pNum = pSession->NumPmkidCache;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014981 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014982}
14983
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014984QDF_STATUS csr_roam_get_wpa_rsn_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014985 uint32_t *pLen, uint8_t *pBuf)
14986{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014987 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014988 uint32_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014989 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014990
14991 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014992 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014993 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014994 }
14995
14996 if (pLen) {
14997 len = *pLen;
14998 *pLen = pSession->nWpaRsnReqIeLength;
14999 if (pBuf) {
15000 if (len >= pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015001 qdf_mem_copy(pBuf, pSession->pWpaRsnReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015002 pSession->nWpaRsnReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015003 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015004 }
15005 }
15006 }
15007 return status;
15008}
15009
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015010QDF_STATUS csr_roam_get_wpa_rsn_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015011 uint32_t *pLen, uint8_t *pBuf)
15012{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015013 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015014 uint32_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015015 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015016
15017 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015018 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015019 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015020 }
15021
15022 if (pLen) {
15023 len = *pLen;
15024 *pLen = pSession->nWpaRsnRspIeLength;
15025 if (pBuf) {
15026 if (len >= pSession->nWpaRsnRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015027 qdf_mem_copy(pBuf, pSession->pWpaRsnRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015028 pSession->nWpaRsnRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015029 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015030 }
15031 }
15032 }
15033 return status;
15034}
15035
15036#ifdef FEATURE_WLAN_WAPI
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015037QDF_STATUS csr_roam_get_wapi_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015038 uint32_t *pLen, uint8_t *pBuf)
15039{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015040 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015041 uint32_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015042 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015043
15044 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015045 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015046 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015047 }
15048
15049 if (pLen) {
15050 len = *pLen;
15051 *pLen = pSession->nWapiReqIeLength;
15052 if (pBuf) {
15053 if (len >= pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015054 qdf_mem_copy(pBuf, pSession->pWapiReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015055 pSession->nWapiReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015056 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015057 }
15058 }
15059 }
15060 return status;
15061}
15062
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015063QDF_STATUS csr_roam_get_wapi_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015064 uint32_t *pLen, uint8_t *pBuf)
15065{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015066 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015067 uint32_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015068 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015069
15070 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015071 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015072 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015073 }
15074
15075 if (pLen) {
15076 len = *pLen;
15077 *pLen = pSession->nWapiRspIeLength;
15078 if (pBuf) {
15079 if (len >= pSession->nWapiRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015080 qdf_mem_copy(pBuf, pSession->pWapiRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015081 pSession->nWapiRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015082 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015083 }
15084 }
15085 }
15086 return status;
15087}
15088#endif /* FEATURE_WLAN_WAPI */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015089eRoamCmdStatus csr_get_roam_complete_status(tpAniSirGlobal pMac,
15090 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015091{
15092 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015093 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015094
15095 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015096 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015097 return retStatus;
15098 }
15099
15100 if (CSR_IS_ROAMING(pSession)) {
15101 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
15102 pSession->fRoaming = false;
15103 }
15104 return retStatus;
15105}
15106
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015107static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015108 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015109 tSirBssDescription *pBssDesc)
15110{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015111 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015112 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
15113 struct bss_config_param bssConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015114
15115 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015116 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015117 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015118 }
15119
15120 if (csr_is_conn_state_ibss(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015121 status = csr_roam_issue_stop_bss(pMac, sessionId,
15122 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015123 } else if (csr_is_conn_state_connected_infra(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015124 /* Disassociate from the connected Infrastructure network.*/
15125 status = csr_roam_issue_disassociate(pMac, sessionId,
15126 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015127 false);
15128 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015129 /* We don't expect Bt-AMP HDD not to disconnect the last
15130 * connection first at this time. Otherwise we need to add
15131 * code to handle the situation just like IBSS. Though for
15132 * WDS station, we need to send disassoc to PE first then
15133 * send stop_bss to PE, before we can continue.
15134 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015135
15136 if (csr_is_conn_state_wds(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053015137 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015138 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015139 }
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015140 qdf_mem_set(&bssConfig, sizeof(struct bss_config_param), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015141 /* Assume HDD provide bssid in profile */
Anurag Chouhanc5548422016-02-24 18:33:27 +053015142 qdf_copy_macaddr(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015143 pProfile->BSSIDs.bssid);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015144 /* there is no Bss description before we start an WDS so we
15145 * need to adopt all Bss configuration parameters from the
15146 * Profile.
15147 */
15148 status = csr_roam_prepare_bss_config_from_profile(pMac,
15149 pProfile,
15150 &bssConfig,
15151 pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015152 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015153 /* Save profile for late use */
15154 csr_free_roam_profile(pMac, sessionId);
15155 pSession->pCurRoamProfile =
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015156 qdf_mem_malloc(sizeof(struct csr_roam_profile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015157 if (pSession->pCurRoamProfile != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015158 csr_roam_copy_profile(pMac,
15159 pSession->pCurRoamProfile,
15160 pProfile);
15161 }
15162 /* Prepare some more parameters for this WDS */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015163 csr_roam_prepare_bss_params(pMac, sessionId, pProfile,
15164 NULL, &bssConfig, NULL);
15165 status = csr_roam_set_bss_config_cfg(pMac, sessionId,
15166 pProfile, NULL,
15167 &bssConfig, NULL,
15168 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015169 }
15170 }
15171
15172 return status;
15173}
15174
15175/**
15176 * csr_add_supported_5Ghz_channels()- Add valid 5Ghz channels
15177 * in Join req.
15178 * @mac_ctx: pointer to global mac structure
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015179 * @chan_list: Pointer to channel list buffer to populate
15180 * @num_chan: Pointer to number of channels value to update
15181 * @supp_chan_ie: Boolean to check if we need to populate as IE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015182 *
15183 * This function is called to update valid 5Ghz channels
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015184 * in Join req. If @supp_chan_ie is true, supported channels IE
15185 * format[chan num 1, num of channels 1, chan num 2, num of
15186 * channels 2, ..] is populated. Else, @chan_list would be a list
15187 * of supported channels[chan num 1, chan num 2..]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015188 *
15189 * Return: void
15190 */
15191static void csr_add_supported_5Ghz_channels(tpAniSirGlobal mac_ctx,
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015192 uint8_t *chan_list,
15193 uint8_t *num_chnl,
15194 bool supp_chan_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015195{
15196 uint16_t i, j;
15197 uint32_t size = 0;
15198
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015199 if (!chan_list) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015200 sme_err("chan_list buffer NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015201 return;
15202 }
15203
15204 size = sizeof(mac_ctx->roam.validChannelList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015205 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015206 (csr_get_cfg_valid_channels(mac_ctx,
15207 (uint8_t *) mac_ctx->roam.validChannelList,
15208 &size))) {
15209 for (i = 0, j = 0; i < size; i++) {
15210 /* Only add 5ghz channels.*/
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015211 if (WLAN_REG_IS_5GHZ_CH
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015212 (mac_ctx->roam.validChannelList[i])) {
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015213 chan_list[j]
15214 = mac_ctx->roam.validChannelList[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015215 j++;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015216
15217 if (supp_chan_ie) {
15218 chan_list[j] = 1;
15219 j++;
15220 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015221 }
15222 }
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015223 *num_chnl = (uint8_t)j;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015224 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015225 sme_err("can not find any valid channel");
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015226 *num_chnl = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015227 }
15228}
15229
15230/**
Krunal Soni0193b6f2016-08-15 15:53:43 -070015231 * csr_set_ldpc_exception() - to set allow any LDPC exception permitted
15232 * @mac_ctx: Pointer to mac context
15233 * @session: Pointer to SME/CSR session
15234 * @channel: Given channel number where connection will go
15235 * @usr_cfg_rx_ldpc: User provided RX LDPC setting
15236 *
15237 * This API will check if hardware allows LDPC to be enabled for provided
15238 * channel and user has enabled the RX LDPC selection
15239 *
15240 * Return: QDF_STATUS
15241 */
15242static QDF_STATUS csr_set_ldpc_exception(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015243 struct csr_roam_session *session, uint8_t channel,
Krunal Soni0193b6f2016-08-15 15:53:43 -070015244 bool usr_cfg_rx_ldpc)
15245{
15246 if (!mac_ctx) {
Varun Reddy Yeturu5a183652016-09-09 15:36:00 -070015247 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15248 "mac_ctx is NULL");
Krunal Soni0193b6f2016-08-15 15:53:43 -070015249 return QDF_STATUS_E_FAILURE;
15250 }
15251 if (!session) {
Varun Reddy Yeturu5a183652016-09-09 15:36:00 -070015252 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15253 "session is NULL");
Krunal Soni0193b6f2016-08-15 15:53:43 -070015254 return QDF_STATUS_E_FAILURE;
15255 }
15256 if (usr_cfg_rx_ldpc && wma_is_rx_ldpc_supported_for_channel(channel)) {
15257 session->htConfig.ht_rx_ldpc = 1;
15258 session->vht_config.ldpc_coding = 1;
Abhishek Singh245182f2017-08-10 17:41:09 +053015259 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Krunal Soni0193b6f2016-08-15 15:53:43 -070015260 "LDPC enable for chnl[%d]", channel);
15261 } else {
15262 session->htConfig.ht_rx_ldpc = 0;
15263 session->vht_config.ldpc_coding = 0;
Abhishek Singh245182f2017-08-10 17:41:09 +053015264 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Krunal Soni0193b6f2016-08-15 15:53:43 -070015265 "LDPC disable for chnl[%d]", channel);
15266 }
15267 return QDF_STATUS_SUCCESS;
15268}
15269
Abhishek Singhcfb44482017-03-10 12:42:37 +053015270#ifdef WLAN_FEATURE_11W
15271/**
Srinivas Girigowda6519b932017-08-03 14:10:57 -070015272 * csr_is_mfpc_capable() - is MFPC capable
15273 * @ies: AP information element
15274 *
15275 * Return: true if MFPC capable, false otherwise
15276 */
15277bool csr_is_mfpc_capable(struct sDot11fIERSN *rsn)
15278{
15279 bool mfpc_capable = false;
15280
15281 if (rsn && rsn->present &&
15282 ((rsn->RSN_Cap[0] >> 7) & 0x01))
15283 mfpc_capable = true;
15284
15285 return mfpc_capable;
15286}
15287
15288/**
Abhishek Singhcfb44482017-03-10 12:42:37 +053015289 * csr_set_mgmt_enc_type() - set mgmt enc type for PMF
15290 * @profile: roam profile
15291 * @ies: AP ie
15292 * @csr_join_req: csr join req
15293 *
15294 * Return: void
15295 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015296static void csr_set_mgmt_enc_type(struct csr_roam_profile *profile,
15297 tDot11fBeaconIEs *ies,
15298 tSirSmeJoinReq *csr_join_req)
Abhishek Singhcfb44482017-03-10 12:42:37 +053015299{
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +053015300 sme_debug("mgmt encryption type %d MFPe %d MFPr %d",
15301 profile->mgmt_encryption_type,
15302 profile->MFPEnabled, profile->MFPRequired);
15303
Abhishek Singhcfb44482017-03-10 12:42:37 +053015304 if (profile->MFPEnabled)
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +053015305 csr_join_req->MgmtEncryptionType =
15306 profile->mgmt_encryption_type;
Abhishek Singhcfb44482017-03-10 12:42:37 +053015307 else
15308 csr_join_req->MgmtEncryptionType = eSIR_ED_NONE;
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +053015309
Abhishek Singhcfb44482017-03-10 12:42:37 +053015310 if (profile->MFPEnabled &&
15311 !(profile->MFPRequired) &&
Srinivas Girigowda6519b932017-08-03 14:10:57 -070015312 !csr_is_mfpc_capable(&ies->RSN))
Abhishek Singhcfb44482017-03-10 12:42:37 +053015313 csr_join_req->MgmtEncryptionType = eSIR_ED_NONE;
15314}
15315#else
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015316static inline void csr_set_mgmt_enc_type(struct csr_roam_profile *profile,
15317 tDot11fBeaconIEs *pIes,
15318 tSirSmeJoinReq *csr_join_req)
Abhishek Singhcfb44482017-03-10 12:42:37 +053015319{
15320}
15321#endif
15322
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053015323#ifdef WLAN_FEATURE_FILS_SK
15324/*
15325 * csr_update_fils_connection_info: Copy fils connection info to join request
15326 * @profile: pointer to profile
15327 * @csr_join_req: csr join request
15328 *
15329 * Return: None
15330 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015331static void csr_update_fils_connection_info(struct csr_roam_profile *profile,
15332 tSirSmeJoinReq *csr_join_req)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053015333{
15334 if (!profile->fils_con_info)
15335 return;
15336
15337 if (profile->fils_con_info->is_fils_connection) {
15338 qdf_mem_copy(&csr_join_req->fils_con_info,
15339 profile->fils_con_info,
15340 sizeof(struct cds_fils_connection_info));
15341 } else {
15342 qdf_mem_zero(&csr_join_req->fils_con_info,
15343 sizeof(struct cds_fils_connection_info));
15344 }
15345}
15346#else
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015347static void csr_update_fils_connection_info(struct csr_roam_profile *profile,
15348 tSirSmeJoinReq *csr_join_req)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053015349{ }
15350#endif
Abhishek Singhcfb44482017-03-10 12:42:37 +053015351
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +053015352#ifdef WLAN_FEATURE_SAE
15353/*
15354 * csr_update_sae_config: Copy SAE info to join request
15355 * @profile: pointer to profile
15356 * @csr_join_req: csr join request
15357 *
15358 * Return: None
15359 */
15360static void csr_update_sae_config(tSirSmeJoinReq *csr_join_req,
15361 tpAniSirGlobal mac, struct csr_roam_session *session)
15362{
15363 tPmkidCacheInfo pmkid_cache;
15364 uint32_t index;
15365
15366 qdf_mem_copy(pmkid_cache.BSSID.bytes,
15367 csr_join_req->bssDescription.bssId, QDF_MAC_ADDR_SIZE);
15368
15369 csr_join_req->sae_pmk_cached =
15370 csr_lookup_pmkid_using_bssid(mac, session, &pmkid_cache, &index);
15371
15372 sme_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
15373 csr_join_req->sae_pmk_cached,
15374 MAC_ADDR_ARRAY(csr_join_req->bssDescription.bssId));
15375}
15376#else
15377static void csr_update_sae_config(tSirSmeJoinReq *csr_join_req,
15378 tpAniSirGlobal mac, struct csr_roam_session *session)
15379{ }
15380#endif
15381
Krunal Soni0193b6f2016-08-15 15:53:43 -070015382/**
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015383 * csr_get_nss_supported_by_sta_and_ap() - finds out nss from session
15384 * and beacon from AP
15385 * @vht_caps: VHT capabilities
15386 * @ht_caps: HT capabilities
15387 * @dot11_mode: dot11 mode
15388 *
15389 * Return: number of nss advertised by beacon
15390 */
15391static uint8_t csr_get_nss_supported_by_sta_and_ap(tDot11fIEVHTCaps *vht_caps,
15392 tDot11fIEHTCaps *ht_caps,
15393 uint32_t dot11_mode)
15394{
15395 bool vht_capability, ht_capability;
15396
15397 vht_capability = IS_DOT11_MODE_VHT(dot11_mode);
15398 ht_capability = IS_DOT11_MODE_HT(dot11_mode);
15399
15400 if (vht_capability && vht_caps->present) {
15401 if ((vht_caps->rxMCSMap & 0xC0) != 0xC0)
15402 return 4;
15403
15404 if ((vht_caps->rxMCSMap & 0x30) != 0x30)
15405 return 3;
15406
15407 if ((vht_caps->rxMCSMap & 0x0C) != 0x0C)
15408 return 2;
15409 } else if (ht_capability && ht_caps->present) {
15410 if (ht_caps->supportedMCSSet[3])
15411 return 4;
15412
15413 if (ht_caps->supportedMCSSet[2])
15414 return 3;
15415
15416 if (ht_caps->supportedMCSSet[1])
15417 return 2;
15418 }
15419
15420 return 1;
15421}
15422
15423/**
15424 * csr_dump_vendor_ies() - Dumps all the vendor IEs
15425 * @ie: ie buffer
15426 * @ie_len: length of ie buffer
15427 *
15428 * This function dumps the vendor IEs present in the AP's IE buffer
15429 *
15430 * Return: none
15431 */
15432static
15433void csr_dump_vendor_ies(uint8_t *ie, uint16_t ie_len)
15434{
15435 int32_t left = ie_len;
15436 uint8_t *ptr = ie;
15437 uint8_t elem_id, elem_len;
15438
15439 while (left >= 2) {
15440 elem_id = ptr[0];
15441 elem_len = ptr[1];
15442 left -= 2;
15443 if (elem_len > left) {
Vignesh Viswanathanf9a704c2018-07-30 12:57:18 +053015444 sme_err("Invalid IEs eid: %d elem_len: %d left: %d",
15445 elem_id, elem_len, left);
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015446 return;
15447 }
15448 if (elem_id == SIR_MAC_EID_VENDOR) {
Vignesh Viswanathanf9a704c2018-07-30 12:57:18 +053015449 sme_debug("Dumping Vendor IE of len %d", elem_len);
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015450 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
15451 QDF_TRACE_LEVEL_DEBUG,
15452 &ptr[2], elem_len);
15453 }
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015454 left -= elem_len;
15455 ptr += (elem_len + 2);
15456 }
15457}
15458
15459/**
15460 * csr_check_vendor_ap_3_present() - Check if Vendor AP 3 is present
15461 * @mac_ctx: Pointer to Global MAC structure
15462 * @ie: Pointer to starting IE in Beacon/Probe Response
15463 * @ie_len: Length of all IEs combined
15464 *
15465 * For Vendor AP 3, the condition is that Vendor AP 3 IE should be present
15466 * and Vendor AP 4 IE should not be present.
15467 * If Vendor AP 3 IE is present and Vendor AP 4 IE is also present,
15468 * return false, else return true.
15469 *
15470 * Return: true or false
15471 */
15472static bool
15473csr_check_vendor_ap_3_present(tpAniSirGlobal mac_ctx, uint8_t *ie,
15474 uint16_t ie_len)
15475{
15476 bool ret = true;
15477
15478 if ((wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_VENDOR_AP_3_OUI,
15479 SIR_MAC_VENDOR_AP_3_OUI_LEN, ie, ie_len)) &&
15480 (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_VENDOR_AP_4_OUI,
15481 SIR_MAC_VENDOR_AP_4_OUI_LEN, ie, ie_len))) {
Vignesh Viswanathanf9a704c2018-07-30 12:57:18 +053015482 sme_debug("Vendor OUI 3 and Vendor OUI 4 found");
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015483 ret = false;
15484 }
15485
15486 return ret;
15487}
15488
15489/**
Arif Hussain6686c0b2018-08-21 18:21:05 -070015490 * csr_enable_twt() - Check if its allowed to enable twt for this session
15491 * @ie: pointer to beacon/probe resp ie's
15492 *
15493 * TWT is allowed only if device is in 11ax mode or if QCN ie present.
15494 *
15495 * Return: true or flase
15496 */
15497static bool csr_enable_twt(tDot11fBeaconIEs *ie)
15498{
15499 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
15500 return true;
15501
15502 if (!ie) {
15503 sme_debug("Beacon ie buffer is null");
15504 return false;
15505 }
15506
15507 return ie->QCN_IE.present;
15508}
15509
15510/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015511 * The communication between HDD and LIM is thru mailbox (MB).
15512 * Both sides will access the data structure "tSirSmeJoinReq".
15513 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the
15514 * regular way like tSirSmeJoinReq.assocType, this guideline stops at component
15515 * tSirRSNie;
15516 * any acces to the components after tSirRSNie is forbidden because the space
15517 * from tSirRSNie is squeezed with the component "tSirBssDescription" and since
15518 * the size of actual 'tSirBssDescription' varies, the receiving side should
15519 * keep in mind not to access the components DIRECTLY after tSirRSNie.
15520 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015521QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015522 tSirBssDescription *pBssDescription,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015523 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015524 tDot11fBeaconIEs *pIes, uint16_t messageType)
15525{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015526 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015527 uint8_t acm_mask = 0, uapsd_mask;
15528 uint16_t msgLen, ieLen;
15529 tSirMacRateSet OpRateSet;
15530 tSirMacRateSet ExRateSet;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015531 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015532 uint32_t dwTmp, ucDot11Mode = 0;
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053015533 uint8_t *wpaRsnIE = NULL;
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080015534 uint8_t txBFCsnValue = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015535 tSirSmeJoinReq *csr_join_req;
15536 tSirMacCapabilityInfo *pAP_capabilityInfo;
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070015537 bool fTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015538 int8_t pwrLimit = 0;
15539 struct ps_global_info *ps_global_info = &pMac->sme.ps_global_info;
15540 struct ps_params *ps_param = &ps_global_info->ps_params[sessionId];
Krunal Sonia5d89ad2018-05-30 16:35:51 -070015541 uint8_t ese_config = 0, channel_id;
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015542 tpCsrNeighborRoamControlInfo neigh_roam_info;
Krunal Soni53993f72016-07-08 18:20:03 -070015543 uint32_t value = 0, value1 = 0;
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053015544 QDF_STATUS packetdump_timer_status;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015545 bool is_vendor_ap_present;
15546 struct vdev_type_nss *vdev_type_nss;
15547 struct action_oui_search_attr vendor_ap_search_attr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015548
15549 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015550 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015551 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015552 }
15553 /* To satisfy klockworks */
15554 if (NULL == pBssDescription) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015555 sme_err(" pBssDescription is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015556 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015557 }
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015558 neigh_roam_info = &pMac->roam.neighborRoamInfo[sessionId];
15559 if ((eWNI_SME_REASSOC_REQ == messageType) ||
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015560 WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId) ||
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015561 (abs(pBssDescription->rssi) <
Varun Reddy Yeturuf64252a2016-05-13 15:02:03 -070015562 (neigh_roam_info->cfgParams.neighborLookupThreshold -
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015563 neigh_roam_info->cfgParams.hi_rssi_scan_rssi_delta))) {
15564 pSession->disable_hi_rssi = true;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015565 sme_debug(
15566 "Disabling HI_RSSI feature, AP channel=%d, rssi=%d",
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015567 pBssDescription->channelId, pBssDescription->rssi);
15568 } else {
15569 pSession->disable_hi_rssi = false;
15570 }
15571
Krunal Sonia5d89ad2018-05-30 16:35:51 -070015572 /*
15573 * When STA's join req times out on current BSS, SME issues next BSS
15574 * internally without checking HW mode for new channel.
15575 *
15576 * For example, STA tries to connect SSID="abc",
15577 * BSSID="a1:a2:a3:a4:a5:a6", channel=36 and lets say it fails. It
15578 * should try few more times to same BSSID and after that it will try
15579 * next bss. Lets say next BSS it found has, SSID="abc",
15580 * BSSID="b1:b2:b3:b4:b5:b6", channel=1 then it needs to check whether
15581 * hardware mode change is required for channel=1. If driver fails in
15582 * checking hardware mode then following check will prevent the bad
15583 * situation.
15584 */
15585 channel_id = pBssDescription->channelId;
15586 if (!policy_mgr_is_hwmode_set_for_given_chnl(pMac->psoc, channel_id)) {
15587 sme_err("HW mode is not properly set for channel %d",
15588 channel_id);
15589 return QDF_STATUS_E_FAILURE;
15590 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015591
15592 do {
15593 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15594 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015595 qdf_mem_copy(&pSession->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015596 &pBssDescription->bssId, sizeof(tSirMacAddr));
15597 /*
15598 * the tSirSmeJoinReq which includes a single
15599 * bssDescription. it includes a single uint32_t for the
15600 * IE fields, but the length field in the bssDescription
15601 * needs to be interpreted to determine length of IE fields
15602 * So, take the size of the tSirSmeJoinReq, subtract size of
15603 * bssDescription, add the number of bytes indicated by the
15604 * length field of the bssDescription, add the size of length
Jeff Johnsonfe8e9492018-05-06 15:40:52 -070015605 * field because it not included in the length field.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015606 */
15607 msgLen = sizeof(tSirSmeJoinReq) - sizeof(*pBssDescription) +
15608 pBssDescription->length +
15609 sizeof(pBssDescription->length) +
15610 /*
15611 * add in the size of the WPA IE that
15612 * we may build.
15613 */
15614 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) +
15615 sizeof(uint16_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015616 csr_join_req = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015617 if (NULL == csr_join_req)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015618 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015619 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015620 status = QDF_STATUS_SUCCESS;
15621 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015622 break;
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053015623
15624 wpaRsnIE = qdf_mem_malloc(DOT11F_IE_RSN_MAX_LEN);
15625 if (NULL == wpaRsnIE)
15626 status = QDF_STATUS_E_NOMEM;
15627
15628 if (!QDF_IS_STATUS_SUCCESS(status))
15629 break;
15630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015631 csr_join_req->messageType = messageType;
15632 csr_join_req->length = msgLen;
15633 csr_join_req->sessionId = (uint8_t) sessionId;
15634 csr_join_req->transactionId = 0;
15635 if (pIes->SSID.present && pIes->SSID.num_ssid) {
15636 csr_join_req->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015637 qdf_mem_copy(&csr_join_req->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015638 pIes->SSID.num_ssid);
15639 } else
15640 csr_join_req->ssId.length = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015641 qdf_mem_copy(&csr_join_req->selfMacAddr, &pSession->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015642 sizeof(tSirMacAddr));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015643 sme_err("Connecting to ssid:%.*s bssid: "MAC_ADDRESS_STR" rssi: %d channel: %d country_code: %c%c",
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -080015644 pIes->SSID.num_ssid, pIes->SSID.ssid,
15645 MAC_ADDR_ARRAY(pBssDescription->bssId),
15646 pBssDescription->rssi, pBssDescription->channelId,
15647 pMac->scan.countryCodeCurrent[0],
15648 pMac->scan.countryCodeCurrent[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015649 /* bsstype */
15650 dwTmp = csr_translate_bsstype_to_mac_type
15651 (pProfile->BSSType);
Rajeev Kumarc9a50e72016-04-15 15:18:42 -070015652 csr_join_req->bsstype = dwTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015653 /* dot11mode */
15654 ucDot11Mode =
15655 csr_translate_to_wni_cfg_dot11_mode(pMac,
15656 pSession->bssParams.
15657 uCfgDot11Mode);
15658 if (pBssDescription->channelId <= 14
15659 && false == pMac->roam.configParam.enableVhtFor24GHz
15660 && WNI_CFG_DOT11_MODE_11AC == ucDot11Mode) {
15661 /* Need to disable VHT operation in 2.4 GHz band */
15662 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
15663 }
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015664
15665 if (IS_5G_CH(pBssDescription->channelId))
15666 vdev_type_nss = &pMac->vdev_type_nss_5g;
15667 else
15668 vdev_type_nss = &pMac->vdev_type_nss_2g;
15669 if (pSession->pCurRoamProfile->csrPersona ==
15670 QDF_P2P_CLIENT_MODE)
15671 pSession->vdev_nss = vdev_type_nss->p2p_cli;
15672 else
15673 pSession->vdev_nss = vdev_type_nss->sta;
15674 pSession->nss = pSession->vdev_nss;
15675
15676 if (pSession->nss > csr_get_nss_supported_by_sta_and_ap(
15677 &pIes->VHTCaps,
15678 &pIes->HTCaps, ucDot11Mode)) {
15679 pSession->nss = csr_get_nss_supported_by_sta_and_ap(
15680 &pIes->VHTCaps, &pIes->HTCaps,
15681 ucDot11Mode);
15682 pSession->vdev_nss = pSession->nss;
15683 }
15684
15685 if (!pMac->roam.configParam.enable2x2)
15686 pSession->nss = 1;
15687
15688 if (pSession->nss == 1)
15689 pSession->supported_nss_1x1 = true;
15690
15691 ieLen = csr_get_ielen_from_bss_description(pBssDescription);
15692
15693 /* Dump the Vendor Specific IEs*/
15694 csr_dump_vendor_ies((uint8_t *)&pBssDescription->ieFields[0],
15695 ieLen);
15696
15697 /* Fill the Vendor AP search params */
15698 vendor_ap_search_attr.ie_data =
15699 (uint8_t *)&pBssDescription->ieFields[0];
15700 vendor_ap_search_attr.ie_length = ieLen;
15701 vendor_ap_search_attr.mac_addr = &pBssDescription->bssId[0];
15702 vendor_ap_search_attr.nss = csr_get_nss_supported_by_sta_and_ap(
15703 &pIes->VHTCaps, &pIes->HTCaps,
15704 ucDot11Mode);
15705 vendor_ap_search_attr.ht_cap = pIes->HTCaps.present;
15706 vendor_ap_search_attr.vht_cap = pIes->VHTCaps.present;
15707 vendor_ap_search_attr.enable_2g =
15708 IS_24G_CH(pBssDescription->channelId);
15709 vendor_ap_search_attr.enable_5g =
15710 IS_5G_CH(pBssDescription->channelId);
15711
15712 is_vendor_ap_present =
15713 ucfg_action_oui_search(pMac->psoc,
15714 &vendor_ap_search_attr,
15715 ACTION_OUI_CONNECT_1X1);
15716
15717 if (is_vendor_ap_present) {
15718 is_vendor_ap_present = csr_check_vendor_ap_3_present(
15719 pMac, (uint8_t *)pIes, ieLen);
15720 }
15721
Vignesh Viswanathanf9a704c2018-07-30 12:57:18 +053015722 /*
15723 * For WMI_ACTION_OUI_CONNECT_1x1_WITH_1_CHAIN, the host
15724 * sends the NSS as 1 to the FW and the FW then decides
15725 * after receiving the first beacon after connection to
15726 * switch to 1 Tx/Rx Chain.
15727 */
15728
15729 if (!is_vendor_ap_present) {
15730 is_vendor_ap_present =
15731 ucfg_action_oui_search(pMac->psoc,
15732 &vendor_ap_search_attr,
15733 ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN);
15734 if (is_vendor_ap_present)
15735 sme_debug("1x1 with 1 Chain AP");
15736 }
15737
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015738 if (pMac->roam.configParam.is_force_1x1 &&
15739 pMac->lteCoexAntShare &&
15740 is_vendor_ap_present) {
15741 pSession->supported_nss_1x1 = true;
15742 pSession->vdev_nss = 1;
15743 pSession->nss = 1;
15744 pSession->nss_forced_1x1 = true;
15745 sme_debug("For special ap, NSS: %d", pSession->nss);
15746 }
15747
15748 /*
15749 * If CCK WAR is set for current AP, update to firmware via
15750 * WMI_VDEV_PARAM_ABG_MODE_TX_CHAIN_NUM
15751 */
15752 is_vendor_ap_present =
15753 ucfg_action_oui_search(pMac->psoc,
15754 &vendor_ap_search_attr,
15755 ACTION_OUI_CCKM_1X1);
15756 if (is_vendor_ap_present) {
Vignesh Viswanathanf9a704c2018-07-30 12:57:18 +053015757 sme_debug("vdev: %d WMI_VDEV_PARAM_ABG_MODE_TX_CHAIN_NUM 1",
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015758 pSession->sessionId);
15759 wma_cli_set_command(
15760 pSession->sessionId,
15761 (int)WMI_VDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, 1,
15762 VDEV_CMD);
15763 }
15764
15765 /*
15766 * If Switch to 11N WAR is set for current AP, change dot11
15767 * mode to 11N.
15768 */
15769 is_vendor_ap_present =
15770 ucfg_action_oui_search(pMac->psoc,
15771 &vendor_ap_search_attr,
15772 ACTION_OUI_SWITCH_TO_11N_MODE);
15773 if (pMac->roam.configParam.is_force_1x1 &&
15774 pMac->lteCoexAntShare &&
15775 is_vendor_ap_present &&
15776 (ucDot11Mode == WNI_CFG_DOT11_MODE_ALL ||
15777 ucDot11Mode == WNI_CFG_DOT11_MODE_11AC ||
15778 ucDot11Mode == WNI_CFG_DOT11_MODE_11AC_ONLY))
15779 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
15780
15781 csr_join_req->supported_nss_1x1 = pSession->supported_nss_1x1;
15782 csr_join_req->vdev_nss = pSession->vdev_nss;
15783 csr_join_req->nss = pSession->nss;
15784 csr_join_req->nss_forced_1x1 = pSession->nss_forced_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015785 csr_join_req->dot11mode = (uint8_t) ucDot11Mode;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +053015786 sme_debug("dot11mode=%d, uCfgDot11Mode=%d nss=%d",
15787 csr_join_req->dot11mode,
15788 pSession->bssParams.uCfgDot11Mode,
15789 csr_join_req->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015790#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
15791 csr_join_req->cc_switch_mode =
15792 pMac->roam.configParam.cc_switch_mode;
15793#endif
15794 csr_join_req->staPersona = (uint8_t) pProfile->csrPersona;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +053015795 csr_join_req->wps_registration = pProfile->bWPSAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015796 csr_join_req->cbMode = (uint8_t) pSession->bssParams.cbMode;
Abhishek Singhb59f8d42017-07-31 14:42:47 +053015797 csr_join_req->force_24ghz_in_ht20 =
15798 pProfile->force_24ghz_in_ht20;
15799 sme_debug("CSR PERSONA: %d CSR CbMode: %d force 24gh ht20 %d",
15800 pProfile->csrPersona, pSession->bssParams.cbMode,
15801 csr_join_req->force_24ghz_in_ht20);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015802 csr_join_req->uapsdPerAcBitmask = pProfile->uapsd_mask;
Naveen Rawatcd118312016-11-22 10:46:21 -080015803 pSession->uapsd_mask = pProfile->uapsd_mask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015804 status =
15805 csr_get_rate_set(pMac, pProfile,
15806 (eCsrPhyMode) pProfile->phyMode,
15807 pBssDescription, pIes, &OpRateSet,
15808 &ExRateSet);
15809 ps_param->uapsd_per_ac_bit_mask =
15810 pProfile->uapsd_mask;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015811 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015812 /* OperationalRateSet */
15813 if (OpRateSet.numRates) {
15814 csr_join_req->operationalRateSet.numRates =
15815 OpRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015816 qdf_mem_copy(&csr_join_req->operationalRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015817 rate, OpRateSet.rate,
15818 OpRateSet.numRates);
15819 } else
15820 csr_join_req->operationalRateSet.numRates = 0;
15821
15822 /* ExtendedRateSet */
15823 if (ExRateSet.numRates) {
15824 csr_join_req->extendedRateSet.numRates =
15825 ExRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015826 qdf_mem_copy(&csr_join_req->extendedRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015827 rate, ExRateSet.rate,
15828 ExRateSet.numRates);
15829 } else
15830 csr_join_req->extendedRateSet.numRates = 0;
15831 } else {
15832 csr_join_req->operationalRateSet.numRates = 0;
15833 csr_join_req->extendedRateSet.numRates = 0;
15834 }
15835 /* rsnIE */
15836 if (csr_is_profile_wpa(pProfile)) {
15837 /* Insert the Wpa IE into the join request */
15838 ieLen =
15839 csr_retrieve_wpa_ie(pMac, pProfile,
15840 pBssDescription, pIes,
15841 (tCsrWpaIe *) (wpaRsnIE));
15842 } else if (csr_is_profile_rsn(pProfile)) {
15843 /* Insert the RSN IE into the join request */
15844 ieLen =
15845 csr_retrieve_rsn_ie(pMac, sessionId, pProfile,
15846 pBssDescription, pIes,
15847 (tCsrRSNIe *) (wpaRsnIE));
Abhishek Singh6454ad32017-12-20 10:42:21 +053015848 csr_join_req->force_rsne_override =
15849 pProfile->force_rsne_override;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015850 }
15851#ifdef FEATURE_WLAN_WAPI
15852 else if (csr_is_profile_wapi(pProfile)) {
15853 /* Insert the WAPI IE into the join request */
15854 ieLen =
15855 csr_retrieve_wapi_ie(pMac, sessionId, pProfile,
15856 pBssDescription, pIes,
15857 (tCsrWapiIe *) (wpaRsnIE));
15858 }
15859#endif /* FEATURE_WLAN_WAPI */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015860 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015861 ieLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015862 /* remember the IE for future use */
15863 if (ieLen) {
15864 if (ieLen > DOT11F_IE_RSN_MAX_LEN) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015865 sme_err("WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015866 ieLen, DOT11F_IE_RSN_MAX_LEN);
15867 ieLen = DOT11F_IE_RSN_MAX_LEN;
15868 }
15869#ifdef FEATURE_WLAN_WAPI
15870 if (csr_is_profile_wapi(pProfile)) {
15871 /* Check whether we need to allocate more mem */
15872 if (ieLen > pSession->nWapiReqIeLength) {
15873 if (pSession->pWapiReqIE
15874 && pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015875 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015876 pWapiReqIE);
15877 }
15878 pSession->pWapiReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015879 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015880 if (NULL == pSession->pWapiReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015881 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015882 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015883 status = QDF_STATUS_SUCCESS;
15884 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015885 break;
15886 }
15887 pSession->nWapiReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015888 qdf_mem_copy(pSession->pWapiReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015889 ieLen);
15890 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015891 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015892 wpaRsnIE, ieLen);
15893 } else /* should be WPA/WPA2 otherwise */
15894#endif /* FEATURE_WLAN_WAPI */
15895 {
15896 /* Check whether we need to allocate more mem */
15897 if (ieLen > pSession->nWpaRsnReqIeLength) {
15898 if (pSession->pWpaRsnReqIE
15899 && pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015900 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015901 pWpaRsnReqIE);
15902 }
15903 pSession->pWpaRsnReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015904 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015905 if (NULL == pSession->pWpaRsnReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015906 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015907 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015908 status = QDF_STATUS_SUCCESS;
15909 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015910 break;
15911 }
15912 pSession->nWpaRsnReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015913 qdf_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015914 ieLen);
15915 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015916 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015917 wpaRsnIE, ieLen);
15918 }
15919 } else {
15920 /* free whatever old info */
15921 pSession->nWpaRsnReqIeLength = 0;
15922 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015923 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015924 pSession->pWpaRsnReqIE = NULL;
15925 }
15926#ifdef FEATURE_WLAN_WAPI
15927 pSession->nWapiReqIeLength = 0;
15928 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015929 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015930 pSession->pWapiReqIE = NULL;
15931 }
15932#endif /* FEATURE_WLAN_WAPI */
15933 csr_join_req->rsnIE.length = 0;
15934 }
15935#ifdef FEATURE_WLAN_ESE
15936 if (eWNI_SME_JOIN_REQ == messageType)
15937 csr_join_req->cckmIE.length = 0;
15938 else if (eWNI_SME_REASSOC_REQ == messageType) {
15939 /* cckmIE */
15940 if (csr_is_profile_ese(pProfile)) {
15941 /* Insert the CCKM IE into the join request */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015942 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015943 qdf_mem_copy((void *)(wpaRsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015944 pSession->suppCckmIeInfo.cckmIe,
15945 ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015946 } else
15947 ieLen = 0;
15948 /*
15949 * If present, copy the IE into the
15950 * eWNI_SME_REASSOC_REQ message buffer
15951 */
15952 if (ieLen) {
15953 /*
15954 * Copy the CCKM IE over from the temp
15955 * buffer (wpaRsnIE)
15956 */
15957 csr_join_req->cckmIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015958 qdf_mem_copy(&csr_join_req->cckmIE.cckmIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015959 wpaRsnIE, ieLen);
15960 } else
15961 csr_join_req->cckmIE.length = 0;
15962 }
15963#endif /* FEATURE_WLAN_ESE */
15964 /* addIEScan */
15965 if (pProfile->nAddIEScanLength && pProfile->pAddIEScan) {
15966 ieLen = pProfile->nAddIEScanLength;
15967 if (ieLen > pSession->nAddIEScanLength) {
15968 if (pSession->pAddIEScan
15969 && pSession->nAddIEScanLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015970 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015971 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015972 pSession->pAddIEScan = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015973 if (NULL == pSession->pAddIEScan)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015974 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015975 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015976 status = QDF_STATUS_SUCCESS;
15977 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015978 break;
15979 }
15980 pSession->nAddIEScanLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015981 qdf_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015982 ieLen);
15983 csr_join_req->addIEScan.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015984 qdf_mem_copy(&csr_join_req->addIEScan.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015985 pProfile->pAddIEScan, ieLen);
15986 } else {
15987 pSession->nAddIEScanLength = 0;
15988 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015989 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015990 pSession->pAddIEScan = NULL;
15991 }
15992 csr_join_req->addIEScan.length = 0;
15993 }
15994 /* addIEAssoc */
15995 if (pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc) {
15996 ieLen = pProfile->nAddIEAssocLength;
15997 if (ieLen > pSession->nAddIEAssocLength) {
15998 if (pSession->pAddIEAssoc
15999 && pSession->nAddIEAssocLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016000 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016001 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016002 pSession->pAddIEAssoc = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016003 if (NULL == pSession->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016004 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016005 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016006 status = QDF_STATUS_SUCCESS;
16007 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016008 break;
16009 }
16010 pSession->nAddIEAssocLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016011 qdf_mem_copy(pSession->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016012 pProfile->pAddIEAssoc, ieLen);
16013 csr_join_req->addIEAssoc.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016014 qdf_mem_copy(&csr_join_req->addIEAssoc.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016015 pProfile->pAddIEAssoc, ieLen);
16016 } else {
16017 pSession->nAddIEAssocLength = 0;
16018 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016019 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016020 pSession->pAddIEAssoc = NULL;
16021 }
16022 csr_join_req->addIEAssoc.length = 0;
16023 }
16024
16025 if (eWNI_SME_REASSOC_REQ == messageType) {
16026 /* Unmask any AC in reassoc that is ACM-set */
16027 uapsd_mask = (uint8_t) pProfile->uapsd_mask;
16028 if (uapsd_mask && (NULL != pBssDescription)) {
16029 if (CSR_IS_QOS_BSS(pIes)
16030 && CSR_IS_UAPSD_BSS(pIes))
16031#ifndef WLAN_MDM_CODE_REDUCTION_OPT
16032 acm_mask =
16033 sme_qos_get_acm_mask(pMac,
16034 pBssDescription,
16035 pIes);
16036#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
16037 else
16038 uapsd_mask = 0;
16039 }
16040 }
16041
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -080016042 if (!CSR_IS_11n_ALLOWED(pProfile->negotiatedUCEncryptionType))
16043 csr_join_req->he_with_wep_tkip =
16044 pMac->roam.configParam.wep_tkip_in_he;
16045
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016046 csr_join_req->UCEncryptionType =
16047 csr_translate_encrypt_type_to_ed_type
16048 (pProfile->negotiatedUCEncryptionType);
16049
16050 csr_join_req->MCEncryptionType =
16051 csr_translate_encrypt_type_to_ed_type
16052 (pProfile->negotiatedMCEncryptionType);
Abhishek Singhcfb44482017-03-10 12:42:37 +053016053 csr_set_mgmt_enc_type(pProfile, pIes, csr_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016054#ifdef FEATURE_WLAN_ESE
16055 ese_config = pMac->roam.configParam.isEseIniFeatureEnabled;
16056#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016057 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Abhinav Kumar271f0632018-03-29 16:01:30 +053016058 if (csr_is_profile11r(pMac, pProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016059#ifdef FEATURE_WLAN_ESE
16060 &&
16061 !((pProfile->negotiatedAuthType ==
16062 eCSR_AUTH_TYPE_OPEN_SYSTEM) && (pIes->ESEVersion.present)
16063 && (ese_config))
16064#endif
16065 )
16066 csr_join_req->is11Rconnection = true;
16067 else
16068 csr_join_req->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016069#ifdef FEATURE_WLAN_ESE
16070 if (true == ese_config)
16071 csr_join_req->isESEFeatureIniEnabled = true;
16072 else
16073 csr_join_req->isESEFeatureIniEnabled = false;
16074
16075 /* A profile can not be both ESE and 11R. But an 802.11R AP
16076 * may be advertising support for ESE as well. So if we are
16077 * associating Open or explicitly ESE then we will get ESE.
Jeff Johnson698eacd2018-05-12 17:00:03 -070016078 * If we are associating explicitly 11R only then we will get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016079 * 11R.
16080 */
16081 if ((csr_is_profile_ese(pProfile) ||
16082 ((pIes->ESEVersion.present) &&
16083 (pProfile->negotiatedAuthType ==
16084 eCSR_AUTH_TYPE_OPEN_SYSTEM)))
16085 && (ese_config))
16086 csr_join_req->isESEconnection = true;
16087 else
16088 csr_join_req->isESEconnection = false;
16089
16090 if (eWNI_SME_JOIN_REQ == messageType) {
16091 tESETspecInfo eseTspec;
16092 /*
16093 * ESE-Tspec IEs in the ASSOC request is presently not
16094 * supported. so nullify the TSPEC parameters
16095 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016096 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
16097 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016098 &eseTspec, sizeof(tESETspecInfo));
16099 } else if (eWNI_SME_REASSOC_REQ == messageType) {
16100 if ((csr_is_profile_ese(pProfile) ||
16101 ((pIes->ESEVersion.present)
16102 && (pProfile->negotiatedAuthType ==
16103 eCSR_AUTH_TYPE_OPEN_SYSTEM))) &&
16104 (ese_config)) {
16105 tESETspecInfo eseTspec;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016106
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016107 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016108 0);
16109 eseTspec.numTspecs =
16110 sme_qos_ese_retrieve_tspec_info(pMac,
16111 sessionId,
16112 (tTspecInfo *) &eseTspec.
16113 tspec[0]);
16114 csr_join_req->eseTspecInfo.numTspecs =
16115 eseTspec.numTspecs;
16116 if (eseTspec.numTspecs) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016117 qdf_mem_copy(&csr_join_req->eseTspecInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016118 .tspec[0],
16119 &eseTspec.tspec[0],
16120 (eseTspec.numTspecs *
16121 sizeof(tTspecInfo)));
16122 }
16123 } else {
16124 tESETspecInfo eseTspec;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016125 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016126 * ESE-Tspec IEs in the ASSOC request is
16127 * presently not supported. so nullify the TSPEC
16128 * parameters
16129 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016130 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016131 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016132 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016133 &eseTspec,
16134 sizeof(tESETspecInfo));
16135 }
16136 }
16137#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016138 if (ese_config
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016139 || csr_roam_is_fast_roam_enabled(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016140 csr_join_req->isFastTransitionEnabled = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016141 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016142 csr_join_req->isFastTransitionEnabled = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016144 if (csr_roam_is_fast_roam_enabled(pMac, sessionId))
16145 csr_join_req->isFastRoamIniFeatureEnabled = true;
16146 else
16147 csr_join_req->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016148
16149 csr_join_req->txLdpcIniFeatureEnabled =
Krunal Sonia2c0e412017-05-04 14:12:41 +053016150 (uint8_t) pMac->roam.configParam.tx_ldpc_enable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016151
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070016152 if ((csr_is11h_supported(pMac)) &&
16153 (WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId)) &&
16154 (pIes->Country.present) &&
16155 (!pMac->roam.configParam.
16156 fSupplicantCountryCodeHasPriority)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016157 csr_save_to_channel_power2_g_5_g(pMac,
16158 pIes->Country.num_triplets *
16159 sizeof(tSirMacChanInfo),
16160 (tSirMacChanInfo *)
16161 (&pIes->Country.triplets[0]));
16162 csr_apply_power2_current(pMac);
16163 }
Krunal Soni0193b6f2016-08-15 15:53:43 -070016164 /*
16165 * If RX LDPC has been disabled for 2.4GHz channels and enabled
Krunal Sonid292a6b2016-10-27 17:25:23 -070016166 * for 5Ghz for STA like persona then here is how to handle
16167 * those cases (by now channel has been decided).
Krunal Soni0193b6f2016-08-15 15:53:43 -070016168 */
Krunal Sonid292a6b2016-10-27 17:25:23 -070016169 if (eSIR_INFRASTRUCTURE_MODE == csr_join_req->bsstype ||
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080016170 !policy_mgr_is_dbs_enable(pMac->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -070016171 csr_set_ldpc_exception(pMac, pSession,
16172 pBssDescription->channelId,
Krunal Sonia2c0e412017-05-04 14:12:41 +053016173 pMac->roam.configParam.rx_ldpc_enable);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016174 qdf_mem_copy(&csr_join_req->htConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016175 &pSession->htConfig, sizeof(tSirHTConfig));
Sandeep Puligilla98917432016-06-10 13:50:28 -070016176 qdf_mem_copy(&csr_join_req->vht_config, &pSession->vht_config,
16177 sizeof(pSession->vht_config));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016178 sme_debug("ht capability 0x%x VHT capability 0x%x",
Sandeep Puligilla98917432016-06-10 13:50:28 -070016179 (unsigned int)(*(uint32_t *) &csr_join_req->htConfig),
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016180 (unsigned int)(*(uint32_t *) &csr_join_req->
16181 vht_config));
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080016182
Jinwei Chen998a1a02018-06-20 17:20:34 +080016183 if (IS_DOT11_MODE_HE(csr_join_req->dot11mode)) {
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080016184 csr_join_req_copy_he_cap(csr_join_req, pSession);
Jinwei Chen998a1a02018-06-20 17:20:34 +080016185 /* change the HE caps like sts per band */
Kiran Kumar Lokeref3044852018-06-27 14:14:24 -070016186 if (!pMac->usr_cfg_tx_bfee_nsts)
16187 CSR_REVISE_REQ_HE_CAP_PER_BAND(csr_join_req,
16188 pMac,
16189 pBssDescription->
16190 channelId);
Jinwei Chen998a1a02018-06-20 17:20:34 +080016191 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080016192
Krunal Soni53993f72016-07-08 18:20:03 -070016193 if (wlan_cfg_get_int(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
Jeff Johnsonc09caa42018-06-07 22:58:55 -070016194 &value) != QDF_STATUS_SUCCESS)
Krunal Soni53993f72016-07-08 18:20:03 -070016195 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016196 ("Failed to get SU beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070016197 if (wlan_cfg_get_int(pMac,
16198 WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
Jeff Johnsonc09caa42018-06-07 22:58:55 -070016199 &value1) != QDF_STATUS_SUCCESS)
Krunal Soni53993f72016-07-08 18:20:03 -070016200 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016201 ("Failed to get CSN beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070016202
16203 csr_join_req->vht_config.su_beam_formee = value;
Abhishek Singhd8162ca2017-04-11 11:54:54 +053016204
16205 /* Set BF CSN value only if SU Bformee is enabled */
Abhinav Kumar3ff56da2018-06-29 15:01:58 +053016206 if (csr_join_req->vht_config.su_beam_formee) {
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080016207 txBFCsnValue = (uint8_t)value1;
Naveen Rawat5b96c3c2017-09-13 16:33:07 -070016208 /*
16209 * Certain commercial AP display a bad behavior when
16210 * CSN value in assoc request is more than AP's CSN.
16211 * Sending absolute self CSN value with such AP leads to
16212 * IOT issues. However this issue is observed only with
16213 * CSN cap of less than 4. To avoid such issues, take a
16214 * min of self and peer CSN while sending ASSOC request.
16215 */
Abhinav Kumar3ff56da2018-06-29 15:01:58 +053016216 if (txBFCsnValue < 4) {
16217 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps) &&
16218 pIes->VHTCaps.csnofBeamformerAntSup)
Naveen Rawat5b96c3c2017-09-13 16:33:07 -070016219 txBFCsnValue = QDF_MIN(txBFCsnValue,
Abhinav Kumar3ff56da2018-06-29 15:01:58 +053016220 pIes->VHTCaps.csnofBeamformerAntSup);
16221 else if (IS_BSS_VHT_CAPABLE(
16222 pIes->vendor_vht_ie.VHTCaps)
16223 && pIes->vendor_vht_ie.VHTCaps.
16224 csnofBeamformerAntSup)
16225 txBFCsnValue = QDF_MIN(txBFCsnValue,
16226 pIes->vendor_vht_ie.
16227 VHTCaps.csnofBeamformerAntSup);
Naveen Rawat5b96c3c2017-09-13 16:33:07 -070016228 }
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080016229 }
16230 csr_join_req->vht_config.csnof_beamformer_antSup = txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016231
Krunal Soni53993f72016-07-08 18:20:03 -070016232 if (wlan_cfg_get_int(pMac,
Abhishek Singhd8162ca2017-04-11 11:54:54 +053016233 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &value)
Jeff Johnsonc09caa42018-06-07 22:58:55 -070016234 != QDF_STATUS_SUCCESS)
Abhishek Singhd8162ca2017-04-11 11:54:54 +053016235 sme_err("Failed to get SU beamformer capability");
16236
16237 /*
16238 * Set SU Bformer only if SU Bformer is enabled in INI
16239 * and AP is SU Bformee capable
16240 */
16241 if (value && !((IS_BSS_VHT_CAPABLE(pIes->VHTCaps) &&
16242 pIes->VHTCaps.suBeamformeeCap) ||
16243 (IS_BSS_VHT_CAPABLE(
16244 pIes->vendor_vht_ie.VHTCaps)
16245 && pIes->vendor_vht_ie.VHTCaps.
16246 suBeamformeeCap)))
16247 value = 0;
16248
16249 csr_join_req->vht_config.su_beam_former = value;
16250
16251 /* Set num soundingdim value to 0 if SU Bformer is disabled */
16252 if (!csr_join_req->vht_config.su_beam_former)
16253 csr_join_req->vht_config.num_soundingdim = 0;
16254
16255 if (wlan_cfg_get_int(pMac,
16256 WNI_CFG_VHT_MU_BEAMFORMEE_CAP, &value)
Jeff Johnsonc09caa42018-06-07 22:58:55 -070016257 != QDF_STATUS_SUCCESS)
Abhishek Singhd8162ca2017-04-11 11:54:54 +053016258 sme_err("Failed to get CSN beamformee capability");
16259 /*
16260 * Set MU Bformee only if SU Bformee is enabled and
16261 * MU Bformee is enabled in INI
16262 */
Kiran Kumar Lokered057b722017-09-07 15:32:09 -070016263 if (value && csr_join_req->vht_config.su_beam_formee &&
16264 pIes->VHTCaps.muBeamformerCap)
Abhishek Singhd8162ca2017-04-11 11:54:54 +053016265 csr_join_req->vht_config.mu_beam_formee = 1;
16266 else
16267 csr_join_req->vht_config.mu_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016268
16269 csr_join_req->enableVhtpAid =
16270 (uint8_t) pMac->roam.configParam.enableVhtpAid;
16271
16272 csr_join_req->enableVhtGid =
16273 (uint8_t) pMac->roam.configParam.enableVhtGid;
16274
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016275 csr_join_req->enableAmpduPs =
16276 (uint8_t) pMac->roam.configParam.enableAmpduPs;
16277
16278 csr_join_req->enableHtSmps =
16279 (uint8_t) pMac->roam.configParam.enableHtSmps;
16280
16281 csr_join_req->htSmps = (uint8_t) pMac->roam.configParam.htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -080016282 csr_join_req->send_smps_action =
16283 pMac->roam.configParam.send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016284
Deepak Dhamdhere612392c2016-08-28 02:56:51 -070016285 csr_join_req->max_amsdu_num =
16286 (uint8_t) pMac->roam.configParam.max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016287
16288 if (pMac->roam.roamSession[sessionId].fWMMConnection)
16289 csr_join_req->isWMEenabled = true;
16290 else
16291 csr_join_req->isWMEenabled = false;
16292
16293 if (pMac->roam.roamSession[sessionId].fQOSConnection)
16294 csr_join_req->isQosEnabled = true;
16295 else
16296 csr_join_req->isQosEnabled = false;
16297
16298 if (pProfile->bOSENAssociation)
16299 csr_join_req->isOSENConnection = true;
16300 else
16301 csr_join_req->isOSENConnection = false;
16302
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080016303 /* Fill rrm config parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016304 qdf_mem_copy(&csr_join_req->rrm_config,
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080016305 &pMac->rrm.rrmSmeContext.rrmConfig,
16306 sizeof(struct rrm_config_param));
16307
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016308 pAP_capabilityInfo =
16309 (tSirMacCapabilityInfo *)
16310 &pBssDescription->capabilityInfo;
16311 /*
16312 * tell the target AP my 11H capability only if both AP and STA
16313 * support
16314 * 11H and the channel being used is 11a
16315 */
16316 if (csr_is11h_supported(pMac) && pAP_capabilityInfo->spectrumMgt
16317 && eSIR_11A_NW_TYPE == pBssDescription->nwType) {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070016318 fTmp = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016319 } else
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070016320 fTmp = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016321
16322 csr_join_req->spectrumMgtIndicator = fTmp;
16323 csr_join_req->powerCap.minTxPower = MIN_TX_PWR_CAP;
16324 /*
16325 * This is required for 11k test VoWiFi Ent: Test 2.
16326 * We need the power capabilities for Assoc Req.
16327 * This macro is provided by the halPhyCfg.h. We pick our
16328 * max and min capability by the halPhy provided macros
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053016329 * Any change in this power cap IE should also be done
16330 * in csr_update_driver_assoc_ies() which would send
16331 * assoc IE's to FW which is used for LFR3 roaming
16332 * ie. used in reassociation requests from FW.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016333 */
16334 pwrLimit = csr_get_cfg_max_tx_power(pMac,
16335 pBssDescription->channelId);
Agrawal Ashish6b48ee22017-02-21 20:54:53 +053016336 if (0 != pwrLimit && pwrLimit < MAX_TX_PWR_CAP)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016337 csr_join_req->powerCap.maxTxPower = pwrLimit;
16338 else
16339 csr_join_req->powerCap.maxTxPower = MAX_TX_PWR_CAP;
16340
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053016341 csr_add_supported_5Ghz_channels(pMac,
16342 csr_join_req->supportedChannels.channelList,
16343 &csr_join_req->supportedChannels.numChnl,
16344 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016345
16346 csr_join_req->uapsdPerAcBitmask = (uint8_t)pProfile->uapsd_mask;
16347 /* Move the entire BssDescription into the join request. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016348 qdf_mem_copy(&csr_join_req->bssDescription, pBssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016349 pBssDescription->length +
16350 sizeof(pBssDescription->length));
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053016351 csr_update_fils_connection_info(pProfile, csr_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +053016352 csr_update_sae_config(csr_join_req, pMac, pSession);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016353 /*
16354 * conc_custom_rule1:
16355 * If SAP comes up first and STA comes up later then SAP
16356 * need to follow STA's channel in 2.4Ghz. In following if
16357 * condition we are adding sanity check, just to make sure that
16358 * if this rule is enabled then don't allow STA to connect on
16359 * 5gz channel and also by this time SAP's channel should be the
16360 * same as STA's channel.
16361 */
16362 if (pMac->roam.configParam.conc_custom_rule1) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070016363 if ((0 == pMac->roam.configParam.
16364 is_sta_connection_in_5gz_enabled) &&
16365 WLAN_REG_IS_5GHZ_CH(pBssDescription->
16366 channelId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016367 QDF_TRACE(QDF_MODULE_ID_SME,
16368 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016369 "STA-conn on 5G isn't allowed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016370 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016371 break;
16372 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070016373 if (!WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016374 (false == csr_is_conn_allow_2g_band(pMac,
16375 pBssDescription->channelId))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016376 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016377 break;
16378 }
16379 }
16380
16381 /*
16382 * conc_custom_rule2:
16383 * If P2PGO comes up first and STA comes up later then P2PGO
16384 * need to follow STA's channel in 5Ghz. In following if
16385 * condition we are just adding sanity check to make sure that
16386 * by this time P2PGO's channel is same as STA's channel.
16387 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070016388 if (pMac->roam.configParam.conc_custom_rule2 &&
16389 !WLAN_REG_IS_24GHZ_CH(pBssDescription->channelId) &&
16390 (!csr_is_conn_allow_5g_band(pMac,
16391 pBssDescription->channelId))) {
16392 status = QDF_STATUS_E_FAILURE;
16393 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016394 }
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +053016395
16396 if (pSession->pCurRoamProfile->csrPersona == QDF_STA_MODE)
16397 csr_join_req->enable_bcast_probe_rsp =
16398 pMac->roam.configParam.enable_bcast_probe_rsp;
16399
Arif Hussain6686c0b2018-08-21 18:21:05 -070016400 csr_join_req->enable_session_twt_support = csr_enable_twt(pIes);
Rajeev Kumard138ac52017-01-30 18:38:37 -080016401 status = umac_send_mb_message_to_mac(csr_join_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016402 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016403 /*
Rajeev Kumard138ac52017-01-30 18:38:37 -080016404 * umac_send_mb_message_to_mac would've released the mem
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016405 * allocated by csr_join_req. Let's make it defensive by
16406 * assigning NULL to the pointer.
16407 */
16408 csr_join_req = NULL;
16409 break;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016410 }
16411
16412 if (pProfile->csrPersona == QDF_STA_MODE) {
16413 sme_debug("Invoking packetdump register API");
16414 wlan_register_txrx_packetdump();
16415 packetdump_timer_status = qdf_mc_timer_start(
16416 &pMac->roam.packetdump_timer,
16417 (PKT_DUMP_TIMER_DURATION *
16418 QDF_MC_TIMER_TO_SEC_UNIT)/
16419 QDF_MC_TIMER_TO_MS_UNIT);
16420 if (!QDF_IS_STATUS_SUCCESS(packetdump_timer_status))
16421 sme_err("cannot start packetdump timer status: %d",
16422 packetdump_timer_status);
16423 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016424#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016425 if (eWNI_SME_JOIN_REQ == messageType) {
16426 /* Notify QoS module that join happening */
16427 pSession->join_bssid_count++;
16428 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
16429 "BSSID Count: %d", pSession->join_bssid_count);
16430 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016431 SME_QOS_CSR_JOIN_REQ, NULL);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016432 } else if (eWNI_SME_REASSOC_REQ == messageType)
16433 /* Notify QoS module that reassoc happening */
16434 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016435 SME_QOS_CSR_REASSOC_REQ,
16436 NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016437#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016438 } while (0);
16439
16440 /* Clean up the memory in case of any failure */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016441 if (!QDF_IS_STATUS_SUCCESS(status) && (NULL != csr_join_req))
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016442 qdf_mem_free(csr_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016443
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053016444 if (wpaRsnIE)
16445 qdf_mem_free(wpaRsnIE);
16446
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016447 return status;
16448}
16449
16450/* */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016451QDF_STATUS csr_send_mb_disassoc_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016452 tSirMacAddr bssId, uint16_t reasonCode)
16453{
16454 tSirSmeDisassocReq *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016455 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016456
16457 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016458 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016459
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016460 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016461 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016462 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016464 pMsg->messageType = eWNI_SME_DISASSOC_REQ;
16465 pMsg->length = sizeof(tSirSmeDisassocReq);
16466 pMsg->sessionId = sessionId;
16467 pMsg->transactionId = 0;
16468 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070016469 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016470 qdf_mem_copy(&pMsg->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016471 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016472 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016473 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016474 bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016475 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016476 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016477 qdf_mem_copy(&pMsg->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016478 bssId, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016479 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016480 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016481 }
16482 pMsg->reasonCode = reasonCode;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -070016483 pMsg->process_ho_fail = (pSession->disconnect_reason ==
16484 eCSR_DISCONNECT_REASON_ROAM_HO_FAIL) ? true : false;
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053016485
16486 /* Update the disconnect stats */
16487 pSession->disconnect_stats.disconnection_cnt++;
16488 pSession->disconnect_stats.disconnection_by_app++;
16489
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016490 /*
16491 * The state will be DISASSOC_HANDOFF only when we are doing
16492 * handoff. Here we should not send the disassoc over the air
16493 * to the AP
16494 */
Selvaraj, Sridhar0ab68622017-04-24 14:21:27 +053016495 if ((CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
16496 && csr_roam_is11r_assoc(pMac, sessionId)) ||
16497 pMsg->process_ho_fail) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016498 /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
16499 pMsg->doNotSendOverTheAir = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR;
16500 }
Rajeev Kumard138ac52017-01-30 18:38:37 -080016501 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016502}
16503
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016504QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016505csr_send_mb_get_associated_stas_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016506 QDF_MODULE_ID modId,
16507 struct qdf_mac_addr bssid,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016508 void *pUsrContext,
16509 void *pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016510 uint8_t *pAssocStasBuf)
16511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016512 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016513 tSirSmeGetAssocSTAsReq *pMsg;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016514
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016515 pMsg = qdf_mem_malloc(sizeof(*pMsg));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016516 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016517 return QDF_STATUS_E_NOMEM;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016518
16519 pMsg->messageType = eWNI_SME_GET_ASSOC_STAS_REQ;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016520 qdf_copy_macaddr(&pMsg->bssid, &bssid);
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016521 pMsg->modId = modId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016522 qdf_mem_copy(pMsg->pUsrContext, pUsrContext, sizeof(void *));
16523 qdf_mem_copy(pMsg->pSapEventCallback,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016524 pfnSapEventCallback, sizeof(void *));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016525 qdf_mem_copy(pMsg->pAssocStasArray, pAssocStasBuf, sizeof(void *));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016526 pMsg->length = sizeof(*pMsg);
Rajeev Kumard138ac52017-01-30 18:38:37 -080016527 status = umac_send_mb_message_to_mac(pMsg);
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016529 return status;
16530}
16531
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016532QDF_STATUS csr_send_chng_mcc_beacon_interval(tpAniSirGlobal pMac,
16533 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016534{
16535 tpSirChangeBIParams pMsg;
16536 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016537 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016538 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016539
16540 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016541 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016542 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016543 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016544 /* NO need to update the Beacon Params if update beacon parameter flag
16545 * is not set
16546 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016547 if (!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016548 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016549
16550 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval =
16551 false;
16552
16553 /* Create the message and send to lim */
16554 len = sizeof(tSirChangeBIParams);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016555 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016556 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016557 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016558 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016559 status = QDF_STATUS_SUCCESS;
16560 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016561 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
16562 pMsg->length = len;
16563
Anurag Chouhanc5548422016-02-24 18:33:27 +053016564 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016565 sme_debug(
16566 "CSR Attempting to change BI for Bssid= "
16567 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016568 pMsg->sessionId = sessionId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016569 sme_debug("session %d BeaconInterval %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016570 sessionId,
16571 pMac->roam.roamSession[sessionId].bssParams.
16572 beaconInterval);
16573 pMsg->beaconInterval =
16574 pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
Rajeev Kumard138ac52017-01-30 18:38:37 -080016575 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016576 }
16577 return status;
16578}
16579
16580#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016581QDF_STATUS csr_set_ht2040_mode(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016582 ePhyChanBondState cbMode, bool obssEnabled)
16583{
16584 tpSirSetHT2040Mode pMsg;
16585 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016586 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016587 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016588
16589 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016590 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016591 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016592 }
16593
16594 /* Create the message and send to lim */
16595 len = sizeof(tSirSetHT2040Mode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016596 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016597 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016598 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016599 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016600 status = QDF_STATUS_SUCCESS;
16601 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016602 qdf_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016603 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
16604 pMsg->length = len;
16605
Anurag Chouhanc5548422016-02-24 18:33:27 +053016606 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016607 sme_debug(
16608 "CSR Attempting to set HT20/40 mode for Bssid= "
16609 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016610 pMsg->sessionId = sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016611 sme_debug(" session %d HT20/40 mode %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016612 sessionId, cbMode);
16613 pMsg->cbMode = cbMode;
16614 pMsg->obssEnabled = obssEnabled;
Rajeev Kumard138ac52017-01-30 18:38:37 -080016615 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016616 }
16617 return status;
16618}
16619#endif
16620
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016621QDF_STATUS csr_send_mb_deauth_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016622 tSirMacAddr bssId, uint16_t reasonCode)
16623{
16624 tSirSmeDeauthReq *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016625 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016626
16627 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016628 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016629
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016630 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016631 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016632 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016633
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016634 qdf_mem_set(pMsg, sizeof(tSirSmeDeauthReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016635 pMsg->messageType = eWNI_SME_DEAUTH_REQ;
16636 pMsg->length = sizeof(tSirSmeDeauthReq);
16637 pMsg->sessionId = sessionId;
16638 pMsg->transactionId = 0;
16639
16640 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070016641 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016642 qdf_mem_copy(&pMsg->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016643 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016644 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016645 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016646 qdf_mem_copy(&pMsg->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016647 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016648 }
16649
16650 /* Set the peer MAC address before sending the message to LIM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016651 qdf_mem_copy(&pMsg->peer_macaddr.bytes, bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016652 pMsg->reasonCode = reasonCode;
16653
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053016654 /* Update the disconnect stats */
16655 pSession->disconnect_stats.disconnection_cnt++;
16656 pSession->disconnect_stats.disconnection_by_app++;
16657
Rajeev Kumard138ac52017-01-30 18:38:37 -080016658 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016659}
16660
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016661QDF_STATUS csr_send_mb_disassoc_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016662 tpSirSmeDisassocInd pDisassocInd)
16663{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016664 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016665 tSirSmeDisassocCnf *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016667 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016668 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016669 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016670 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016671 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016672 status = QDF_STATUS_SUCCESS;
16673 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016674 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016675 pMsg->messageType = eWNI_SME_DISASSOC_CNF;
16676 pMsg->statusCode = eSIR_SME_SUCCESS;
16677 pMsg->length = sizeof(tSirSmeDisassocCnf);
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +053016678 pMsg->sme_session_id = pDisassocInd->sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016679 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080016680 &pDisassocInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016681 status = QDF_STATUS_SUCCESS;
16682 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016683 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016684 break;
16685 }
16686
Anurag Chouhanc5548422016-02-24 18:33:27 +053016687 qdf_copy_macaddr(&pMsg->bssid, &pDisassocInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016688 status = QDF_STATUS_SUCCESS;
16689 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016690 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016691 break;
16692 }
16693
Rajeev Kumard138ac52017-01-30 18:38:37 -080016694 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016695 } while (0);
16696 return status;
16697}
16698
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016699QDF_STATUS csr_send_mb_deauth_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016700 tpSirSmeDeauthInd pDeauthInd)
16701{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016702 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016703 tSirSmeDeauthCnf *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016704
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016705 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016706 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016707 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016708 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016709 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016710 status = QDF_STATUS_SUCCESS;
16711 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016712 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016713 pMsg->messageType = eWNI_SME_DEAUTH_CNF;
16714 pMsg->statusCode = eSIR_SME_SUCCESS;
16715 pMsg->length = sizeof(tSirSmeDeauthCnf);
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +053016716 pMsg->sme_session_id = pDeauthInd->sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016717 qdf_copy_macaddr(&pMsg->bssid, &pDeauthInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016718 status = QDF_STATUS_SUCCESS;
16719 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016720 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016721 break;
16722 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053016723 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -080016724 &pDeauthInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016725 status = QDF_STATUS_SUCCESS;
16726 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016727 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016728 break;
16729 }
Rajeev Kumard138ac52017-01-30 18:38:37 -080016730 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016731 } while (0);
16732 return status;
16733}
16734
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016735QDF_STATUS csr_send_assoc_cnf_msg(tpAniSirGlobal pMac, tpSirSmeAssocInd
16736 pAssocInd, QDF_STATUS Halstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016737{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016738 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016739 tSirSmeAssocCnf *pMsg;
Sandeep Puligilla1426d612017-04-12 18:22:06 -070016740 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016741
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016742 sme_debug("Posting eWNI_SME_ASSOC_CNF to LIM.HalStatus: %d", Halstatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016743 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016744 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016745 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016746 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016747 pMsg->messageType = eWNI_SME_ASSOC_CNF;
16748 pMsg->length = sizeof(tSirSmeAssocCnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016749 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016750 pMsg->statusCode = eSIR_SME_SUCCESS;
16751 else
16752 pMsg->statusCode = eSIR_SME_ASSOC_REFUSED;
16753 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016754 qdf_mem_copy(pMsg->bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016755 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016756 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016757 qdf_mem_copy(pMsg->peer_macaddr.bytes, pAssocInd->peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016758 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016759 /* aid */
16760 pMsg->aid = pAssocInd->aid;
16761 /* alternateBssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016762 qdf_mem_copy(pMsg->alternate_bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016763 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016764 /* alternateChannelId */
16765 pMsg->alternateChannelId = 11;
Sandeep Puligilla1426d612017-04-12 18:22:06 -070016766
16767 msg.type = pMsg->messageType;
16768 msg.bodyval = 0;
16769 msg.bodyptr = pMsg;
Rajeev Kumard138ac52017-01-30 18:38:37 -080016770 /* pMsg is freed by umac_send_mb_message_to_mac in anycase*/
Sandeep Puligilla1426d612017-04-12 18:22:06 -070016771 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE, &msg,
16772 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016773 } while (0);
16774 return status;
16775}
16776
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016777QDF_STATUS csr_send_assoc_ind_to_upper_layer_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016778 tpSirSmeAssocInd pAssocInd,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016779 QDF_STATUS Halstatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016780 uint8_t sessionId)
16781{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070016782 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016783 tSirSmeAssocIndToUpperLayerCnf *pMsg;
16784 uint8_t *pBuf;
16785 tSirResultCodes statusCode;
16786 uint16_t wTmp;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016787
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016788 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016789 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocIndToUpperLayerCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016790 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016791 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016792
16793 pMsg->messageType = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
16794 pMsg->length = sizeof(tSirSmeAssocIndToUpperLayerCnf);
16795
16796 pMsg->sessionId = sessionId;
16797
16798 pBuf = (uint8_t *) &pMsg->statusCode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016799 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016800 statusCode = eSIR_SME_SUCCESS;
16801 else
16802 statusCode = eSIR_SME_ASSOC_REFUSED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016803 qdf_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016804 /* bssId */
Will Huang558f8082017-05-31 16:22:24 +080016805 pBuf = (uint8_t *)&pMsg->bssId;
16806 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId,
16807 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016808 /* peerMacAddr */
Will Huang558f8082017-05-31 16:22:24 +080016809 pBuf = (uint8_t *)&pMsg->peerMacAddr;
16810 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
16811 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016812 /* StaId */
Will Huang558f8082017-05-31 16:22:24 +080016813 pBuf = (uint8_t *)&pMsg->aid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016814 wTmp = pAssocInd->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016815 qdf_mem_copy(pBuf, &wTmp, sizeof(uint16_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016816 /* alternateBssId */
Will Huang558f8082017-05-31 16:22:24 +080016817 pBuf = (uint8_t *)&pMsg->alternateBssId;
16818 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId,
16819 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016820 /* alternateChannelId */
Will Huang558f8082017-05-31 16:22:24 +080016821 pBuf = (uint8_t *)&pMsg->alternateChannelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016822 *pBuf = 11;
Will Huang558f8082017-05-31 16:22:24 +080016823 /*
16824 * Instead of copying roam Info,just copy WmmEnabled,
16825 * RsnIE information.
16826 * Wmm
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016827 */
Will Huang558f8082017-05-31 16:22:24 +080016828 pBuf = (uint8_t *)&pMsg->wmmEnabledSta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016829 *pBuf = pAssocInd->wmmEnabledSta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016830 /* RSN IE */
Will Huang558f8082017-05-31 16:22:24 +080016831 pBuf = (uint8_t *)&pMsg->rsnIE;
16832 qdf_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE,
16833 sizeof(tSirRSNie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016834#ifdef FEATURE_WLAN_WAPI
16835 /* WAPI IE */
Will Huang558f8082017-05-31 16:22:24 +080016836 pBuf = (uint8_t *)&pMsg->wapiIE;
16837 qdf_mem_copy((tSirWAPIie *)pBuf, &pAssocInd->wapiIE,
16838 sizeof(tSirWAPIie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016839#endif
16840 /* Additional IE */
Will Huang558f8082017-05-31 16:22:24 +080016841 pBuf = (uint8_t *)&pMsg->addIE;
16842 qdf_mem_copy((tSirAddie *)pBuf, &pAssocInd->addIE,
16843 sizeof(tSirAddie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016844 /* reassocReq */
Will Huang558f8082017-05-31 16:22:24 +080016845 pBuf = (uint8_t *)&pMsg->reassocReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016846 *pBuf = pAssocInd->reassocReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016847 /* timingMeasCap */
Will Huang558f8082017-05-31 16:22:24 +080016848 pBuf = (uint8_t *)&pMsg->timingMeasCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016849 *pBuf = pAssocInd->timingMeasCap;
Will Huang558f8082017-05-31 16:22:24 +080016850 /* chan_info */
16851 pBuf = (uint8_t *)&pMsg->chan_info;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016852 qdf_mem_copy((void *)pBuf, &pAssocInd->chan_info,
Will Huang558f8082017-05-31 16:22:24 +080016853 sizeof(tSirSmeChanInfo));
16854 /* ampdu */
16855 pBuf = (uint8_t *)&pMsg->ampdu;
16856 *((bool *)pBuf) = pAssocInd->ampdu;
16857 /* sgi_enable */
16858 pBuf = (uint8_t *)&pMsg->sgi_enable;
16859 *((bool *)pBuf) = pAssocInd->sgi_enable;
16860 /* tx stbc */
16861 pBuf = (uint8_t *)&pMsg->tx_stbc;
16862 *((bool *)pBuf) = pAssocInd->tx_stbc;
16863 /* ch_width */
16864 pBuf = (uint8_t *)&pMsg->ch_width;
16865 *((tSirMacHTChannelWidth *)pBuf) = pAssocInd->ch_width;
16866 /* mode */
16867 pBuf = (uint8_t *)&pMsg->mode;
16868 *((enum sir_sme_phy_mode *)pBuf) = pAssocInd->mode;
16869 /* rx stbc */
16870 pBuf = (uint8_t *)&pMsg->rx_stbc;
16871 *((bool *)pBuf) = pAssocInd->rx_stbc;
16872 /* max supported idx */
16873 pBuf = (uint8_t *)&pMsg->max_supp_idx;
16874 *pBuf = pAssocInd->max_supp_idx;
16875 /* max extended idx */
16876 pBuf = (uint8_t *)&pMsg->max_ext_idx;
16877 *pBuf = pAssocInd->max_ext_idx;
16878 /* max ht mcs idx */
16879 pBuf = (uint8_t *)&pMsg->max_mcs_idx;
16880 *pBuf = pAssocInd->max_mcs_idx;
16881 /* vht rx mcs map */
16882 pBuf = (uint8_t *)&pMsg->rx_mcs_map;
16883 *pBuf = pAssocInd->rx_mcs_map;
16884 /* vht tx mcs map */
16885 pBuf = (uint8_t *)&pMsg->tx_mcs_map;
16886 *pBuf = pAssocInd->tx_mcs_map;
16887
gaolez7bb1e742017-03-21 16:37:38 +080016888 pBuf = (uint8_t *)&pMsg->ecsa_capable;
16889 *pBuf = pAssocInd->ecsa_capable;
16890
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053016891 if (pAssocInd->HTCaps.present)
16892 pMsg->ht_caps = pAssocInd->HTCaps;
16893 if (pAssocInd->VHTCaps.present)
16894 pMsg->vht_caps = pAssocInd->VHTCaps;
16895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016896 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
16897 msgQ.bodyptr = pMsg;
16898 msgQ.bodyval = 0;
16899 sys_process_mmh_msg(pMac, &msgQ);
16900 } while (0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016901 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016902}
16903
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016904QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080016905 uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016906 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080016907 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016908 tAniEdType edType, bool fUnicast,
16909 tAniKeyDirection aniKeyDirection,
16910 uint8_t keyId, uint8_t keyLength,
16911 uint8_t *pKey, uint8_t paeRole,
16912 uint8_t *pKeyRsc)
16913{
16914 tSirSmeSetContextReq *pMsg;
Abhishek Singh154637a2017-06-19 18:02:11 +053016915 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016916 uint16_t msgLen;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016917 QDF_STATUS status = QDF_STATUS_E_FAILURE;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016918 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016919
16920 sme_debug("keylength: %d Encry type: %d", keyLength, edType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016921 do {
16922 if ((1 != numKeys) && (0 != numKeys))
16923 break;
16924 /*
16925 * All of these fields appear in every SET_CONTEXT message.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016926 * Below we'll add in the size for each key set. Since we only
16927 * support up to one key, we always allocate memory for 1 key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016928 */
16929 msgLen = sizeof(struct sSirSmeSetContextReq);
16930
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016931 pMsg = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016932 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016933 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016934 pMsg->messageType = eWNI_SME_SETCONTEXT_REQ;
16935 pMsg->length = msgLen;
16936 pMsg->sessionId = (uint8_t) sessionId;
16937 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016938 qdf_copy_macaddr(&pMsg->peer_macaddr, &peer_macaddr);
16939 qdf_copy_macaddr(&pMsg->bssid,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080016940 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016941
16942 /**
16943 * Set the pMsg->keyMaterial.length field
16944 * (this length is defined as all data that follows the
16945 * edType field in the tSirKeyMaterial keyMaterial; field).
16946 *
16947 * NOTE: This keyMaterial.length contains the length of a
16948 * MAX size key, though the keyLength can be shorter than this
16949 * max size. Is LIM interpreting this ok ?
16950 */
16951 pMsg->keyMaterial.length =
16952 sizeof(pMsg->keyMaterial.numKeys) +
16953 (numKeys * sizeof(pMsg->keyMaterial.key));
16954 pMsg->keyMaterial.edType = edType;
16955 pMsg->keyMaterial.numKeys = numKeys;
16956 pMsg->keyMaterial.key[0].keyId = keyId;
16957 pMsg->keyMaterial.key[0].unicast = fUnicast;
16958 pMsg->keyMaterial.key[0].keyDirection = aniKeyDirection;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016959 qdf_mem_copy(pMsg->keyMaterial.key[0].keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016960 pKeyRsc, CSR_MAX_RSC_LEN);
16961 /* 0 is Supplicant */
16962 pMsg->keyMaterial.key[0].paeRole = paeRole;
16963 pMsg->keyMaterial.key[0].keyLength = keyLength;
Sreelakshmi Konamki66ddf3a2017-02-28 17:29:43 +053016964 if (keyLength && pKey)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016965 qdf_mem_copy(pMsg->keyMaterial.key[0].key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016966 pKey, keyLength);
Abhishek Singh154637a2017-06-19 18:02:11 +053016967
16968 msg.type = eWNI_SME_SETCONTEXT_REQ;
16969 msg.bodyptr = pMsg;
Sandeep Puligillafc2181b2018-06-18 16:32:41 -070016970 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
Abhishek Singh154637a2017-06-19 18:02:11 +053016971 if (QDF_IS_STATUS_ERROR(status))
16972 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016973 } while (0);
16974 return status;
16975}
16976
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016977QDF_STATUS csr_send_mb_start_bss_req_msg(tpAniSirGlobal pMac, uint32_t
16978 sessionId, eCsrRoamBssType bssType,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016979 struct csr_roamstart_bssparams *pParam,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016980 tSirBssDescription *pBssDesc)
16981{
16982 tSirSmeStartBssReq *pMsg;
16983 uint16_t wTmp;
Krunal Soni53993f72016-07-08 18:20:03 -070016984 uint32_t value = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016985 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016986
16987 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016988 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016989 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016990 }
16991
16992 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
16993 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016994 pMsg = qdf_mem_malloc(sizeof(tSirSmeStartBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016995 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016996 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016998 pMsg->messageType = eWNI_SME_START_BSS_REQ;
16999 pMsg->sessionId = sessionId;
17000 pMsg->length = sizeof(tSirSmeStartBssReq);
17001 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017002 qdf_copy_macaddr(&pMsg->bssid, &pParam->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017003 /* selfMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053017004 qdf_copy_macaddr(&pMsg->self_macaddr, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017005 /* beaconInterval */
17006 if (pBssDesc && pBssDesc->beaconInterval)
17007 wTmp = pBssDesc->beaconInterval;
17008 else if (pParam->beaconInterval)
17009 wTmp = pParam->beaconInterval;
17010 else
17011 wTmp = WNI_CFG_BEACON_INTERVAL_STADEF;
17012
Krunal Sonicbda8552016-07-14 19:39:02 -070017013 csr_validate_mcc_beacon_interval(pMac, pParam->operationChn,
17014 &wTmp, sessionId, pParam->bssPersona);
17015 /* Update the beacon Interval */
17016 pParam->beaconInterval = wTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017017 pMsg->beaconInterval = wTmp;
17018 pMsg->dot11mode =
17019 csr_translate_to_wni_cfg_dot11_mode(pMac,
17020 pParam->uCfgDot11Mode);
17021#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
17022 pMsg->cc_switch_mode = pMac->roam.configParam.cc_switch_mode;
17023#endif
17024 pMsg->bssType = csr_translate_bsstype_to_mac_type(bssType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017025 qdf_mem_copy(&pMsg->ssId, &pParam->ssId, sizeof(pParam->ssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017026 pMsg->channelId = pParam->operationChn;
17027 /* What should we really do for the cbmode. */
17028 pMsg->cbMode = (ePhyChanBondState) pParam->cbMode;
17029 pMsg->vht_channel_width = pParam->ch_params.ch_width;
17030 pMsg->center_freq_seg0 = pParam->ch_params.center_freq_seg0;
17031 pMsg->center_freq_seg1 = pParam->ch_params.center_freq_seg1;
17032 pMsg->sec_ch_offset = pParam->ch_params.sec_ch_offset;
17033 pMsg->privacy = pParam->privacy;
17034 pMsg->apUapsdEnable = pParam->ApUapsdEnable;
17035 pMsg->ssidHidden = pParam->ssidHidden;
17036 pMsg->fwdWPSPBCProbeReq = (uint8_t) pParam->fwdWPSPBCProbeReq;
17037 pMsg->protEnabled = (uint8_t) pParam->protEnabled;
17038 pMsg->obssProtEnabled = (uint8_t) pParam->obssProtEnabled;
17039 /* set cfg related to protection */
17040 pMsg->ht_capab = pParam->ht_protection;
17041 pMsg->authType = pParam->authType;
17042 pMsg->dtimPeriod = pParam->dtimPeriod;
17043 pMsg->wps_state = pParam->wps_state;
17044 pMsg->isCoalesingInIBSSAllowed = pMac->isCoalesingInIBSSAllowed;
17045 pMsg->bssPersona = pParam->bssPersona;
Krunal Sonia2c0e412017-05-04 14:12:41 +053017046 pMsg->txLdpcIniFeatureEnabled = pMac->roam.configParam.tx_ldpc_enable;
Krunal Soni53993f72016-07-08 18:20:03 -070017047
jiad4a7a33c2017-08-08 15:32:24 +080017048 /*
17049 * If RX LDPC has been disabled for 2.4GHz channels and enabled
17050 * for 5Ghz for STA like persona then here is how to handle
17051 * those cases (by now channel has been decided).
17052 */
17053 if (eSIR_IBSS_MODE == pMsg->bssType ||
17054 !policy_mgr_is_dbs_enable(pMac->psoc))
17055 csr_set_ldpc_exception(pMac, pSession,
17056 pMsg->channelId,
17057 pMac->roam.configParam.rx_ldpc_enable);
17058
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070017059 qdf_mem_copy(&pMsg->vht_config,
17060 &pSession->vht_config,
17061 sizeof(pSession->vht_config));
17062 qdf_mem_copy(&pMsg->htConfig,
17063 &pSession->htConfig,
17064 sizeof(tSirHTConfig));
17065
Krunal Soni53993f72016-07-08 18:20:03 -070017066 if (wlan_cfg_get_int(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, &value)
Jeff Johnsonc09caa42018-06-07 22:58:55 -070017067 != QDF_STATUS_SUCCESS)
Krunal Soni53993f72016-07-08 18:20:03 -070017068 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017069 "could not get SU beam formee capability");
Krunal Soni53993f72016-07-08 18:20:03 -070017070 pMsg->vht_config.su_beam_formee =
17071 (uint8_t)value &&
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -080017072 (uint8_t)pMac->roam.configParam.enable_txbf_sap_mode;
Krunal Soni53993f72016-07-08 18:20:03 -070017073 if (wlan_cfg_get_int(pMac,
17074 WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
Jeff Johnsonc09caa42018-06-07 22:58:55 -070017075 &value) != QDF_STATUS_SUCCESS)
Krunal Soni53993f72016-07-08 18:20:03 -070017076 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017077 ("Failed to get CSN beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070017078 pMsg->vht_config.csnof_beamformer_antSup = (uint8_t)value;
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070017079 pMsg->vht_config.mu_beam_formee = 0;
Krunal Soni53993f72016-07-08 18:20:03 -070017080
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070017081 sme_debug("ht capability 0x%x VHT capability 0x%x",
17082 (uint32_t)(*(uint32_t *) &pMsg->htConfig),
17083 (uint32_t)(*(uint32_t *) &pMsg->vht_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017084#ifdef WLAN_FEATURE_11W
17085 pMsg->pmfCapable = pParam->mfpCapable;
17086 pMsg->pmfRequired = pParam->mfpRequired;
17087#endif
17088
17089 if (pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017090 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017091 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017092 }
17093 pMsg->rsnIE.length = pParam->nRSNIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017094 qdf_mem_copy(pMsg->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017095 pParam->pRSNIE,
17096 pParam->nRSNIELength);
17097 pMsg->nwType = (tSirNwType)pParam->sirNwType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017098 qdf_mem_copy(&pMsg->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017099 &pParam->operationalRateSet,
17100 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017101 qdf_mem_copy(&pMsg->extendedRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017102 &pParam->extendedRateSet,
17103 sizeof(tSirMacRateSet));
jiad4a7a33c2017-08-08 15:32:24 +080017104
Jinwei Chen998a1a02018-06-20 17:20:34 +080017105 if (IS_DOT11_MODE_HE(pMsg->dot11mode)) {
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080017106 csr_start_bss_copy_he_cap(pMsg, pSession);
Jinwei Chen998a1a02018-06-20 17:20:34 +080017107 /* change the HE caps like sts per band */
17108 CSR_REVISE_REQ_HE_CAP_PER_BAND(pMsg, pMac,
Lin Bai772fbaf2018-07-04 14:20:55 +080017109 pParam->operationChn);
Jinwei Chen998a1a02018-06-20 17:20:34 +080017110 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080017111
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017112 qdf_mem_copy(&pMsg->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017113 &pParam->addIeParams,
17114 sizeof(pParam->addIeParams));
17115 pMsg->obssEnabled = pMac->roam.configParam.obssEnabled;
17116 pMsg->sap_dot11mc = pParam->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +053017117 pMsg->vendor_vht_sap =
17118 pMac->roam.configParam.vendor_vht_sap;
Arif Hussain671a1902017-03-17 09:08:32 -070017119 pMsg->cac_duration_ms = pParam->cac_duration_ms;
17120 pMsg->dfs_regdomain = pParam->dfs_regdomain;
Jiachao Wu712d4fd2017-08-23 16:52:34 +080017121 pMsg->beacon_tx_rate = pParam->beacon_tx_rate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017122
Rajeev Kumard138ac52017-01-30 18:38:37 -080017123 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017124}
17125
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017126QDF_STATUS csr_send_mb_stop_bss_req_msg(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017127{
17128 tSirSmeStopBssReq *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017129 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017130
17131 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017132 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017133 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017134 }
17135
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017136 pMsg = qdf_mem_malloc(sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017137 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017138 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017139 pMsg->messageType = eWNI_SME_STOP_BSS_REQ;
17140 pMsg->sessionId = sessionId;
17141 pMsg->length = sizeof(tSirSmeStopBssReq);
17142 pMsg->transactionId = 0;
17143 pMsg->reasonCode = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017144 qdf_copy_macaddr(&pMsg->bssid, &pSession->connectedProfile.bssid);
Rajeev Kumard138ac52017-01-30 18:38:37 -080017145 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017146}
17147
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017148QDF_STATUS csr_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017149 tCsrRoamModifyProfileFields *pModProfileFields,
17150 uint32_t *pRoamId, bool fForce)
17151{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017152 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017153 uint32_t roamId = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017154 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017155
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017156 if ((csr_is_conn_state_connected(pMac, sessionId)) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017157 (fForce || (qdf_mem_cmp(&pModProfileFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017158 &pSession->connectedProfile.
17159 modifyProfileFields,
17160 sizeof(tCsrRoamModifyProfileFields))))) {
17161 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017162 if (pRoamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017163 *pRoamId = roamId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017164
17165 status =
17166 csr_roam_issue_reassoc(pMac, sessionId, NULL,
17167 pModProfileFields,
17168 eCsrSmeIssuedReassocToSameAP,
17169 roamId, false);
17170 }
17171 return status;
17172}
17173
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017174static QDF_STATUS csr_roam_session_opened(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017175 uint32_t sessionId)
17176{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017177 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080017178 struct csr_roam_info roamInfo;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017179
Jeff Johnson172237b2017-11-07 15:32:59 -080017180 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017181 status = csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
17182 eCSR_ROAM_SESSION_OPENED,
17183 eCSR_ROAM_RESULT_NONE);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017184
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017185 return status;
17186}
17187
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017188QDF_STATUS csr_process_add_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017189{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017190 struct add_sta_self_params *rsp;
17191 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017192 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017193
17194 if (pMsg == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017195 sme_err("in %s msg ptr is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017196 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017197 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017198 rsp = (struct add_sta_self_params *) pMsg;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017199 sme_debug("Add Sta self rsp status = %d", rsp->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017200
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017201 if (QDF_STATUS_SUCCESS == rsp->status &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017202 (WMI_VDEV_TYPE_STA == rsp->type ||
17203 (WMI_VDEV_TYPE_AP == rsp->type &&
17204 WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE == rsp->sub_type))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017205 sme_debug("send SET IE msg to PE");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017206 msg = qdf_mem_malloc(sizeof(*msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017207 if (NULL == msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017208 sme_err("Memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017209 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017210 }
17211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017212 msg->msg_type = eWNI_SME_SET_IE_REQ;
17213 msg->session_id = rsp->session_id;
17214 msg->length = sizeof(*msg);
Rajeev Kumard138ac52017-01-30 18:38:37 -080017215 status = umac_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017216 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017217 sme_err("Failed to send down the set IE req ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017218 }
17219
Krunal Soni985b8132017-02-10 18:49:08 -080017220 csr_roam_session_opened(pMac, rsp->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017221 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017222}
17223
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070017224/**
17225 * csr_get_vdev_type_nss() - gets the nss value based on vdev type
17226 * @mac_ctx: Pointer to Global MAC structure
17227 * @dev_mode: current device operating mode.
17228 * @nss2g: Pointer to the 2G Nss parameter.
17229 * @nss5g: Pointer to the 5G Nss parameter.
17230 *
17231 * Fills the 2G and 5G Nss values based on device mode.
17232 *
17233 * Return: None
17234 */
17235void csr_get_vdev_type_nss(tpAniSirGlobal mac_ctx,
Jeff Johnsonc1e62782017-11-09 09:50:17 -080017236 enum QDF_OPMODE dev_mode,
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070017237 uint8_t *nss_2g, uint8_t *nss_5g)
17238{
17239 switch (dev_mode) {
17240 case QDF_STA_MODE:
17241 *nss_2g = mac_ctx->vdev_type_nss_2g.sta;
17242 *nss_5g = mac_ctx->vdev_type_nss_5g.sta;
17243 break;
17244 case QDF_SAP_MODE:
17245 *nss_2g = mac_ctx->vdev_type_nss_2g.sap;
17246 *nss_5g = mac_ctx->vdev_type_nss_5g.sap;
17247 break;
17248 case QDF_P2P_CLIENT_MODE:
17249 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_cli;
17250 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_cli;
17251 break;
17252 case QDF_P2P_GO_MODE:
17253 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_go;
17254 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_go;
17255 break;
17256 case QDF_P2P_DEVICE_MODE:
17257 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_dev;
17258 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_dev;
17259 break;
17260 case QDF_IBSS_MODE:
17261 *nss_2g = mac_ctx->vdev_type_nss_2g.ibss;
17262 *nss_5g = mac_ctx->vdev_type_nss_5g.ibss;
17263 break;
17264 case QDF_OCB_MODE:
17265 *nss_2g = mac_ctx->vdev_type_nss_2g.ocb;
17266 *nss_5g = mac_ctx->vdev_type_nss_5g.ocb;
17267 break;
17268 default:
17269 *nss_2g = 1;
17270 *nss_5g = 1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017271 sme_err("Unknown device mode");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070017272 break;
17273 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017274 sme_debug("mode - %d: nss_2g - %d, 5g - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070017275 dev_mode, *nss_2g, *nss_5g);
17276}
Jeff Johnson29e2ca12016-10-14 12:50:38 -070017277
17278static
17279QDF_STATUS csr_issue_add_sta_for_session_req(tpAniSirGlobal pMac,
17280 uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017281 tSirMacAddr sessionMacAddr,
17282 uint32_t type, uint32_t subType)
17283{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017284 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017285 struct add_sta_self_params *add_sta_self_req;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070017286 uint8_t nss_2g;
17287 uint8_t nss_5g;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070017288 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017289
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017290 add_sta_self_req = qdf_mem_malloc(sizeof(struct add_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017291 if (NULL == add_sta_self_req) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017292 sme_err("Unable to allocate memory for tAddSelfStaParams");
Dustin Brownd28772b2017-03-17 14:16:07 -070017293 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017294 }
17295
Krunal Soni985b8132017-02-10 18:49:08 -080017296 csr_get_vdev_type_nss(pMac, pMac->sme.currDeviceMode,
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070017297 &nss_2g, &nss_5g);
Krunal Soni985b8132017-02-10 18:49:08 -080017298 qdf_mem_copy(add_sta_self_req->self_mac_addr, sessionMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017299 sizeof(tSirMacAddr));
Krunal Soni985b8132017-02-10 18:49:08 -080017300 add_sta_self_req->curr_device_mode = pMac->sme.currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017301 add_sta_self_req->session_id = sessionId;
Krunal Soni985b8132017-02-10 18:49:08 -080017302 add_sta_self_req->type = type;
17303 add_sta_self_req->sub_type = subType;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070017304 add_sta_self_req->nss_2g = nss_2g;
17305 add_sta_self_req->nss_5g = nss_5g;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +053017306 add_sta_self_req->tx_aggregation_size =
17307 pMac->roam.configParam.tx_aggregation_size;
Paul Zhangee09f8e2018-04-23 16:11:32 +080017308 add_sta_self_req->tx_aggregation_size_be =
17309 pMac->roam.configParam.tx_aggregation_size_be;
17310 add_sta_self_req->tx_aggregation_size_bk =
17311 pMac->roam.configParam.tx_aggregation_size_bk;
17312 add_sta_self_req->tx_aggregation_size_vi =
17313 pMac->roam.configParam.tx_aggregation_size_vi;
17314 add_sta_self_req->tx_aggregation_size_vo =
17315 pMac->roam.configParam.tx_aggregation_size_vo;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +053017316 add_sta_self_req->rx_aggregation_size =
17317 pMac->roam.configParam.rx_aggregation_size;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +053017318 add_sta_self_req->enable_bcast_probe_rsp =
17319 pMac->roam.configParam.enable_bcast_probe_rsp;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +053017320 add_sta_self_req->fils_max_chan_guard_time =
17321 pMac->roam.configParam.fils_max_chan_guard_time;
Naveen Rawat2b6e3c92017-03-20 13:59:07 -070017322 add_sta_self_req->pkt_err_disconn_th =
17323 pMac->roam.configParam.pkt_err_disconn_th;
Yeshwanth Sriram Guntuka2ba6fe92017-10-04 14:40:45 +053017324 add_sta_self_req->oce_feature_bitmap =
17325 pMac->roam.configParam.oce_feature_bitmap;
Paul Zhang33fae272018-04-23 16:19:00 +080017326 add_sta_self_req->tx_aggr_sw_retry_threshold_be =
17327 pMac->roam.configParam.tx_aggr_sw_retry_threshold_be;
17328 add_sta_self_req->tx_aggr_sw_retry_threshold_bk =
17329 pMac->roam.configParam.tx_aggr_sw_retry_threshold_bk;
17330 add_sta_self_req->tx_aggr_sw_retry_threshold_vi =
17331 pMac->roam.configParam.tx_aggr_sw_retry_threshold_vi;
17332 add_sta_self_req->tx_aggr_sw_retry_threshold_vo =
17333 pMac->roam.configParam.tx_aggr_sw_retry_threshold_vo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017334 msg.type = WMA_ADD_STA_SELF_REQ;
17335 msg.reserved = 0;
17336 msg.bodyptr = add_sta_self_req;
17337 msg.bodyval = 0;
17338
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017339 sme_debug(
17340 "Send WMA_ADD_STA_SELF_REQ for selfMac=" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017341 MAC_ADDR_ARRAY(add_sta_self_req->self_mac_addr));
Tushnim Bhattacharyya647f93e2018-03-27 15:50:42 -070017342 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017343
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017344 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017345 sme_err("wma_post_ctrl_msg failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017346 qdf_mem_free(add_sta_self_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017347 add_sta_self_req = NULL;
17348 }
17349 return status;
17350}
17351
Sandeep Puligillaba71da42016-10-04 17:36:32 -070017352QDF_STATUS csr_roam_open_session(tpAniSirGlobal mac_ctx,
Krunal Soni8d184fa2017-11-20 21:52:05 -080017353 struct sme_session_params *session_param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017354{
Dustin Brownd28772b2017-03-17 14:16:07 -070017355 QDF_STATUS status;
17356 uint32_t existing_session_id;
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +053017357 struct mlme_ht_capabilities_info *ht_cap_info;
Dustin Brownd28772b2017-03-17 14:16:07 -070017358 uint32_t nCfgValue;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017359 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017360
Dustin Brownd28772b2017-03-17 14:16:07 -070017361 /* check to see if the mac address already belongs to a session */
17362 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Krunal Soni8d184fa2017-11-20 21:52:05 -080017363 (struct qdf_mac_addr *)session_param->self_mac_addr,
17364 &existing_session_id);
Dustin Brownd28772b2017-03-17 14:16:07 -070017365 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -080017366 sme_err("Session %d exists with mac address " MAC_ADDRESS_STR,
17367 existing_session_id,
17368 MAC_ADDR_ARRAY(session_param->self_mac_addr));
Sandeep Puligillaba71da42016-10-04 17:36:32 -070017369 return QDF_STATUS_E_FAILURE;
17370 }
17371
Dustin Brownd28772b2017-03-17 14:16:07 -070017372 /* attempt to retrieve session for Id */
Krunal Soni8d184fa2017-11-20 21:52:05 -080017373 session = CSR_GET_SESSION(mac_ctx, session_param->sme_session_id);
Dustin Brownd28772b2017-03-17 14:16:07 -070017374 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017375 sme_err("Session does not exist for interface %d",
Krunal Soni8d184fa2017-11-20 21:52:05 -080017376 session_param->sme_session_id);
Dustin Brownd28772b2017-03-17 14:16:07 -070017377 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017378 }
Dustin Brownd28772b2017-03-17 14:16:07 -070017379
17380 /* check to see if the session is already active */
17381 if (session->sessionActive) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017382 sme_err("Cannot re-open active session with Id %d",
Krunal Soni8d184fa2017-11-20 21:52:05 -080017383 session_param->sme_session_id);
Dustin Brownd28772b2017-03-17 14:16:07 -070017384 return QDF_STATUS_E_FAILURE;
17385 }
17386
17387 session->sessionActive = true;
Krunal Soni8d184fa2017-11-20 21:52:05 -080017388 session->sessionId = session_param->sme_session_id;
Dustin Brownd28772b2017-03-17 14:16:07 -070017389
17390 /* Initialize FT related data structures only in STA mode */
Jeff Johnson46841a52018-06-10 20:17:36 -070017391 sme_ft_open(MAC_HANDLE(mac_ctx), session->sessionId);
Dustin Brownd28772b2017-03-17 14:16:07 -070017392
Krunal Soni8d184fa2017-11-20 21:52:05 -080017393 session->session_open_cb = session_param->session_open_cb;
17394 session->session_close_cb = session_param->session_close_cb;
17395 session->callback = session_param->callback;
17396 session->pContext = session_param->callback_ctx;
17397
17398 qdf_mem_copy(&session->selfMacAddr, session_param->self_mac_addr,
Dustin Brownd28772b2017-03-17 14:16:07 -070017399 sizeof(struct qdf_mac_addr));
17400 status = qdf_mc_timer_init(&session->hTimerRoaming,
17401 QDF_TIMER_TYPE_SW,
17402 csr_roam_roaming_timer_handler,
17403 &session->roamingTimerInfo);
17404 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017405 sme_err("cannot allocate memory for Roaming timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070017406 return status;
17407 }
17408
17409 status = qdf_mc_timer_init(&session->roaming_offload_timer,
17410 QDF_TIMER_TYPE_SW,
17411 csr_roam_roaming_offload_timeout_handler,
17412 &session->roamingTimerInfo);
17413 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017414 sme_err("mem fail for roaming timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070017415 return status;
17416 }
17417
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +053017418 ht_cap_info = &mac_ctx->mlme_cfg->ht_caps.ht_cap_info;
Vignesh Viswanathan78182502018-08-06 15:13:30 +053017419 session->htConfig.ht_rx_ldpc = ht_cap_info->adv_coding_cap;
17420 session->htConfig.ht_tx_stbc = ht_cap_info->tx_stbc;
17421 session->htConfig.ht_rx_stbc = ht_cap_info->rx_stbc;
17422 session->htConfig.ht_sgi20 = ht_cap_info->short_gi_20_mhz;
17423 session->htConfig.ht_sgi40 = ht_cap_info->short_gi_40_mhz;
Dustin Brownd28772b2017-03-17 14:16:07 -070017424
17425#ifdef FEATURE_WLAN_BTAMP_UT_RF
17426 status = qdf_mc_timer_init(&session->hTimerJoinRetry, QDF_TIMER_TYPE_SW,
17427 csr_roam_join_retry_timer_handler,
17428 &session->joinRetryTimerInfo);
17429 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017430 sme_err("cannot allocate memory for join retry timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070017431 return status;
17432 }
17433#endif /* FEATURE_WLAN_BTAMP_UT_RF */
17434
17435 nCfgValue = 0;
17436 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MAX_MPDU_LENGTH, &nCfgValue);
17437 session->vht_config.max_mpdu_len = nCfgValue;
17438
17439 nCfgValue = 0;
17440 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET,
17441 &nCfgValue);
17442 session->vht_config.supported_channel_widthset = nCfgValue;
17443
17444 nCfgValue = 0;
17445 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_LDPC_CODING_CAP, &nCfgValue);
17446 session->vht_config.ldpc_coding = nCfgValue;
17447
17448 nCfgValue = 0;
17449 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SHORT_GI_80MHZ, &nCfgValue);
17450 session->vht_config.shortgi80 = nCfgValue;
17451
17452 nCfgValue = 0;
17453 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ,
17454 &nCfgValue);
17455 session->vht_config.shortgi160and80plus80 = nCfgValue;
17456
17457 nCfgValue = 0;
17458 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TXSTBC, &nCfgValue);
17459 session->vht_config.tx_stbc = nCfgValue;
17460
17461 nCfgValue = 0;
17462 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_RXSTBC, &nCfgValue);
17463 session->vht_config.rx_stbc = nCfgValue;
17464
17465 nCfgValue = 0;
17466 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMER_CAP, &nCfgValue);
17467 session->vht_config.su_beam_former = nCfgValue;
17468
17469 nCfgValue = 0;
17470 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, &nCfgValue);
17471 session->vht_config.su_beam_formee = nCfgValue;
17472
17473 nCfgValue = 0;
17474 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
17475 &nCfgValue);
17476 session->vht_config.csnof_beamformer_antSup = nCfgValue;
17477
17478 nCfgValue = 0;
17479 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_NUM_SOUNDING_DIMENSIONS,
17480 &nCfgValue);
17481 session->vht_config.num_soundingdim = nCfgValue;
17482
17483 nCfgValue = 0;
17484 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MU_BEAMFORMER_CAP, &nCfgValue);
17485 session->vht_config.mu_beam_former = nCfgValue;
17486
17487 nCfgValue = 0;
17488 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, &nCfgValue);
17489 session->vht_config.mu_beam_formee = nCfgValue;
17490
17491 nCfgValue = 0;
17492 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TXOP_PS, &nCfgValue);
17493 session->vht_config.vht_txops = nCfgValue;
17494
17495 nCfgValue = 0;
17496 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_HTC_VHTC_CAP, &nCfgValue);
17497 session->vht_config.htc_vhtcap = nCfgValue;
17498
17499 nCfgValue = 0;
17500 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_RX_ANT_PATTERN, &nCfgValue);
17501 session->vht_config.rx_antpattern = nCfgValue;
17502
17503 nCfgValue = 0;
17504 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TX_ANT_PATTERN, &nCfgValue);
17505 session->vht_config.tx_antpattern = nCfgValue;
17506
17507 nCfgValue = 0;
17508 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, &nCfgValue);
17509 session->vht_config.max_ampdu_lenexp = nCfgValue;
17510
17511 csr_update_session_he_cap(mac_ctx, session);
17512
Krunal Soni8d184fa2017-11-20 21:52:05 -080017513 return csr_issue_add_sta_for_session_req(mac_ctx,
17514 session_param->sme_session_id,
17515 session_param->self_mac_addr,
17516 session_param->type_of_persona,
17517 session_param->subtype_of_persona);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017518}
17519
Pragaspathi Thilagarajad7a5f52018-08-08 14:02:35 +053017520QDF_STATUS csr_process_del_sta_session_rsp(tpAniSirGlobal mac_ctx,
17521 uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017522{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017523 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017524 struct del_sta_self_params *rsp;
17525 uint8_t sessionId;
Pragaspathi Thilagarajad7a5f52018-08-08 14:02:35 +053017526 tListElem *entry;
17527 tSmeCmd *sme_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017528
17529 if (pMsg == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017530 sme_err("msg ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017531 return status;
17532 }
Pragaspathi Thilagarajad7a5f52018-08-08 14:02:35 +053017533
17534 entry = csr_nonscan_active_ll_peek_head(mac_ctx, LL_ACCESS_LOCK);
17535 if (!entry) {
17536 sme_err("NO commands are ACTIVE");
17537 return status;
17538 }
17539
17540 sme_command = GET_BASE_ADDR(entry, tSmeCmd, Link);
17541 if (e_sme_command_del_sta_session != sme_command->command) {
17542 sme_err("No Del sta session command ACTIVE");
17543 return status;
17544 }
17545
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017546 rsp = (struct del_sta_self_params *) pMsg;
Krunal Soni985b8132017-02-10 18:49:08 -080017547 sessionId = rsp->session_id;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017548 sme_debug("Del Sta rsp status = %d", rsp->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017549 /* This session is done. */
Pragaspathi Thilagarajad7a5f52018-08-08 14:02:35 +053017550 csr_cleanup_session(mac_ctx, sessionId);
Krunal Soni985b8132017-02-10 18:49:08 -080017551 if (rsp->sme_callback) {
Pragaspathi Thilagarajad7a5f52018-08-08 14:02:35 +053017552 status = sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017553 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017554 sme_debug("Failed to Release Lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017555 else {
Krunal Soni8d184fa2017-11-20 21:52:05 -080017556 rsp->sme_callback(rsp->session_id);
Pragaspathi Thilagarajad7a5f52018-08-08 14:02:35 +053017557 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017558 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017559 sme_debug("Failed to get Lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017560 return status;
17561 }
17562 }
17563 }
Krunal Soni985b8132017-02-10 18:49:08 -080017564
Pragaspathi Thilagarajad7a5f52018-08-08 14:02:35 +053017565 /* Remove this command out of the non scan active list */
17566 if (csr_nonscan_active_ll_remove_entry(mac_ctx, entry,
17567 LL_ACCESS_LOCK)) {
17568 csr_release_command(mac_ctx, sme_command);
17569 }
17570
Krunal Soni985b8132017-02-10 18:49:08 -080017571 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017572}
17573
17574
Jeff Johnson29e2ca12016-10-14 12:50:38 -070017575static QDF_STATUS
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +053017576csr_issue_del_sta_for_session_req(tpAniSirGlobal mac_ctx, uint32_t session_id,
17577 tSirMacAddr session_mac_addr,
Krunal Soni8d184fa2017-11-20 21:52:05 -080017578 csr_session_close_cb callback,
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +053017579 void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017580{
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +053017581 QDF_STATUS status = QDF_STATUS_SUCCESS;
17582 tSmeCmd *sme_command;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017583
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +053017584 sme_command = csr_get_command_buffer(mac_ctx);
17585 if (NULL == sme_command) {
17586 status = QDF_STATUS_E_RESOURCES;
17587 } else {
17588 sme_command->command = e_sme_command_del_sta_session;
17589 sme_command->sessionId = (uint8_t)session_id;
17590 sme_command->u.delStaSessionCmd.session_close_cb = callback;
17591 sme_command->u.delStaSessionCmd.context = context;
17592 qdf_mem_copy(sme_command->u.delStaSessionCmd.selfMacAddr,
17593 session_mac_addr, sizeof(tSirMacAddr));
17594 status = csr_queue_sme_command(mac_ctx, sme_command, true);
17595 if (!QDF_IS_STATUS_SUCCESS(status))
17596 sme_err("fail to send message status = %d", status);
Min Liu22202b72018-02-12 14:01:24 +080017597 }
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +053017598 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017599}
17600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017601void csr_cleanup_session(tpAniSirGlobal pMac, uint32_t sessionId)
17602{
17603 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017604 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
17605 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017606
17607 csr_roam_stop(pMac, sessionId);
17608
17609 /* Clean up FT related data structures */
Jeff Johnson46841a52018-06-10 20:17:36 -070017610 sme_ft_close(MAC_HANDLE(pMac), sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017611 csr_free_connect_bss_desc(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080017612 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017613 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
Anurag Chouhan210db072016-02-22 18:42:15 +053017614 qdf_mc_timer_destroy(&pSession->hTimerRoaming);
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070017615 qdf_mc_timer_destroy(&pSession->roaming_offload_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017616#ifdef FEATURE_WLAN_BTAMP_UT_RF
Anurag Chouhan210db072016-02-22 18:42:15 +053017617 qdf_mc_timer_destroy(&pSession->hTimerJoinRetry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017618#endif
Krunal Soni72dba662017-02-15 20:13:17 -080017619 purge_sme_session_pending_cmd_list(pMac, sessionId);
Krunal Soni81f068c2017-02-23 19:51:55 -080017620 purge_sme_session_pending_scan_cmd_list(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017621 csr_init_session(pMac, sessionId);
17622 }
17623}
17624
Krunal Soni8d184fa2017-11-20 21:52:05 -080017625QDF_STATUS csr_roam_close_session(tpAniSirGlobal mac_ctx,
17626 uint32_t session_id, bool sync)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017627{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017628 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krunal Soni8d184fa2017-11-20 21:52:05 -080017629 struct csr_roam_session *session;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017630
Krunal Soni8d184fa2017-11-20 21:52:05 -080017631 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
17632 sme_err("session %d not found", session_id);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017633 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017634 }
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017635
Krunal Soni8d184fa2017-11-20 21:52:05 -080017636 session = CSR_GET_SESSION(mac_ctx, session_id);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017637 /* Vdev going down stop roaming */
Krunal Soni8d184fa2017-11-20 21:52:05 -080017638 session->fCancelRoaming = true;
17639 if (sync) {
17640 csr_cleanup_session(mac_ctx, session_id);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017641 return status;
17642 }
17643
Abhishek Singh809c41a2018-08-10 14:13:08 +053017644 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
17645 sme_debug("Stop Wait for key timer and change substate to eCSR_ROAM_SUBSTATE_NONE");
17646 csr_roam_stop_wait_for_key_timer(mac_ctx);
17647 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
17648 session_id);
17649 }
17650
Krunal Soni8d184fa2017-11-20 21:52:05 -080017651 purge_sme_session_pending_cmd_list(mac_ctx, session_id);
17652 purge_sme_session_active_cmd_list(mac_ctx, session_id);
17653 purge_sme_session_pending_scan_cmd_list(mac_ctx, session_id);
17654 purge_sme_session_active_scan_cmd_list(mac_ctx, session_id);
17655 if (!session->session_close_cb) {
17656 sme_err("no close session callback registered");
17657 return QDF_STATUS_E_FAILURE;
17658 }
17659 status = csr_issue_del_sta_for_session_req(mac_ctx,
17660 session_id, session->selfMacAddr.bytes,
17661 session->session_close_cb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017662 return status;
17663}
17664
17665static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId)
17666{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017667 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017668
17669 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017670 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017671 return;
17672 }
17673
17674 pSession->sessionActive = false;
17675 pSession->sessionId = CSR_SESSION_ID_INVALID;
17676 pSession->callback = NULL;
17677 pSession->pContext = NULL;
17678 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
wadesongd5477662018-04-25 17:00:47 +080017679 csr_saved_scan_cmd_free_fields(pMac, pSession);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017680 csr_free_roam_profile(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080017681 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017682 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
17683 csr_free_connect_bss_desc(pMac, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017684 qdf_mem_set(&pSession->selfMacAddr, sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017685 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017686 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017687 pSession->pWpaRsnReqIE = NULL;
17688 }
17689 pSession->nWpaRsnReqIeLength = 0;
17690 if (pSession->pWpaRsnRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017691 qdf_mem_free(pSession->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017692 pSession->pWpaRsnRspIE = NULL;
17693 }
17694 pSession->nWpaRsnRspIeLength = 0;
17695#ifdef FEATURE_WLAN_WAPI
17696 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017697 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017698 pSession->pWapiReqIE = NULL;
17699 }
17700 pSession->nWapiReqIeLength = 0;
17701 if (pSession->pWapiRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017702 qdf_mem_free(pSession->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017703 pSession->pWapiRspIE = NULL;
17704 }
17705 pSession->nWapiRspIeLength = 0;
17706#endif /* FEATURE_WLAN_WAPI */
17707 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017708 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017709 pSession->pAddIEScan = NULL;
17710 }
17711 pSession->nAddIEScanLength = 0;
17712 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017713 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017714 pSession->pAddIEAssoc = NULL;
17715 }
17716 pSession->nAddIEAssocLength = 0;
17717}
17718
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017719QDF_STATUS csr_roam_get_session_id_from_bssid(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017720 struct qdf_mac_addr *bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017721 uint32_t *pSessionId)
17722{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017723 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017724 uint32_t i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017725
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017726 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
17727 if (CSR_IS_SESSION_VALID(pMac, i)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053017728 if (qdf_is_macaddr_equal(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017729 &pMac->roam.roamSession[i].connectedProfile.
17730 bssid)) {
17731 /* Found it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017732 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017733 *pSessionId = i;
17734 break;
17735 }
17736 }
17737 }
17738 return status;
17739}
17740
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017741/* This function assumes that we only support one IBSS session.
17742 * We cannot use BSSID to identify session because for IBSS,
17743 * the bssid changes.
17744 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017745static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac)
17746{
17747 uint32_t i, nRet = CSR_SESSION_ID_INVALID;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017748 struct csr_roam_session *pSession;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017750 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
17751 if (CSR_IS_SESSION_VALID(pMac, i)) {
17752 pSession = CSR_GET_SESSION(pMac, i);
17753 if (pSession->pCurRoamProfile
17754 &&
17755 (csr_is_bss_type_ibss
17756 (pSession->connectedProfile.BSSType))) {
17757 /* Found it */
17758 nRet = i;
17759 break;
17760 }
17761 }
17762 }
17763 return nRet;
17764}
17765
Anurag Chouhan6d760662016-02-20 16:05:43 +053017766static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017767{
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017768 uint32_t sessionId = 0;
17769
17770 /*
17771 * Update the current BSS info in ho control block based on connected
17772 * profile info from pmac global structure
17773 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017774
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017775 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017776 " csr_roam_link_up: WLAN link UP with AP= " MAC_ADDRESS_STR,
17777 MAC_ADDR_ARRAY(bssid.bytes));
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017778 /* Check for user misconfig of RSSI trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017779 pMac->roam.configParam.vccRssiThreshold =
17780 (0 == pMac->roam.configParam.vccRssiThreshold) ?
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017781 CSR_VCC_RSSI_THRESHOLD :
17782 pMac->roam.configParam.vccRssiThreshold;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017783 /* Check for user misconfig of UL MAC Loss trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017784 pMac->roam.configParam.vccUlMacLossThreshold =
17785 (0 == pMac->roam.configParam.vccUlMacLossThreshold) ?
17786 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.
17787 vccUlMacLossThreshold;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017788 /* Indicate the neighbor roal algorithm about the connect indication */
17789 csr_roam_get_session_id_from_bssid(pMac, &bssid,
17790 &sessionId);
17791 csr_neighbor_roam_indicate_connect(pMac, sessionId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017792 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017793}
17794
17795static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId)
17796{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017797 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017798
17799 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017800 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017801 return;
17802 }
17803 /* Only to handle the case for Handover on infra link */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017804 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017805 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017806 /*
17807 * Incase of station mode, immediately stop data transmission whenever
17808 * link down is detected.
17809 */
17810 if (csr_roam_is_sta_mode(pMac, sessionId)
17811 && !CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -080017812 && !csr_roam_is11r_assoc(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017813 sme_debug("Inform Link lost for session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017814 sessionId);
17815 csr_roam_call_callback(pMac, sessionId, NULL, 0,
17816 eCSR_ROAM_LOSTLINK,
17817 eCSR_ROAM_RESULT_LOSTLINK);
17818 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017819 /* deregister the clients requesting stats from PE/TL & also stop the
17820 * corresponding timers
17821 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017822 csr_roam_dereg_statistics_req(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017823 /* Indicate the neighbor roal algorithm about the disconnect
17824 * indication
17825 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017826 csr_neighbor_roam_indicate_disconnect(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017827
17828 /* Remove this code once SLM_Sessionization is supported */
17829 /* BMPS_WORKAROUND_NOT_NEEDED */
17830 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
17831 csr_is_infra_ap_started(pMac) &&
17832 pMac->roam.configParam.doBMPSWorkaround) {
17833 pMac->roam.configParam.doBMPSWorkaround = 0;
17834 }
17835
17836}
17837
Naveen Rawatfa2a1002018-05-17 16:06:37 -070017838#ifndef QCA_SUPPORT_CP_STATS
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017839QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017840 uint8_t staId, uint8_t sessionId)
17841{
17842 tAniGetPEStatsReq *pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017843 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017844
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017845 pMsg = qdf_mem_malloc(sizeof(tAniGetPEStatsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017846 if (NULL == pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017847 sme_err("Failed to allocate mem for stats req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017848 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017849 }
17850 /* need to initiate a stats request to PE */
17851 pMsg->msgType = eWNI_SME_GET_STATISTICS_REQ;
17852 pMsg->msgLen = (uint16_t) sizeof(tAniGetPEStatsReq);
17853 pMsg->staId = staId;
17854 pMsg->statsMask = statsMask;
17855 pMsg->sessionId = sessionId;
Rajeev Kumard138ac52017-01-30 18:38:37 -080017856 status = umac_send_mb_message_to_mac(pMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017857 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017858 sme_debug("Failed to send down the stats req ");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017859
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017860 return status;
17861}
17862
17863/**
17864 * csr_update_stats() - updates correct stats struct in mac_ctx
17865 * @mac: mac global context
17866 * @stats_type: stats type
17867 * @sme_stats_rsp: stats rsp msg packet
17868 * @stats: input stats data buffer to fill in mac_ctx struct
17869 * @length: out param - stats length
17870 *
17871 * This function fills corresponding stats struct in mac_cts based on stats type
17872 * passed
17873 *
17874 * Return: void
17875 */
17876static void
17877csr_update_stats(tpAniSirGlobal mac, uint8_t stats_type,
17878 tAniGetPEStatsRsp *sme_stats_rsp,
17879 uint8_t **stats, uint32_t *length)
17880{
17881 switch (stats_type) {
17882 case eCsrSummaryStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017883 sme_debug("summary stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017884 qdf_mem_copy((uint8_t *) &mac->roam.summaryStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017885 sizeof(tCsrSummaryStatsInfo));
17886 *stats += sizeof(tCsrSummaryStatsInfo);
17887 *length -= sizeof(tCsrSummaryStatsInfo);
17888 break;
17889 case eCsrGlobalClassAStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017890 sme_debug("ClassA stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017891 qdf_mem_copy((uint8_t *) &mac->roam.classAStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017892 sizeof(tCsrGlobalClassAStatsInfo));
17893 *stats += sizeof(tCsrGlobalClassAStatsInfo);
17894 *length -= sizeof(tCsrGlobalClassAStatsInfo);
17895 break;
Himanshu Agarwal37e42412016-07-21 14:35:09 +053017896 case csr_per_chain_rssi_stats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017897 sme_debug("csrRoamStatsRspProcessor:Per Chain RSSI stats");
Himanshu Agarwal37e42412016-07-21 14:35:09 +053017898 qdf_mem_copy((uint8_t *)&mac->roam.per_chain_rssi_stats,
17899 *stats, sizeof(struct csr_per_chain_rssi_stats_info));
17900 *stats += sizeof(struct csr_per_chain_rssi_stats_info);
17901 *length -= sizeof(struct csr_per_chain_rssi_stats_info);
17902 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017903 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017904 sme_warn("unknown stats type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017905 break;
17906 }
17907}
17908
17909/**
17910 * csr_roam_stats_rsp_processor() - processes stats rsp msg
17911 * @pMac mac global context
17912 * @pSirMsg: incoming message
17913 *
17914 * Return: void
17915 */
17916void csr_roam_stats_rsp_processor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
17917{
17918 tAniGetPEStatsRsp *pSmeStatsRsp;
17919 tListElem *pEntry = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017920 struct csr_statsclient_reqinfo *pTempStaEntry = NULL;
17921 struct csr_pestats_reqinfo *pPeStaEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017922 uint32_t tempMask = 0;
17923 uint8_t counter = 0;
17924 uint8_t *pStats = NULL;
17925 uint32_t length = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017926 int8_t rssi = 0, snr = 0;
17927 uint32_t *pRssi = NULL, *pSnr = NULL;
17928 uint32_t linkCapacity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017929
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017930 pSmeStatsRsp = (tAniGetPEStatsRsp *) pSirMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017931 if (pSmeStatsRsp->rc) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017932 sme_warn("stats rsp from PE shows failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017933 goto post_update;
17934 }
17935 tempMask = pSmeStatsRsp->statsMask;
17936 pStats = ((uint8_t *) &pSmeStatsRsp->statsMask) +
17937 sizeof(pSmeStatsRsp->statsMask);
17938 /*
17939 * subtract all statistics from this length, and after processing the
17940 * entire 'stat' part of the message, if the length is not zero, then
17941 * rssi is piggy packed in this 'stats' message.
17942 */
17943 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
17944 /* new stats info from PE, fill up the stats strucutres in PMAC */
17945 while (tempMask) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017946 if (tempMask & 1)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017947 csr_update_stats(pMac, counter, pSmeStatsRsp,
17948 &pStats, &length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017949 tempMask >>= 1;
17950 counter++;
17951 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017952 if (length != 0) {
17953 pRssi = (uint32_t *) pStats;
17954 rssi = (int8_t) *pRssi;
17955 pStats += sizeof(uint32_t);
17956 length -= sizeof(uint32_t);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017957 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017958 /* If riva is not sending rssi, continue to use the hack */
17959 rssi = RSSI_HACK_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017960
17961 if (length != 0) {
17962 linkCapacity = *(uint32_t *) pStats;
17963 pStats += sizeof(uint32_t);
17964 length -= sizeof(uint32_t);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017965 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017966 linkCapacity = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017967
17968 if (length != 0) {
17969 pSnr = (uint32_t *) pStats;
17970 snr = (int8_t) *pSnr;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017971 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017972 snr = SNR_HACK_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017973
17974post_update:
17975 /* make sure to update the pe stats req list */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017976 pEntry = csr_roam_find_in_pe_stats_req_list(pMac,
17977 pSmeStatsRsp->statsMask);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017978 if (pEntry) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017979 pPeStaEntry = GET_BASE_ADDR(pEntry,
17980 struct csr_pestats_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017981 pPeStaEntry->rspPending = false;
17982
17983 }
17984 /* check the one timer cases */
17985 pEntry = csr_roam_check_client_req_list(pMac, pSmeStatsRsp->statsMask);
17986 if (pEntry) {
17987 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017988 GET_BASE_ADDR(pEntry,
17989 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017990 if (pTempStaEntry->timerExpired) {
17991 /* send up the stats report */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017992 csr_roam_report_statistics(pMac,
17993 pTempStaEntry->statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017994 pTempStaEntry->callback,
17995 pTempStaEntry->staId,
17996 pTempStaEntry->pContext);
17997 /* also remove from the client list */
17998 csr_roam_remove_stat_list_entry(pMac, pEntry);
17999 pTempStaEntry = NULL;
18000 }
18001 }
18002}
18003
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018004tListElem *csr_roam_find_in_pe_stats_req_list(
18005 tpAniSirGlobal pMac, uint32_t statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018006{
18007 tListElem *pEntry = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018008 struct csr_pestats_reqinfo *pTempStaEntry = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018009
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018010 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
18011 if (!pEntry) {
18012 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018013 sme_debug("csr_roam_find_in_pe_stats_req_list: List empty, no request to PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018014 return NULL;
18015 }
18016 while (pEntry) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018017 pTempStaEntry = GET_BASE_ADDR(pEntry, struct csr_pestats_reqinfo, link);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018018 if (pTempStaEntry->statsMask == statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018019 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018020 pEntry =
18021 csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
18022 LL_ACCESS_NOLOCK);
18023 }
18024 return pEntry;
18025}
18026
Jeff Johnson29e2ca12016-10-14 12:50:38 -070018027static
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018028tListElem *csr_roam_checkn_update_client_req_list(
18029tpAniSirGlobal pMac, struct csr_statsclient_reqinfo *pStaEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018030 bool update)
18031{
18032 tListElem *pEntry;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018033 struct csr_statsclient_reqinfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018034
18035 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
18036 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018037 if (!pEntry) {
18038 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018039 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018040 return NULL;
18041 }
18042 while (pEntry) {
18043 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018044 GET_BASE_ADDR(pEntry,
18045 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018046 if ((pTempStaEntry->requesterId == pStaEntry->requesterId)
18047 && (pTempStaEntry->statsMask == pStaEntry->statsMask)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018048 if (update) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018049 pTempStaEntry->callback = pStaEntry->callback;
18050 pTempStaEntry->pContext = pStaEntry->pContext;
18051 }
18052 break;
18053 }
18054 pEntry =
18055 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
18056 LL_ACCESS_NOLOCK);
18057 }
18058 return pEntry;
18059}
18060
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018061tListElem *csr_roam_check_client_req_list(tpAniSirGlobal pMac,
18062 uint32_t statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018063{
18064 tListElem *pEntry;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018065 struct csr_statsclient_reqinfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018066
18067 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
18068 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018069 if (!pEntry) {
18070 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018071 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018072 return NULL;
18073 }
18074 while (pEntry) {
18075 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018076 GET_BASE_ADDR(pEntry,
18077 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018078 if ((pTempStaEntry->
18079 statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018080 break;
18081 }
18082 pEntry =
18083 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
18084 LL_ACCESS_NOLOCK);
18085 }
18086 return pEntry;
18087}
18088
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018089struct csr_statsclient_reqinfo *csr_roam_insert_entry_into_list(
18090 tpAniSirGlobal pMac, tDblLinkList *pStaList,
18091 struct csr_statsclient_reqinfo *
18092 pStaEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018093{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018094 struct csr_statsclient_reqinfo *pNewStaEntry = NULL;
Naveen Rawatd0ca4412017-06-16 14:19:19 -070018095 /*
18096 * if same entity requested for same set of stats with different
18097 * callback update it
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018098 */
18099 if (NULL == csr_roam_checkn_update_client_req_list(pMac, pStaEntry,
18100 true)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018101
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018102 pNewStaEntry = qdf_mem_malloc(sizeof(struct csr_statsclient_reqinfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018103 if (NULL == pNewStaEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018104 sme_err("couldn't allocate memory for the entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018105 return NULL;
18106 }
18107
18108 pNewStaEntry->callback = pStaEntry->callback;
18109 pNewStaEntry->pContext = pStaEntry->pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018110 pNewStaEntry->requesterId = pStaEntry->requesterId;
18111 pNewStaEntry->statsMask = pStaEntry->statsMask;
18112 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
18113 pNewStaEntry->pMac = pStaEntry->pMac;
18114 pNewStaEntry->staId = pStaEntry->staId;
18115 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
18116
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018117 csr_ll_insert_tail(pStaList, &pNewStaEntry->link,
18118 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018119 }
18120 return pNewStaEntry;
18121}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070018122#endif /* QCA_SUPPORT_CP_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018123
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018124QDF_STATUS csr_get_rssi(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018125 tCsrRssiCallback callback,
18126 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053018127 struct qdf_mac_addr bssId,
Jeff Johnson8bd23352017-09-26 11:39:24 -070018128 int8_t lastRSSI, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018129{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018130 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070018131 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018132 uint32_t sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018133 tAniGetRssiReq *pMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018134
18135 status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018136 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018137 callback(lastRSSI, staId, pContext);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018138 sme_err("Failed to get SessionId");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018139 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018140 }
18141
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018142 pMsg = qdf_mem_malloc(sizeof(tAniGetRssiReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018143 if (NULL == pMsg) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018144 sme_err("csr_get_rssi: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018145 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018146 }
18147
18148 pMsg->msgType = eWNI_SME_GET_RSSI_REQ;
18149 pMsg->msgLen = (uint16_t) sizeof(tAniGetRssiReq);
18150 pMsg->sessionId = sessionId;
18151 pMsg->staId = staId;
18152 pMsg->rssiCallback = callback;
18153 pMsg->pDevContext = pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018154 /*
18155 * store RSSI at time of calling, so that if RSSI request cannot
18156 * be sent to firmware, this value can be used to return immediately
18157 */
18158 pMsg->lastRSSI = lastRSSI;
18159 msg.type = eWNI_SME_GET_RSSI_REQ;
18160 msg.bodyptr = pMsg;
18161 msg.reserved = 0;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080018162 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080018163 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018164 sme_err("scheduler_post_msg failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018165 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018166 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018167 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018168 return status;
18169}
18170
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018171QDF_STATUS csr_get_snr(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018172 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +053018173 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018174{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018175 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070018176 struct scheduler_msg msg = {0};
Yuanyuan Liu889167d2017-05-31 16:56:26 -070018177 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018178 tAniGetSnrReq *pMsg;
18179
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018180 pMsg = (tAniGetSnrReq *) qdf_mem_malloc(sizeof(tAniGetSnrReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018181 if (NULL == pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018182 sme_err("failed to allocate mem for req");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018183 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018184 }
18185
Tushnim Bhattacharyya85bedb92017-05-17 13:23:14 -070018186 status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
18187 if (!QDF_IS_STATUS_SUCCESS(status)) {
Houston Hoffman77bf4072017-07-17 01:01:18 -070018188 qdf_mem_free(pMsg);
Srinivas Girigowdaaf0173e2017-06-01 11:50:41 -070018189 sme_err("Couldn't find session_id for given BSSID");
18190 return status;
Tushnim Bhattacharyya85bedb92017-05-17 13:23:14 -070018191 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018192
18193 pMsg->msgType = eWNI_SME_GET_SNR_REQ;
18194 pMsg->msgLen = (uint16_t) sizeof(tAniGetSnrReq);
18195 pMsg->sessionId = sessionId;
18196 pMsg->staId = staId;
18197 pMsg->snrCallback = callback;
18198 pMsg->pDevContext = pContext;
18199 msg.type = eWNI_SME_GET_SNR_REQ;
18200 msg.bodyptr = pMsg;
18201 msg.reserved = 0;
18202
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080018203 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080018204 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018205 sme_err("failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018206 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018207 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018208 }
18209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018210 return status;
18211}
18212
Naveen Rawatfa2a1002018-05-17 16:06:37 -070018213#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018214/**
18215 * csr_deregister_client_request() - deregisters a get stats request
18216 * @mac_ctx: mac global context
18217 * @sta_entry: stats request entry
18218 *
18219 * Return: status of operation
18220 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018221static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018222csr_deregister_client_request(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018223 struct csr_statsclient_reqinfo *sta_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018224{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018225 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018226 tListElem *entry = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018227 struct csr_statsclient_reqinfo *ptr_sta_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018228
18229 entry = csr_roam_checkn_update_client_req_list(mac_ctx, sta_entry,
18230 false);
18231 if (!entry) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018232 sme_err("callback is empty in the request & couldn't find any existing request in statsClientReqList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018233 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018234 }
18235 /* clean up & return */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018236 ptr_sta_entry = GET_BASE_ADDR(entry,
18237 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018238 if (NULL != ptr_sta_entry->pPeStaEntry) {
18239 ptr_sta_entry->pPeStaEntry->numClient--;
18240 /* check if we need to delete the entry from peStatsReqList */
18241 if (!ptr_sta_entry->pPeStaEntry->numClient)
18242 csr_roam_remove_entry_from_pe_stats_req_list(mac_ctx,
18243 ptr_sta_entry->pPeStaEntry);
18244 }
18245 /* check if we need to stop the tl stats timer too */
18246 mac_ctx->roam.tlStatsReqInfo.numClient--;
Anurag Chouhan210db072016-02-22 18:42:15 +053018247 qdf_mc_timer_stop(&ptr_sta_entry->timer);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053018248 /* Destroy the qdf timer... */
Anurag Chouhan210db072016-02-22 18:42:15 +053018249 status = qdf_mc_timer_destroy(&ptr_sta_entry->timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018250 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018251 sme_err(
18252 "failed to destroy Client req timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018253
18254 csr_roam_remove_stat_list_entry(mac_ctx, entry);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018255 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018256}
18257
18258/**
18259 * csr_insert_stats_request_to_list() - inserts request to existing list
18260 * @mac_ctx: mac global context
18261 * @sta_entry: stats request entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018262 *
18263 * Return: status of operation
18264 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018265static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018266csr_insert_stats_request_to_list(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018267 struct csr_statsclient_reqinfo *sta_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018268{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018269struct csr_statsclient_reqinfo *ptr_sta_entry = csr_roam_insert_entry_into_list(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018270 mac_ctx, &mac_ctx->roam.statsClientReqList,
18271 sta_entry);
18272 if (!ptr_sta_entry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018273 sme_err("Failed to insert req in statsClientReqList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018274 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018275 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018276 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018277}
18278
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018279QDF_STATUS csr_get_statistics(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018280 eCsrStatsRequesterType requesterId,
18281 uint32_t statsMask,
18282 tCsrStatsCallback callback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018283 uint8_t staId,
18284 void *pContext,
18285 uint8_t sessionId)
18286{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018287 struct csr_statsclient_reqinfo staEntry;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018288 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018289 bool insertInClientList = false;
18290 uint32_t temp_mask = 0;
18291
18292 if (csr_is_all_session_disconnected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018293 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018294
18295 if (csr_neighbor_middle_of_roaming(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018296 sme_debug("in the middle of roaming states");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018297 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018298 }
18299
18300 if ((!statsMask) && (!callback)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018301 sme_err("statsMask & callback empty in the request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018302 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018303 }
18304 /* for the search list method for deregister */
18305 staEntry.requesterId = requesterId;
18306 staEntry.statsMask = statsMask;
18307 /* requester wants to deregister or just an error */
18308 if ((statsMask) && (!callback))
18309 return csr_deregister_client_request(pMac, &staEntry);
18310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018311 /* add the request in the client req list */
18312 staEntry.callback = callback;
18313 staEntry.pContext = pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018314 staEntry.pPeStaEntry = NULL;
18315 staEntry.staId = staId;
18316 staEntry.pMac = pMac;
18317 staEntry.timerExpired = false;
18318 staEntry.sessionId = sessionId;
18319
Naveen Rawatd0ca4412017-06-16 14:19:19 -070018320 temp_mask = statsMask & ~(1 << eCsrGlobalClassDStats);
18321 if (temp_mask) {
18322 /* send down a req */
18323 status = csr_send_mb_stats_req_msg(pMac,
18324 temp_mask, staId, sessionId);
18325 if (!QDF_IS_STATUS_SUCCESS(status))
18326 sme_err("failed to send down stats req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018327 /*
Naveen Rawatd0ca4412017-06-16 14:19:19 -070018328 * so that when the stats rsp comes back from PE we
18329 * respond to upper layer right away
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018330 */
Naveen Rawatd0ca4412017-06-16 14:19:19 -070018331 staEntry.timerExpired = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018332 insertInClientList = true;
18333 }
Naveen Rawatd0ca4412017-06-16 14:19:19 -070018334 /* if looking for stats from TL only */
18335 if (!insertInClientList) {
18336 /* return the stats */
18337 csr_roam_report_statistics(pMac, statsMask, callback,
18338 staId, pContext);
18339 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018340 }
18341 if (insertInClientList)
Naveen Rawatd0ca4412017-06-16 14:19:19 -070018342 return csr_insert_stats_request_to_list(pMac, &staEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018343
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018344 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018345}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070018346#endif /* QCA_SUPPORT_CP_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018347
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018348#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070018349/**
18350 * csr_roam_set_key_mgmt_offload() - enable/disable key mgmt offload
18351 * @mac_ctx: mac context.
18352 * @session_id: Session Identifier
18353 * @roam_key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080018354 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070018355 *
18356 * Return: QDF_STATUS_SUCCESS - CSR updated config successfully.
18357 * Other status means CSR is failed to update.
18358 */
18359
18360QDF_STATUS csr_roam_set_key_mgmt_offload(tpAniSirGlobal mac_ctx,
18361 uint32_t session_id,
18362 bool roam_key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080018363 struct pmkid_mode_bits *pmkid_modes)
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018364{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018365 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018366
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070018367 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018368 sme_err("session %d not found", session_id);
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018369 return QDF_STATUS_E_FAILURE;
18370 }
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070018371 session->RoamKeyMgmtOffloadEnabled = roam_key_mgmt_offload_enabled;
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080018372 session->pmkid_modes.fw_okc = pmkid_modes->fw_okc;
18373 session->pmkid_modes.fw_pmksa_cache = pmkid_modes->fw_pmksa_cache;
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018374 return QDF_STATUS_SUCCESS;
18375}
18376
18377/**
18378 * csr_update_roam_scan_offload_request() - updates req msg with roam offload
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018379 * parameters
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018380 * @pMac: mac global context
18381 * @req_buf: out param, roam offload scan request packet
18382 * @session: roam session
18383 *
18384 * Return: void
18385 */
18386static void
18387csr_update_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
18388 tSirRoamOffloadScanReq *req_buf,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018389 struct csr_roam_session *session)
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018390{
18391 qdf_mem_copy(req_buf->PSK_PMK, session->psk_pmk,
18392 sizeof(req_buf->PSK_PMK));
18393 req_buf->pmk_len = session->pmk_len;
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018394 req_buf->R0KH_ID_Length = session->ftSmeContext.r0kh_id_len;
18395 qdf_mem_copy(req_buf->R0KH_ID,
18396 session->ftSmeContext.r0kh_id,
18397 req_buf->R0KH_ID_Length);
18398 req_buf->Prefer5GHz = mac_ctx->roam.configParam.nRoamPrefer5GHz;
18399 req_buf->RoamRssiCatGap = mac_ctx->roam.configParam.bCatRssiOffset;
18400 req_buf->Select5GHzMargin = mac_ctx->roam.configParam.nSelect5GHzMargin;
Abhinav Kumara083f212018-04-05 18:49:45 +053018401 req_buf->ho_delay_for_rx = mac_ctx->roam.configParam.ho_delay_for_rx;
Abhinav Kumara95af7c2018-04-06 17:08:00 +053018402 req_buf->min_delay_btw_roam_scans =
18403 mac_ctx->roam.configParam.min_delay_btw_roam_scans;
18404 req_buf->roam_trigger_reason_bitmask =
18405 mac_ctx->roam.configParam.roam_trigger_reason_bitmask;
Abhinav Kumaredd1d372018-05-11 15:33:35 +053018406 req_buf->roam_force_rssi_trigger =
18407 mac_ctx->roam.configParam.roam_force_rssi_trigger;
18408
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018409 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
18410 (uint32_t *) &req_buf->ReassocFailureTimeout)
Jeff Johnsonc09caa42018-06-07 22:58:55 -070018411 != QDF_STATUS_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018412 sme_err(
18413 "could not retrieve ReassocFailureTimeout value");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018414 req_buf->ReassocFailureTimeout =
18415 DEFAULT_REASSOC_FAILURE_TIMEOUT;
18416 }
18417#ifdef FEATURE_WLAN_ESE
18418 if (csr_is_auth_type_ese(req_buf->ConnectedNetwork.authentication)) {
18419 qdf_mem_copy(req_buf->KRK, session->eseCckmInfo.krk,
18420 SIR_KRK_KEY_LEN);
18421 qdf_mem_copy(req_buf->BTK, session->eseCckmInfo.btk,
18422 SIR_BTK_KEY_LEN);
18423 }
18424#endif
Naveen Rawatcd118312016-11-22 10:46:21 -080018425 req_buf->AcUapsd.acbe_uapsd = SIR_UAPSD_GET(ACBE, session->uapsd_mask);
18426 req_buf->AcUapsd.acbk_uapsd = SIR_UAPSD_GET(ACBK, session->uapsd_mask);
18427 req_buf->AcUapsd.acvi_uapsd = SIR_UAPSD_GET(ACVI, session->uapsd_mask);
18428 req_buf->AcUapsd.acvo_uapsd = SIR_UAPSD_GET(ACVO, session->uapsd_mask);
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018429}
18430#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
18431
18432#if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018433/**
18434 * csr_check_band_channel_match() - check if passed band and channel match
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018435 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018436 * @band: band to match with channel
18437 * @channel: channel to match with band
18438 *
18439 * Return: bool if match else false
18440 */
18441static bool
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018442csr_check_band_channel_match(enum band_info band, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018443{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018444 if (BAND_ALL == band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018445 return true;
18446
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018447 if (BAND_2G == band && WLAN_REG_IS_24GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018448 return true;
18449
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018450 if (BAND_5G == band && WLAN_REG_IS_5GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018451 return true;
18452
18453 return false;
18454}
18455
18456/**
18457 * csr_fetch_ch_lst_from_ini() - fetch channel list from ini and update req msg
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018458 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018459 * @mac_ctx: global mac ctx
18460 * @roam_info: roam info struct
18461 * @req_buf: out param, roam offload scan request packet
18462 *
18463 * Return: result of operation
18464 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018465static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018466csr_fetch_ch_lst_from_ini(tpAniSirGlobal mac_ctx,
18467 tpCsrNeighborRoamControlInfo roam_info,
18468 tSirRoamOffloadScanReq *req_buf)
18469{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018470 enum band_info band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018471 uint8_t i = 0;
18472 uint8_t num_channels = 0;
18473 uint8_t *ch_lst = roam_info->cfgParams.channelInfo.ChannelList;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018474 uint16_t unsafe_chan[NUM_CHANNELS];
18475 uint16_t unsafe_chan_cnt = 0;
18476 uint16_t cnt = 0;
18477 bool is_unsafe_chan;
18478 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
18479
18480 if (!qdf_ctx) {
18481 cds_err("qdf_ctx is NULL");
18482 return QDF_STATUS_E_FAILURE;
18483 }
18484
18485 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
18486 &unsafe_chan_cnt,
18487 sizeof(unsafe_chan));
18488
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018489 /*
18490 * The INI channels need to be filtered with respect to the current band
18491 * that is supported.
18492 */
18493 band = mac_ctx->roam.configParam.bandCapability;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018494 if ((BAND_2G != band) && (BAND_5G != band)
18495 && (BAND_ALL != band)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018496 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018497 "Invalid band(%d), roam scan offload req aborted",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018498 band);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018499 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018500 }
18501
18502 for (i = 0; i < roam_info->cfgParams.channelInfo.numOfChannels; i++) {
18503 if (!csr_check_band_channel_match(band, *ch_lst))
18504 continue;
18505 /* Allow DFS channels only if the DFS roaming is enabled */
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018506 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
18507 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
18508 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070018509 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018510 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18511 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018512 ch_lst++;
18513 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018514 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018515
18516 if (mac_ctx->roam.configParam.sta_roam_policy.
18517 skip_unsafe_channels &&
18518 unsafe_chan_cnt) {
18519 is_unsafe_chan = false;
18520 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
18521 if (unsafe_chan[cnt] == *ch_lst) {
18522 is_unsafe_chan = true;
18523 break;
18524 }
18525 }
18526 if (is_unsafe_chan) {
18527 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018528 QDF_TRACE_LEVEL_DEBUG,
18529 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018530 *ch_lst);
18531 ch_lst++;
18532 continue;
18533 }
18534 }
18535 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
18536 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018537 ch_lst++;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018539 }
18540 req_buf->ConnectedNetwork.ChannelCount = num_channels;
18541 req_buf->ChannelCacheType = CHANNEL_LIST_STATIC;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018542 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018543}
18544
18545/**
18546 * csr_fetch_ch_lst_from_occupied_lst() - fetch channel list from occupied list
18547 * and update req msg
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018548 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018549 * @mac_ctx: global mac ctx
18550 * @session_id: session id
18551 * @reason: reason to roam
18552 * @req_buf: out param, roam offload scan request packet
18553 * @roam_info: roam info struct
18554 *
18555 * Return: void
18556 */
18557static void
18558csr_fetch_ch_lst_from_occupied_lst(tpAniSirGlobal mac_ctx,
18559 uint8_t session_id,
18560 uint8_t reason,
18561 tSirRoamOffloadScanReq *req_buf,
18562 tpCsrNeighborRoamControlInfo roam_info)
18563{
18564 uint8_t i = 0;
18565 uint8_t num_channels = 0;
18566 uint8_t *ch_lst =
18567 mac_ctx->scan.occupiedChannels[session_id].channelList;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018568 uint16_t unsafe_chan[NUM_CHANNELS];
18569 uint16_t unsafe_chan_cnt = 0;
18570 uint16_t cnt = 0;
18571 bool is_unsafe_chan;
18572 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
18573
18574 if (!qdf_ctx) {
18575 cds_err("qdf_ctx is NULL");
18576 return;
18577 }
18578
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018579 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018580 "Num of channels before filtering=%d",
18581 mac_ctx->scan.occupiedChannels[session_id].numChannels);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018582 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
18583 &unsafe_chan_cnt,
18584 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018585 for (i = 0; i < mac_ctx->scan.occupiedChannels[session_id].numChannels;
18586 i++) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018587 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
18588 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
18589 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070018590 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018591 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18592 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018593 ch_lst++;
18594 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018595 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018596
18597 if (mac_ctx->roam.configParam.sta_roam_policy.
18598 skip_unsafe_channels &&
18599 unsafe_chan_cnt) {
18600 is_unsafe_chan = false;
18601 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
18602 if (unsafe_chan[cnt] == *ch_lst) {
18603 is_unsafe_chan = true;
18604 break;
18605 }
18606 }
18607 if (is_unsafe_chan) {
18608 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018609 QDF_TRACE_LEVEL_DEBUG,
18610 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018611 *ch_lst);
18612 ch_lst++;
18613 continue;
18614 }
18615 }
18616 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
18617 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018618 if (*ch_lst)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018619 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018620 "DFSRoam=%d, ChnlState=%d, Chnl=%d, num_ch=%d",
18621 mac_ctx->roam.configParam.allowDFSChannelRoam,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070018622 wlan_reg_get_channel_state(mac_ctx->pdev,
18623 *ch_lst),
18624 *ch_lst,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018625 num_channels);
18626 ch_lst++;
18627 }
18628 req_buf->ConnectedNetwork.ChannelCount = num_channels;
Himanshu Agarwalb23aa572018-06-14 17:04:44 +053018629 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018630}
18631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018632/**
18633 * csr_fetch_valid_ch_lst() - fetch channel list from valid channel list and
18634 * update req msg
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018635 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018636 * @mac_ctx: global mac ctx
18637 * @req_buf: out param, roam offload scan request packet
18638 *
18639 * Return: void
18640 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018641static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018642csr_fetch_valid_ch_lst(tpAniSirGlobal mac_ctx,
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018643 tSirRoamOffloadScanReq *req_buf,
18644 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018645{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018646 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018647 uint32_t host_channels = 0;
18648 uint8_t *ch_lst = NULL;
18649 uint8_t i = 0, num_channels = 0;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018650 uint16_t unsafe_chan[NUM_CHANNELS];
18651 uint16_t unsafe_chan_cnt = 0;
18652 uint16_t cnt = 0;
18653 bool is_unsafe_chan;
18654 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018655 enum band_info band = BAND_ALL;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018656
18657 if (!qdf_ctx) {
18658 cds_err("qdf_ctx is NULL");
18659 return QDF_STATUS_E_FAILURE;
18660 }
18661
18662 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
18663 &unsafe_chan_cnt,
18664 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018665
18666 host_channels = sizeof(mac_ctx->roam.validChannelList);
18667 status = csr_get_cfg_valid_channels(mac_ctx,
18668 mac_ctx->roam.validChannelList,
18669 &host_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018670 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018671 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018672 "Failed to get the valid channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018673 return status;
18674 }
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018675
18676 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(mac_ctx)) {
18677 band = csr_get_rf_band(mac_ctx->roam.roamSession[session_id].
18678 connectedProfile.operationChannel);
18679 sme_debug("updated band %d operational ch %d", band,
18680 mac_ctx->roam.roamSession[session_id].
18681 connectedProfile.operationChannel);
18682 }
18683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018684 ch_lst = mac_ctx->roam.validChannelList;
18685 mac_ctx->roam.numValidChannels = host_channels;
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018687 for (i = 0; i < mac_ctx->roam.numValidChannels; i++) {
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018688 if (!csr_check_band_channel_match(band, *ch_lst)) {
18689 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18690 ("ignoring non-intra band channel %d"),
18691 *ch_lst);
18692 ch_lst++;
18693 continue;
18694 }
18695
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018696 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
18697 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
18698 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070018699 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018700 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18701 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018702 ch_lst++;
18703 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018704 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018705
18706 if (mac_ctx->roam.configParam.
18707 sta_roam_policy.skip_unsafe_channels &&
18708 unsafe_chan_cnt) {
18709 is_unsafe_chan = false;
18710 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
18711 if (unsafe_chan[cnt] == *ch_lst) {
18712 is_unsafe_chan = true;
18713 break;
18714 }
18715 }
18716 if (is_unsafe_chan) {
18717 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018718 QDF_TRACE_LEVEL_DEBUG,
18719 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018720 *ch_lst);
18721 ch_lst++;
18722 continue;
18723 }
18724 }
18725 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
18726 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018727 ch_lst++;
18728 }
18729 req_buf->ValidChannelCount = num_channels;
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018730
Himanshu Agarwalb23aa572018-06-14 17:04:44 +053018731 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC;
Abhinav Kumaredd1d372018-05-11 15:33:35 +053018732 req_buf->ConnectedNetwork.ChannelCount = num_channels;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018733 return status;
18734}
18735
18736/**
18737 * csr_create_roam_scan_offload_request() - init roam offload scan request
18738 *
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018739 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018740 * @mac_ctx: global mac ctx
18741 * @command: roam scan offload command input
18742 * @session_id: session id
18743 * @reason: reason to roam
18744 * @session: roam session
18745 * @roam_info: roam info struct
18746 *
18747 * Return: roam offload scan request packet buffer
18748 */
18749static tSirRoamOffloadScanReq *
18750csr_create_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
18751 uint8_t command,
18752 uint8_t session_id,
18753 uint8_t reason,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018754 struct csr_roam_session *session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018755 tpCsrNeighborRoamControlInfo roam_info)
18756{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018757 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018758 uint8_t i, j, dot11_mode;
18759 bool ese_neighbor_list_recvd = false;
18760 uint8_t ch_cache_str[128] = { 0 };
18761 tSirRoamOffloadScanReq *req_buf = NULL;
18762 tpCsrChannelInfo curr_ch_lst_info =
18763 &roam_info->roamChannelInfo.currentChannelListInfo;
18764#ifdef FEATURE_WLAN_ESE
18765 /*
18766 * this flag will be true if connection is ESE and no neighbor
18767 * list received or if the connection is not ESE
18768 */
18769 ese_neighbor_list_recvd = ((roam_info->isESEAssoc)
18770 && (roam_info->roamChannelInfo.IAPPNeighborListReceived
18771 == false))
18772 || (roam_info->isESEAssoc == false);
18773#endif /* FEATURE_WLAN_ESE */
18774
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018775 req_buf = qdf_mem_malloc(sizeof(tSirRoamOffloadScanReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018776 if (NULL == req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018777 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018778 "Mem alloc for roam scan offload req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018779 return NULL;
18780 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018781 req_buf->Command = command;
18782 /*
18783 * If command is STOP, then pass down ScanOffloadEnabled as Zero. This
18784 * will handle the case of host driver reloads, but Riva still up and
18785 * running
18786 */
18787 if (command == ROAM_SCAN_OFFLOAD_STOP) {
18788 /*
18789 * clear the roaming parameters that are per connection.
18790 * For a new connection, they have to be programmed again.
18791 */
Jeff Johnson95f07052018-06-10 15:47:09 -070018792 if (csr_neighbor_middle_of_roaming(mac_ctx,
18793 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018794 req_buf->middle_of_roaming = 1;
18795 else
18796 csr_roam_reset_roam_params(mac_ctx);
18797 req_buf->RoamScanOffloadEnabled = 0;
18798 } else {
18799 req_buf->RoamScanOffloadEnabled =
18800 mac_ctx->roam.configParam.isRoamOffloadScanEnabled;
18801 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018802 qdf_mem_copy(req_buf->ConnectedNetwork.currAPbssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053018803 roam_info->currAPbssid.bytes, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018804 req_buf->ConnectedNetwork.ssId.length =
18805 mac_ctx->roam.roamSession[session_id].
18806 connectedProfile.SSID.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018807 qdf_mem_copy(req_buf->ConnectedNetwork.ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018808 mac_ctx->roam.roamSession[session_id].
18809 connectedProfile.SSID.ssId,
18810 req_buf->ConnectedNetwork.ssId.length);
18811 req_buf->ConnectedNetwork.authentication =
18812 mac_ctx->roam.roamSession[session_id].connectedProfile.AuthType;
18813 req_buf->ConnectedNetwork.encryption =
18814 mac_ctx->roam.roamSession[session_id].
18815 connectedProfile.EncryptionType;
18816 req_buf->ConnectedNetwork.mcencryption =
18817 mac_ctx->roam.roamSession[session_id].
18818 connectedProfile.mcEncryptionType;
gaurank kathpaliac63859d2018-05-03 18:48:41 +053018819 /* Copy the RSN capabilities in roam offload request from session*/
18820 req_buf->rsn_caps = session->rsn_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018821#ifdef WLAN_FEATURE_11W
18822 req_buf->ConnectedNetwork.mfp_enabled =
18823 mac_ctx->roam.roamSession[session_id].connectedProfile.MFPEnabled;
18824#endif
18825 req_buf->delay_before_vdev_stop =
18826 roam_info->cfgParams.delay_before_vdev_stop;
18827 req_buf->OpportunisticScanThresholdDiff =
18828 roam_info->cfgParams.nOpportunisticThresholdDiff;
18829 req_buf->RoamRescanRssiDiff =
18830 roam_info->cfgParams.nRoamRescanRssiDiff;
18831 req_buf->RoamRssiDiff = mac_ctx->roam.configParam.RoamRssiDiff;
Abhishek Singh34c0e632017-09-28 14:39:29 +053018832 req_buf->rssi_abs_thresh = mac_ctx->roam.configParam.rssi_abs_thresh;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018833 req_buf->reason = reason;
18834 req_buf->NeighborScanTimerPeriod =
18835 roam_info->cfgParams.neighborScanPeriod;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +053018836 req_buf->neighbor_scan_min_timer_period =
18837 roam_info->cfgParams.neighbor_scan_min_period;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018838 req_buf->NeighborRoamScanRefreshPeriod =
18839 roam_info->cfgParams.neighborResultsRefreshPeriod;
18840 req_buf->NeighborScanChannelMinTime =
18841 roam_info->cfgParams.minChannelScanTime;
18842 req_buf->NeighborScanChannelMaxTime =
18843 roam_info->cfgParams.maxChannelScanTime;
18844 req_buf->EmptyRefreshScanPeriod =
18845 roam_info->cfgParams.emptyScanRefreshPeriod;
18846 req_buf->RoamBmissFirstBcnt =
18847 roam_info->cfgParams.nRoamBmissFirstBcnt;
18848 req_buf->RoamBmissFinalBcnt =
18849 roam_info->cfgParams.nRoamBmissFinalBcnt;
18850 req_buf->RoamBeaconRssiWeight =
18851 roam_info->cfgParams.nRoamBeaconRssiWeight;
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -070018852 qdf_mem_copy(&req_buf->mawc_roam_params,
18853 &mac_ctx->roam.configParam.csr_mawc_config,
18854 sizeof(req_buf->mawc_roam_params));
18855 sme_debug("MAWC:global=%d,roam=%d,traffic=%d,ap_rssi=%d,high=%d,low=%d",
18856 req_buf->mawc_roam_params.mawc_enabled,
18857 req_buf->mawc_roam_params.mawc_roam_enabled,
18858 req_buf->mawc_roam_params.mawc_roam_traffic_threshold,
18859 req_buf->mawc_roam_params.mawc_roam_ap_rssi_threshold,
18860 req_buf->mawc_roam_params.mawc_roam_rssi_high_adjust,
18861 req_buf->mawc_roam_params.mawc_roam_rssi_low_adjust);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018862#ifdef FEATURE_WLAN_ESE
18863 req_buf->IsESEAssoc =
Srinivas Girigowda18dcf3d2015-12-16 18:11:48 -080018864 csr_roam_is_ese_assoc(mac_ctx, session_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018865 ((req_buf->ConnectedNetwork.authentication ==
18866 eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
18867 (csr_is_auth_type_ese(req_buf->
18868 ConnectedNetwork.authentication)));
Abhinav Kumar271f0632018-03-29 16:01:30 +053018869 req_buf->is_11r_assoc = roam_info->is11rAssoc;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018870 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Abhinav Kumar271f0632018-03-29 16:01:30 +053018871 "IsEseAssoc: %d is_11r_assoc: %d middle of roaming: %d ese_neighbor_list_recvd: %d cur no of chan: %d",
18872 req_buf->IsESEAssoc, req_buf->is_11r_assoc,
Selvaraj, Sridhar8fe6c672017-01-10 11:37:29 +053018873 req_buf->middle_of_roaming,
18874 ese_neighbor_list_recvd,
18875 curr_ch_lst_info->numOfChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018876#endif
Selvaraj, Sridhar38101832017-05-12 14:23:07 +053018877
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018878 if (!CSR_IS_ROAM_INTRA_BAND_ENABLED(mac_ctx)) {
18879 if (ese_neighbor_list_recvd ||
18880 curr_ch_lst_info->numOfChannels == 0) {
18881 /*
18882 * Retrieve the Channel Cache either from ini or from
18883 * the occupied channels list.
18884 * Give Preference to INI Channels
18885 */
18886 if (roam_info->cfgParams.channelInfo.numOfChannels) {
18887 status = csr_fetch_ch_lst_from_ini(mac_ctx,
18888 roam_info,
18889 req_buf);
18890 if (!QDF_IS_STATUS_SUCCESS(status)) {
18891 QDF_TRACE(QDF_MODULE_ID_SME,
18892 QDF_TRACE_LEVEL_DEBUG,
18893 "Fetch channel list from ini failed");
18894 qdf_mem_free(req_buf);
18895 return NULL;
18896 }
18897 } else {
18898 csr_fetch_ch_lst_from_occupied_lst(mac_ctx,
18899 session_id, reason, req_buf,
18900 roam_info);
18901 }
18902 }
18903#ifdef FEATURE_WLAN_ESE
18904 else {
18905 /*
18906 * If ESE is enabled, and a neighbor Report is received,
18907 * then Ignore the INI Channels or the Occupied Channel
18908 * List. Consider the channels in the neighbor list sent
18909 * by the ESE AP
18910 */
18911 csr_fetch_ch_lst_from_received_list(mac_ctx, roam_info,
18912 curr_ch_lst_info, req_buf);
18913 }
18914#endif
18915 }
Selvaraj, Sridhar38101832017-05-12 14:23:07 +053018916 if (req_buf->ConnectedNetwork.ChannelCount == 0) {
18917 /* Maintain the Valid Channels List */
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018918 status = csr_fetch_valid_ch_lst(mac_ctx, req_buf, session_id);
Selvaraj, Sridhar38101832017-05-12 14:23:07 +053018919 if (!QDF_IS_STATUS_SUCCESS(status)) {
18920 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
18921 "Fetch channel list fail");
18922 qdf_mem_free(req_buf);
18923 return NULL;
18924 }
18925 }
18926
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018927 for (i = 0, j = 0; i < req_buf->ConnectedNetwork.ChannelCount; i++) {
18928 if (j < sizeof(ch_cache_str)) {
18929 j += snprintf(ch_cache_str + j,
18930 sizeof(ch_cache_str) - j, " %d",
18931 req_buf->ConnectedNetwork.
18932 ChannelCache[i]);
18933 } else
18934 break;
18935 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018936 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018937 FL("ChnlCacheType:%d, No of Chnls:%d,Channels: %s"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018938 req_buf->ChannelCacheType,
18939 req_buf->ConnectedNetwork.ChannelCount, ch_cache_str);
18940
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018941 req_buf->MDID.mdiePresent =
18942 mac_ctx->roam.roamSession[session_id].
18943 connectedProfile.MDID.mdiePresent;
18944 req_buf->MDID.mobilityDomain =
18945 mac_ctx->roam.roamSession[session_id].
18946 connectedProfile.MDID.mobilityDomain;
18947 req_buf->sessionId = session_id;
18948 req_buf->nProbes = mac_ctx->roam.configParam.nProbes;
18949 req_buf->HomeAwayTime = mac_ctx->roam.configParam.nRoamScanHomeAwayTime;
18950
18951 /*
18952 * Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18953 * where RFS is the RF Switching time. It is twice RFS to consider the
18954 * time to go off channel and return to the home channel.
18955 */
18956 if (req_buf->HomeAwayTime < (req_buf->NeighborScanChannelMaxTime +
18957 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18959 "Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d). Hence enforcing home away time to disable (0)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018960 req_buf->HomeAwayTime,
18961 (req_buf->NeighborScanChannelMaxTime +
18962 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18963 req_buf->HomeAwayTime = 0;
18964 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018965
18966 /*Prepare a probe request for 2.4GHz band and one for 5GHz band */
18967 dot11_mode = (uint8_t) csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
18968 csr_find_best_phy_mode(mac_ctx,
18969 mac_ctx->roam.configParam.phyMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018970 req_buf->allowDFSChannelRoam =
18971 mac_ctx->roam.configParam.allowDFSChannelRoam;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -070018972 req_buf->early_stop_scan_enable =
18973 mac_ctx->roam.configParam.early_stop_scan_enable;
18974 req_buf->early_stop_scan_min_threshold =
18975 mac_ctx->roam.configParam.early_stop_scan_min_threshold;
18976 req_buf->early_stop_scan_max_threshold =
18977 mac_ctx->roam.configParam.early_stop_scan_max_threshold;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053018978 req_buf->roamscan_adaptive_dwell_mode =
18979 mac_ctx->roam.configParam.roamscan_adaptive_dwell_mode;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +053018980 req_buf->lca_config_params.disallow_duration =
18981 mac_ctx->roam.configParam.disallow_duration;
18982 req_buf->lca_config_params.rssi_channel_penalization =
18983 mac_ctx->roam.configParam.rssi_channel_penalization;
18984 req_buf->lca_config_params.num_disallowed_aps =
18985 mac_ctx->roam.configParam.num_disallowed_aps;
Vignesh Viswanathana3d5c272018-06-04 19:36:02 +053018986
18987 /* For RSO Stop, we need to notify FW to deinit BTM */
18988 if (command == ROAM_SCAN_OFFLOAD_STOP)
18989 req_buf->btm_offload_config = 0;
18990 else
18991 req_buf->btm_offload_config =
18992 mac_ctx->roam.configParam.btm_offload_config;
18993
Jiachao Wu84bb2ea2018-01-08 16:17:33 +080018994 req_buf->btm_solicited_timeout =
18995 mac_ctx->roam.configParam.btm_solicited_timeout;
18996 req_buf->btm_max_attempt_cnt =
18997 mac_ctx->roam.configParam.btm_max_attempt_cnt;
18998 req_buf->btm_sticky_time =
18999 mac_ctx->roam.configParam.btm_sticky_time;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +053019000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019001#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +053019002 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
19003 FL("HomeAwayTime=%d EarlyStopFeature Enable=%d, MinThresh=%d, MaxThresh=%d PMK len=%d disallow_dur=%d rssi_chan_pen=%d num_disallowed_aps=%d"),
19004 req_buf->HomeAwayTime,
19005 req_buf->early_stop_scan_enable,
19006 req_buf->early_stop_scan_min_threshold,
19007 req_buf->early_stop_scan_max_threshold,
19008 req_buf->pmk_len,
19009 req_buf->lca_config_params.disallow_duration,
19010 req_buf->lca_config_params.rssi_channel_penalization,
19011 req_buf->lca_config_params.num_disallowed_aps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019012 req_buf->RoamOffloadEnabled = csr_roamIsRoamOffloadEnabled(mac_ctx);
19013 req_buf->RoamKeyMgmtOffloadEnabled = session->RoamKeyMgmtOffloadEnabled;
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080019014 req_buf->pmkid_modes = session->pmkid_modes;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019015 /* Roam Offload piggybacks upon the Roam Scan offload command. */
19016 if (req_buf->RoamOffloadEnabled)
19017 csr_update_roam_scan_offload_request(mac_ctx, req_buf, session);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019018 qdf_mem_copy(&req_buf->roam_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019019 &mac_ctx->roam.configParam.roam_params,
19020 sizeof(req_buf->roam_params));
19021#endif
19022 return req_buf;
19023}
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053019024
19025/**
19026 * csr_update_11k_offload_params - Update 11K offload params
19027 * @mac_ctx: MAC context
19028 * @session: Pointer to the CSR Roam Session
19029 * @req_buffer: Pointer to the RSO Request buffer
Vignesh Viswanathane25af782018-03-23 14:49:50 +053019030 * @enabled: 11k offload enabled/disabled.
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053019031 *
19032 * API to update 11k offload params to Roam Scan Offload request buffer
19033 *
19034 * Return: none
19035 */
19036static void csr_update_11k_offload_params(tpAniSirGlobal mac_ctx,
19037 struct csr_roam_session *session,
Vignesh Viswanathane25af782018-03-23 14:49:50 +053019038 tSirRoamOffloadScanReq *req_buffer,
19039 bool enabled)
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053019040{
19041 struct wmi_11k_offload_params *params = &req_buffer->offload_11k_params;
19042 struct csr_config *csr_config = &mac_ctx->roam.configParam;
19043 struct csr_neighbor_report_offload_params *neighbor_report_offload =
19044 &csr_config->neighbor_report_offload;
19045
19046 params->vdev_id = session->sessionId;
Vignesh Viswanathane25af782018-03-23 14:49:50 +053019047
19048 if (enabled) {
19049 params->offload_11k_bitmask =
19050 csr_config->offload_11k_enable_bitmask;
19051 } else {
19052 params->offload_11k_bitmask = 0;
19053 sme_debug("11k offload disabled in RSO");
19054 return;
19055 }
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053019056
19057 /*
19058 * If none of the parameters are enabled, then set the
19059 * offload_11k_bitmask to 0, so that we don't send the command
19060 * to the FW and drop it in WMA
19061 */
19062 if ((neighbor_report_offload->params_bitmask &
19063 NEIGHBOR_REPORT_PARAMS_ALL) == 0) {
19064 sme_err("No valid neighbor report offload params %x",
19065 neighbor_report_offload->params_bitmask);
19066 params->offload_11k_bitmask = 0;
Vignesh Viswanathane25af782018-03-23 14:49:50 +053019067 return;
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053019068 }
19069
19070 /*
19071 * First initialize all params to NEIGHBOR_REPORT_PARAM_INVALID
19072 * Then set the values that are enabled
19073 */
19074 params->neighbor_report_params.time_offset =
19075 NEIGHBOR_REPORT_PARAM_INVALID;
19076 params->neighbor_report_params.low_rssi_offset =
19077 NEIGHBOR_REPORT_PARAM_INVALID;
19078 params->neighbor_report_params.bmiss_count_trigger =
19079 NEIGHBOR_REPORT_PARAM_INVALID;
19080 params->neighbor_report_params.per_threshold_offset =
19081 NEIGHBOR_REPORT_PARAM_INVALID;
19082 params->neighbor_report_params.neighbor_report_cache_timeout =
19083 NEIGHBOR_REPORT_PARAM_INVALID;
19084 params->neighbor_report_params.max_neighbor_report_req_cap =
19085 NEIGHBOR_REPORT_PARAM_INVALID;
19086
19087 if (neighbor_report_offload->params_bitmask &
19088 NEIGHBOR_REPORT_PARAMS_TIME_OFFSET)
19089 params->neighbor_report_params.time_offset =
19090 neighbor_report_offload->time_offset;
19091
19092 if (neighbor_report_offload->params_bitmask &
19093 NEIGHBOR_REPORT_PARAMS_LOW_RSSI_OFFSET)
19094 params->neighbor_report_params.low_rssi_offset =
19095 neighbor_report_offload->low_rssi_offset;
19096
19097 if (neighbor_report_offload->params_bitmask &
19098 NEIGHBOR_REPORT_PARAMS_BMISS_COUNT_TRIGGER)
19099 params->neighbor_report_params.bmiss_count_trigger =
19100 neighbor_report_offload->bmiss_count_trigger;
19101
19102 if (neighbor_report_offload->params_bitmask &
19103 NEIGHBOR_REPORT_PARAMS_PER_THRESHOLD_OFFSET)
19104 params->neighbor_report_params.per_threshold_offset =
19105 neighbor_report_offload->per_threshold_offset;
19106
19107 if (neighbor_report_offload->params_bitmask &
19108 NEIGHBOR_REPORT_PARAMS_CACHE_TIMEOUT)
19109 params->neighbor_report_params.neighbor_report_cache_timeout =
19110 neighbor_report_offload->neighbor_report_cache_timeout;
19111
19112 if (neighbor_report_offload->params_bitmask &
19113 NEIGHBOR_REPORT_PARAMS_MAX_REQ_CAP)
19114 params->neighbor_report_params.max_neighbor_report_req_cap =
19115 neighbor_report_offload->max_neighbor_report_req_cap;
19116
19117 params->neighbor_report_params.ssid.length =
19118 session->connectedProfile.SSID.length;
19119 qdf_mem_copy(params->neighbor_report_params.ssid.mac_ssid,
19120 session->connectedProfile.SSID.ssId,
19121 session->connectedProfile.SSID.length);
19122
19123 sme_debug("Updated 11k offload params to RSO");
19124}
19125
19126QDF_STATUS csr_invoke_neighbor_report_request(uint8_t session_id,
19127 struct sRrmNeighborReq *neighbor_report_req,
19128 bool send_resp_to_host)
19129{
19130 struct wmi_invoke_neighbor_report_params *invoke_params;
19131 struct scheduler_msg msg = {0};
19132
19133 if (!neighbor_report_req) {
19134 sme_err("Invalid params");
19135 return QDF_STATUS_E_INVAL;
19136 }
19137
19138 invoke_params = qdf_mem_malloc(sizeof(*invoke_params));
19139 if (!invoke_params) {
19140 sme_err("Memory allocation failure");
19141 return QDF_STATUS_E_NOMEM;
19142 }
19143
19144 invoke_params->vdev_id = session_id;
19145 invoke_params->send_resp_to_host = send_resp_to_host;
19146
19147 if (!neighbor_report_req->no_ssid) {
19148 invoke_params->ssid.length = neighbor_report_req->ssid.length;
19149 qdf_mem_copy(invoke_params->ssid.mac_ssid,
19150 neighbor_report_req->ssid.ssId,
19151 neighbor_report_req->ssid.length);
19152 } else {
19153 invoke_params->ssid.length = 0;
19154 }
19155
19156 sme_debug("Sending SIR_HAL_INVOKE_NEIGHBOR_REPORT");
19157
19158 msg.type = SIR_HAL_INVOKE_NEIGHBOR_REPORT;
19159 msg.reserved = 0;
19160 msg.bodyptr = invoke_params;
19161
19162 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
19163 sme_err("Not able to post message to WMA");
19164 qdf_mem_free(invoke_params);
19165 return QDF_STATUS_E_FAILURE;
19166 }
19167
19168 return QDF_STATUS_SUCCESS;
19169}
19170
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019171/**
19172 * check_allowed_ssid_list() - Check the WhiteList
19173 * @req_buffer: Buffer which contains the connected profile SSID.
19174 * @roam_params: Buffer which contains the whitelist SSID's.
19175 *
19176 * Check if the connected profile SSID exists in the whitelist.
19177 * It is assumed that the framework provides this also in the whitelist.
19178 * If it exists there is no issue. Otherwise add it to the list.
19179 *
19180 * Return: None
19181 */
19182static void check_allowed_ssid_list(tSirRoamOffloadScanReq *req_buffer,
19183 struct roam_ext_params *roam_params)
19184{
19185 int i = 0;
19186 bool match = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019187
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019188 for (i = 0; i < roam_params->num_ssid_allowed_list; i++) {
19189 if ((roam_params->ssid_allowed_list[i].length ==
19190 req_buffer->ConnectedNetwork.ssId.length) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019191 (!qdf_mem_cmp(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019192 req_buffer->ConnectedNetwork.ssId.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019193 roam_params->ssid_allowed_list[i].length))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019194 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019195 "Whitelist contains connected profile SSID");
19196 match = true;
19197 break;
19198 }
19199 }
19200 if (!match) {
19201 if (roam_params->num_ssid_allowed_list >=
19202 MAX_SSID_ALLOWED_LIST) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019203 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019204 "Whitelist is FULL. Cannot Add another entry");
19205 return;
19206 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019207 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019208 "Adding Connected profile SSID to whitelist");
19209 /* i is the next available index to add the entry.*/
19210 i = roam_params->num_ssid_allowed_list;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019211 qdf_mem_copy(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019212 req_buffer->ConnectedNetwork.ssId.ssId,
19213 req_buffer->ConnectedNetwork.ssId.length);
19214 roam_params->ssid_allowed_list[i].length =
19215 req_buffer->ConnectedNetwork.ssId.length;
19216 roam_params->num_ssid_allowed_list++;
19217 }
19218}
19219
Abhishek Singh4db8c152017-07-18 10:40:08 +053019220/**
19221 * csr_add_rssi_reject_ap_list() - add rssi reject AP list to the
19222 * roam params
19223 * @mac_ctx: mac ctx.
19224 * @roam_params: roam params in which reject AP list needs
19225 * to be populated.
19226 *
19227 * Return: None
19228 */
19229static void csr_add_rssi_reject_ap_list(tpAniSirGlobal mac_ctx,
19230 struct roam_ext_params *roam_params)
19231{
19232 int i = 0;
19233 struct sir_rssi_disallow_lst *cur_node;
19234 qdf_list_node_t *cur_list = NULL;
19235 qdf_list_node_t *next_list = NULL;
19236 struct rssi_disallow_bssid *rssi_rejection_ap;
19237 qdf_list_t *list = &mac_ctx->roam.rssi_disallow_bssid;
19238 qdf_time_t cur_time =
19239 qdf_do_div(qdf_get_monotonic_boottime(),
19240 QDF_MC_TIMER_TO_MS_UNIT);
19241
19242 roam_params->num_rssi_rejection_ap = qdf_list_size(list);
19243
19244 if (!qdf_list_size(list))
19245 return;
19246
19247 if (roam_params->num_rssi_rejection_ap > MAX_RSSI_AVOID_BSSID_LIST)
19248 roam_params->num_rssi_rejection_ap = MAX_RSSI_AVOID_BSSID_LIST;
19249
19250 qdf_list_peek_front(list, &cur_list);
19251 while (cur_list) {
19252 int32_t rem_time;
19253
19254 rssi_rejection_ap = &roam_params->rssi_rejection_ap[i];
19255 cur_node = qdf_container_of(cur_list,
19256 struct sir_rssi_disallow_lst, node);
19257 rem_time = cur_node->retry_delay -
19258 (cur_time - cur_node->time_during_rejection);
19259
19260 if (rem_time > 0) {
19261 qdf_copy_macaddr(&rssi_rejection_ap->bssid,
19262 &cur_node->bssid);
19263 rssi_rejection_ap->expected_rssi =
19264 cur_node->expected_rssi;
19265 rssi_rejection_ap->remaining_duration = rem_time;
19266 i++;
19267 }
19268 qdf_list_peek_next(list, cur_list, &next_list);
19269 cur_list = next_list;
19270 next_list = NULL;
19271
19272 if (i >= MAX_RSSI_AVOID_BSSID_LIST)
19273 break;
19274 }
19275 for (i = 0; i < roam_params->num_rssi_rejection_ap; i++) {
19276 sme_debug("BSSID %pM expected rssi %d remaining duration %d",
19277 roam_params->rssi_rejection_ap[i].bssid.bytes,
19278 roam_params->rssi_rejection_ap[i].expected_rssi,
19279 roam_params->rssi_rejection_ap[i].remaining_duration);
19280 }
19281}
19282
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019283/*
19284 * Below Table describe whether RSO command can be send down to fimrware or not.
19285 * Host check it on the basis of previous RSO command sent down to firmware.
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070019286 * ||=========================================================================||
19287 * || New cmd | LAST SENT COMMAND ---> ||
19288 * ||====|====================================================================||
19289 * || V | START | STOP | RESTART | UPDATE_CFG| ABORT_SCAN ||
19290 * || ------------------------------------------------------------------------||
19291 * || RSO_START | NO | YES | NO | YES | NO ||
19292 * || RSO_STOP | YES | YES | YES | YES | YES ||
19293 * || RSO_RESTART | YES | YES | NO | YES | YES ||
19294 * || RSO_UPDATE_CFG | YES | NO | YES | YES | YES ||
19295 * || RSO_ABORT_SCAN | YES | NO | YES | YES | YES ||
19296 * ||=========================================================================||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019297 **/
19298#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
19299#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
19300#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
19301#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080019302#define RSO_ABORT_SCAN_BIT (1<<ROAM_SCAN_OFFLOAD_ABORT_SCAN)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070019303#define RSO_START_ALLOW_MASK (RSO_STOP_BIT | RSO_UPDATE_CFG_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019304#define RSO_STOP_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080019305 RSO_STOP_BIT | RSO_START_BIT | RSO_ABORT_SCAN_BIT)
19306#define RSO_RESTART_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
19307 RSO_ABORT_SCAN_BIT | RSO_RESTART_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019308#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_STOP_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080019309 RSO_START_BIT | RSO_ABORT_SCAN_BIT)
19310#define RSO_ABORT_SCAN_ALLOW_MASK (RSO_START_BIT | RSO_RESTART_BIT | \
19311 RSO_UPDATE_CFG_BIT | RSO_ABORT_SCAN_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019312
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019313static bool csr_is_RSO_cmd_allowed(tpAniSirGlobal mac_ctx,
19314 uint8_t command, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019315{
19316 tpCsrNeighborRoamControlInfo neigh_roam_info =
19317 &mac_ctx->roam.neighborRoamInfo[session_id];
19318 uint8_t desiredMask = 0;
19319 bool ret_val;
19320
19321 switch (command) {
19322 case ROAM_SCAN_OFFLOAD_START:
19323 desiredMask = RSO_START_ALLOW_MASK;
19324 break;
19325 case ROAM_SCAN_OFFLOAD_STOP:
19326 desiredMask = RSO_STOP_ALLOW_MASK;
19327 break;
19328 case ROAM_SCAN_OFFLOAD_RESTART:
19329 desiredMask = RSO_RESTART_ALLOW_MASK;
19330 break;
19331 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
19332 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
19333 break;
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080019334 case ROAM_SCAN_OFFLOAD_ABORT_SCAN:
19335 desiredMask = RSO_ABORT_SCAN_ALLOW_MASK;
19336 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019337 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019338 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019339 ("Wrong RSO command %d, not allowed"), command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019340 return 0;/*Cmd Not allowed*/
19341 }
19342 ret_val = desiredMask & (1 << neigh_roam_info->last_sent_cmd);
19343 return ret_val;
19344}
19345
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053019346/*
19347 * csr_roam_send_rso_cmd() - API to send RSO command to PE
19348 * @mac_ctx: Pointer to global MAC structure
19349 * @session_id: Session ID
19350 * @request_buf: Pointer to tSirRoamOffloadScanReq
19351 *
19352 * Return: QDF_STATUS
19353 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -070019354static QDF_STATUS csr_roam_send_rso_cmd(tpAniSirGlobal mac_ctx,
19355 uint8_t session_id,
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053019356 tSirRoamOffloadScanReq *request_buf)
19357{
19358 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019359
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053019360 request_buf->message_type = eWNI_SME_ROAM_SCAN_OFFLOAD_REQ;
19361 request_buf->length = sizeof(*request_buf);
19362
Rajeev Kumard138ac52017-01-30 18:38:37 -080019363 status = umac_send_mb_message_to_mac(request_buf);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053019364 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019365 sme_err("Send RSO from CSR failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053019366 return status;
19367 }
19368 return QDF_STATUS_SUCCESS;
19369}
19370
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019371/**
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019372 * csr_append_assoc_ies() - Append specific IE to assoc IE's buffer
19373 * @mac_ctx: Pointer to global mac context
19374 * @req_buf: Pointer to Roam offload scan request
19375 * @ie_id: IE ID to be appended
19376 * @ie_len: IE length to be appended
19377 * @ie_data: IE data to be appended
19378 *
19379 * Return: None
19380 */
19381static void csr_append_assoc_ies(tpAniSirGlobal mac_ctx,
19382 tSirRoamOffloadScanReq *req_buf, uint8_t ie_id,
19383 uint8_t ie_len, uint8_t *ie_data)
19384{
19385 tSirAddie *assoc_ie = &req_buf->assoc_ie;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019386
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019387 if ((SIR_MAC_MAX_ADD_IE_LENGTH - assoc_ie->length) < ie_len) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019388 sme_err("Appending IE id: %d fails", ie_id);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019389 return;
19390 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019391 assoc_ie->addIEdata[assoc_ie->length] = ie_id;
19392 assoc_ie->addIEdata[assoc_ie->length + 1] = ie_len;
19393 qdf_mem_copy(&assoc_ie->addIEdata[assoc_ie->length + 2],
19394 ie_data, ie_len);
19395 assoc_ie->length += (ie_len + 2);
19396}
19397
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053019398#ifdef FEATURE_WLAN_ESE
19399/**
19400 * ese_populate_addtional_ies() - add IEs to reassoc frame
19401 * @mac_ctx: Pointer to global mac structure
19402 * @session: pointer to CSR session
19403 * @req_buf: Pointer to Roam offload scan request
19404 *
19405 * This function populates the TSPEC ie and appends the info
19406 * to assoc buffer.
19407 *
19408 * Return: None
19409 */
19410static void ese_populate_addtional_ies(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019411 struct csr_roam_session *session,
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053019412 tSirRoamOffloadScanReq *req_buf) {
19413
19414 uint8_t tspec_ie_hdr[SIR_MAC_OUI_WME_HDR_MIN]
19415 = { 0x00, 0x50, 0xf2, 0x02, 0x02, 0x01 };
19416 uint8_t tspec_ie_buf[DOT11F_IE_WMMTSPEC_MAX_LEN], j;
19417 ese_wmm_tspec_ie *tspec_ie;
19418 tESETspecInfo ese_tspec;
19419
19420 tspec_ie = (ese_wmm_tspec_ie *)(tspec_ie_buf + SIR_MAC_OUI_WME_HDR_MIN);
19421 if (csr_is_wmm_supported(mac_ctx) &&
19422 mac_ctx->roam.configParam.isEseIniFeatureEnabled &&
19423 csr_roam_is_ese_assoc(mac_ctx, session->sessionId)) {
19424 ese_tspec.numTspecs = sme_qos_ese_retrieve_tspec_info(mac_ctx,
19425 session->sessionId,
19426 (tTspecInfo *) &ese_tspec.tspec[0]);
19427 qdf_mem_copy(tspec_ie_buf, tspec_ie_hdr,
19428 SIR_MAC_OUI_WME_HDR_MIN);
19429 for (j = 0; j < ese_tspec.numTspecs; j++) {
19430 /* Populate the tspec_ie */
19431 ese_populate_wmm_tspec(&ese_tspec.tspec[j].tspec,
19432 tspec_ie);
19433 csr_append_assoc_ies(mac_ctx, req_buf,
19434 IEEE80211_ELEMID_VENDOR,
19435 DOT11F_IE_WMMTSPEC_MAX_LEN,
19436 tspec_ie_buf);
19437 }
19438 }
19439
19440}
19441#else
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019442static inline void ese_populate_addtional_ies(
19443 tpAniSirGlobal mac_ctx,
19444 struct csr_roam_session *session, tSirRoamOffloadScanReq *req_buf) {
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053019445}
19446#endif
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019447/**
19448 * csr_update_driver_assoc_ies() - Append driver built IE's to assoc IE's
19449 * @mac_ctx: Pointer to global mac structure
19450 * @session: pointer to CSR session
19451 * @req_buf: Pointer to Roam offload scan request
19452 *
19453 * Return: None
19454 */
19455static void csr_update_driver_assoc_ies(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019456 struct csr_roam_session *session,
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019457 tSirRoamOffloadScanReq *req_buf)
19458{
19459 bool power_caps_populated = false;
19460 uint32_t csr_11henable = WNI_CFG_11H_ENABLED_STADEF;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019461
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019462 uint8_t *rrm_cap_ie_data
19463 = (uint8_t *) &mac_ctx->rrm.rrmPEContext.rrmEnabledCaps;
19464 uint8_t power_cap_ie_data[DOT11F_IE_POWERCAPS_MAX_LEN]
19465 = {MIN_TX_PWR_CAP, MAX_TX_PWR_CAP};
Naveen Rawat224ae9c2016-10-24 15:36:56 -070019466 uint8_t max_tx_pwr_cap = 0;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019467 uint8_t supp_chan_ie[DOT11F_IE_SUPPCHANNELS_MAX_LEN], supp_chan_ie_len;
Yu Wang0477ee32017-02-10 20:02:03 +080019468
19469#ifdef FEATURE_WLAN_ESE
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019470 uint8_t ese_ie[DOT11F_IE_ESEVERSION_MAX_LEN]
19471 = { 0x0, 0x40, 0x96, 0x3, ESE_VERSION_SUPPORTED};
Yu Wang0477ee32017-02-10 20:02:03 +080019472#endif
Selvaraj, Sridharced57062017-01-30 15:19:07 +053019473 uint8_t qcn_ie[DOT11F_IE_QCN_IE_MAX_LEN]
19474 = {0x8C, 0xFD, 0xF0, 0x1, QCN_IE_VERSION_SUBATTR_ID,
19475 QCN_IE_VERSION_SUBATTR_DATA_LEN,
19476 QCN_IE_VERSION_SUPPORTED,
19477 QCN_IE_SUBVERSION_SUPPORTED};
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019478
Naveen Rawat224ae9c2016-10-24 15:36:56 -070019479 if (session->pConnectBssDesc)
19480 max_tx_pwr_cap = csr_get_cfg_max_tx_power(mac_ctx,
19481 session->pConnectBssDesc->channelId);
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053019482
19483 if (max_tx_pwr_cap && max_tx_pwr_cap < MAX_TX_PWR_CAP)
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019484 power_cap_ie_data[1] = max_tx_pwr_cap;
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053019485 else
19486 power_cap_ie_data[1] = MAX_TX_PWR_CAP;
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019487
19488 wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &csr_11henable);
19489
19490 if (csr_11henable && csr_is11h_supported(mac_ctx)) {
19491 /* Append power cap IE */
19492 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_PWRCAP,
19493 DOT11F_IE_POWERCAPS_MAX_LEN,
19494 power_cap_ie_data);
19495 power_caps_populated = true;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019496
19497 /* Append Supported channels IE */
19498 csr_add_supported_5Ghz_channels(mac_ctx, supp_chan_ie,
19499 &supp_chan_ie_len, true);
19500
19501 csr_append_assoc_ies(mac_ctx, req_buf,
19502 IEEE80211_ELEMID_SUPPCHAN,
19503 supp_chan_ie_len, supp_chan_ie);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019504 }
19505
Yu Wang0477ee32017-02-10 20:02:03 +080019506#ifdef FEATURE_WLAN_ESE
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019507 /* Append ESE version IE if isEseIniFeatureEnabled INI is enabled */
19508 if (mac_ctx->roam.configParam.isEseIniFeatureEnabled)
19509 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_VENDOR,
19510 DOT11F_IE_ESEVERSION_MAX_LEN,
19511 ese_ie);
Yu Wang0477ee32017-02-10 20:02:03 +080019512#endif
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019513
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019514 if (mac_ctx->rrm.rrmPEContext.rrmEnable) {
19515 /* Append RRM IE */
19516 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_RRM,
19517 DOT11F_IE_RRMENABLEDCAP_MAX_LEN,
19518 rrm_cap_ie_data);
19519 if (!power_caps_populated)
19520 /* Append Power cap IE if not appended already */
19521 csr_append_assoc_ies(mac_ctx, req_buf,
19522 IEEE80211_ELEMID_PWRCAP,
19523 DOT11F_IE_POWERCAPS_MAX_LEN,
19524 power_cap_ie_data);
19525 }
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053019526 ese_populate_addtional_ies(mac_ctx, session, req_buf);
19527
Selvaraj, Sridharced57062017-01-30 15:19:07 +053019528 /* Append QCN IE if g_support_qcn_ie INI is enabled */
19529 if (mac_ctx->roam.configParam.qcn_ie_support)
19530 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_VENDOR,
19531 DOT11F_IE_QCN_IE_MAX_LEN,
19532 qcn_ie);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019533}
19534
19535/**
Kapil Gupta5cda2252016-12-29 18:44:26 +053019536 * csr_create_per_roam_request() - create PER roam offload scan request
19537 *
19538 * parameters
19539 * @mac_ctx: global mac ctx
19540 * @session_id: session id
19541 *
19542 * Return: per roam config request packet buffer
19543 */
19544static struct wmi_per_roam_config_req *
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019545csr_create_per_roam_request(tpAniSirGlobal mac_ctx,
19546 uint8_t session_id)
Kapil Gupta5cda2252016-12-29 18:44:26 +053019547{
19548 struct wmi_per_roam_config_req *req_buf = NULL;
19549
19550 req_buf = qdf_mem_malloc(sizeof(struct wmi_per_roam_config_req));
19551 if (!req_buf) {
19552 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019553 "Mem alloc for per roam req failed");
Kapil Gupta5cda2252016-12-29 18:44:26 +053019554 return NULL;
19555 }
19556 req_buf->vdev_id = session_id;
19557 req_buf->per_config.enable =
19558 mac_ctx->roam.configParam.per_roam_config.enable;
19559 req_buf->per_config.tx_high_rate_thresh =
19560 mac_ctx->roam.configParam.per_roam_config.tx_high_rate_thresh;
19561 req_buf->per_config.rx_high_rate_thresh =
19562 mac_ctx->roam.configParam.per_roam_config.rx_high_rate_thresh;
19563 req_buf->per_config.tx_low_rate_thresh =
19564 mac_ctx->roam.configParam.per_roam_config.tx_low_rate_thresh;
19565 req_buf->per_config.rx_low_rate_thresh =
19566 mac_ctx->roam.configParam.per_roam_config.rx_low_rate_thresh;
19567 req_buf->per_config.per_rest_time =
19568 mac_ctx->roam.configParam.per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +053019569 req_buf->per_config.tx_per_mon_time =
19570 mac_ctx->roam.configParam.per_roam_config.tx_per_mon_time;
19571 req_buf->per_config.rx_per_mon_time =
19572 mac_ctx->roam.configParam.per_roam_config.rx_per_mon_time;
Kapil Gupta5cda2252016-12-29 18:44:26 +053019573 req_buf->per_config.tx_rate_thresh_percnt =
19574 mac_ctx->roam.configParam.per_roam_config.tx_rate_thresh_percnt;
19575 req_buf->per_config.rx_rate_thresh_percnt =
19576 mac_ctx->roam.configParam.per_roam_config.rx_rate_thresh_percnt;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053019577 req_buf->per_config.min_candidate_rssi =
19578 mac_ctx->roam.configParam.per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +053019579
19580 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053019581 "PER based roaming configuaration enable: %d vdev: %d high_rate_thresh: %d low_rate_thresh: %d rate_thresh_percnt: %d per_rest_time: %d monitor_time: %d min cand rssi: %d",
Kapil Gupta5cda2252016-12-29 18:44:26 +053019582 req_buf->per_config.enable, session_id,
19583 req_buf->per_config.tx_high_rate_thresh,
19584 req_buf->per_config.tx_low_rate_thresh,
19585 req_buf->per_config.tx_rate_thresh_percnt,
Kapil Gupta957827b2017-02-13 15:47:04 +053019586 req_buf->per_config.per_rest_time,
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053019587 req_buf->per_config.tx_per_mon_time,
19588 req_buf->per_config.min_candidate_rssi);
Kapil Gupta5cda2252016-12-29 18:44:26 +053019589 return req_buf;
19590}
19591
19592/**
19593 * csr_roam_offload_per_scan() - populates roam offload scan request and sends
19594 * to WMA
19595 *
19596 * parameters
19597 * @mac_ctx: global mac ctx
19598 * @session_id: session id
19599 *
19600 * Return: result of operation
19601 */
19602static QDF_STATUS
19603csr_roam_offload_per_scan(tpAniSirGlobal mac_ctx, uint8_t session_id)
19604{
19605 tpCsrNeighborRoamControlInfo roam_info =
19606 &mac_ctx->roam.neighborRoamInfo[session_id];
19607 struct wmi_per_roam_config_req *req_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070019608 struct scheduler_msg msg = {0};
Kapil Gupta5cda2252016-12-29 18:44:26 +053019609
19610 /*
19611 * No need to update in case of stop command, FW takes care of stopping
19612 * this internally
19613 */
19614 if (roam_info->last_sent_cmd == ROAM_SCAN_OFFLOAD_STOP)
19615 return QDF_STATUS_SUCCESS;
19616
19617 if (!mac_ctx->roam.configParam.per_roam_config.enable) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019618 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
19619 "PER based roaming is disabled in configuration");
Kapil Gupta5cda2252016-12-29 18:44:26 +053019620 return QDF_STATUS_SUCCESS;
19621 }
19622
19623 req_buf = csr_create_per_roam_request(mac_ctx, session_id);
19624 if (!req_buf) {
19625 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019626 "Failed to create req packet");
Kapil Gupta5cda2252016-12-29 18:44:26 +053019627 return QDF_STATUS_E_FAILURE;
19628 }
19629 msg.type = WMA_SET_PER_ROAM_CONFIG_CMD;
19630 msg.reserved = 0;
19631 msg.bodyptr = req_buf;
19632 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
19633 &msg))) {
19634 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
19635 "%s: Unable to post WMA_SET_PER_ROAM_CONFIG_CMD to WMA",
19636 __func__);
19637 qdf_mem_free(req_buf);
19638 }
19639 return QDF_STATUS_SUCCESS;
19640}
19641
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019642#if defined(WLAN_FEATURE_FILS_SK)
19643QDF_STATUS csr_update_fils_config(tpAniSirGlobal mac, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070019644 struct csr_roam_profile *src_profile)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019645{
19646 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Jeff Johnson66ee8a92018-03-17 15:24:26 -070019647 struct csr_roam_profile *dst_profile = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019648
19649 if (!session) {
19650 sme_err("session NULL");
19651 return QDF_STATUS_E_FAILURE;
19652 }
19653
19654 dst_profile = session->pCurRoamProfile;
19655
19656 if (!dst_profile) {
19657 sme_err("Current Roam profile of SME session NULL");
19658 return QDF_STATUS_E_FAILURE;
19659 }
19660 update_profile_fils_info(dst_profile, src_profile);
19661 return QDF_STATUS_SUCCESS;
19662}
19663
19664/**
19665 * copy_all_before_char() - API to copy all character before a particular char
19666 * @str: Source string
Arif Hussain80a328a2018-03-02 00:12:48 -080019667 * @str_len: Source string legnth
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019668 * @dst: Destination string
Arif Hussain80a328a2018-03-02 00:12:48 -080019669 * @dst_len: Destination string legnth
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019670 * @c: Character before which all characters need to be copied
19671 *
19672 * Return: length of the copied string, if success. zero otherwise.
19673 */
Arif Hussain80a328a2018-03-02 00:12:48 -080019674static uint32_t copy_all_before_char(char *str, uint32_t str_len,
19675 char *dst, uint32_t dst_len, char c)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019676{
19677 uint32_t len = 0;
19678
19679 if (!str)
19680 return len;
19681
Arif Hussain80a328a2018-03-02 00:12:48 -080019682 while ((len < str_len) && (len < dst_len) &&
19683 (*str != '\0') && (*str != c)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019684 *dst++ = *str++;
19685 len++;
19686 }
Arif Hussain80a328a2018-03-02 00:12:48 -080019687
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019688 return len;
19689}
19690
19691/**
19692 * csr_update_fils_params_rso() - API to update FILS params in RSO
19693 * @mac: Mac context
19694 * @session: CSR Roam Session
19695 * @req_buffer: RSO request buffer
19696 *
19697 * Return: None
19698 */
19699static void csr_update_fils_params_rso(tpAniSirGlobal mac,
19700 struct csr_roam_session *session,
19701 tSirRoamOffloadScanReq *req_buffer)
19702{
19703 struct roam_fils_params *roam_fils_params;
19704 struct cds_fils_connection_info *fils_info;
Arif Hussaina216f672018-04-04 07:16:58 -070019705 uint32_t usr_name_len;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019706
19707 if (!session->pCurRoamProfile)
19708 return;
19709
19710 fils_info = session->pCurRoamProfile->fils_con_info;
19711 if (!fils_info || !req_buffer)
19712 return;
19713
Vignesh Viswanathan925db8c2018-01-09 17:20:19 +053019714 if (!fils_info->key_nai_length) {
Vignesh Viswanathan04f87952017-11-04 00:46:10 +053019715 sme_debug("key_nai_length is NULL");
19716 return;
19717 }
19718
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019719 roam_fils_params = &req_buffer->roam_fils_params;
19720 if ((fils_info->key_nai_length > FILS_MAX_KEYNAME_NAI_LENGTH) ||
19721 (fils_info->r_rk_length > FILS_MAX_RRK_LENGTH)) {
19722 sme_err("Fils info len error: keyname nai len(%d) rrk len(%d)",
19723 fils_info->key_nai_length, fils_info->r_rk_length);
19724 return;
19725 }
19726
Arif Hussaina216f672018-04-04 07:16:58 -070019727 usr_name_len = copy_all_before_char(fils_info->keyname_nai,
19728 sizeof(fils_info->keyname_nai),
19729 roam_fils_params->username,
19730 sizeof(roam_fils_params->username),
19731 '@');
19732 if (fils_info->key_nai_length <= usr_name_len) {
19733 sme_err("Fils info len error: key nai len %d, user name len %d",
19734 fils_info->key_nai_length, usr_name_len);
19735 return;
19736 }
19737
19738 roam_fils_params->username_length = usr_name_len;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019739 req_buffer->is_fils_connection = true;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019740
19741 roam_fils_params->next_erp_seq_num =
19742 (fils_info->sequence_number + 1);
19743
19744 roam_fils_params->rrk_length = fils_info->r_rk_length;
19745 qdf_mem_copy(roam_fils_params->rrk, fils_info->r_rk,
19746 roam_fils_params->rrk_length);
19747
19748 /* REALM info */
19749 roam_fils_params->realm_len = fils_info->key_nai_length
19750 - roam_fils_params->username_length - 1;
19751 qdf_mem_copy(roam_fils_params->realm, fils_info->keyname_nai
19752 + roam_fils_params->username_length + 1,
19753 roam_fils_params->realm_len);
19754}
19755#else
19756static inline void csr_update_fils_params_rso(tpAniSirGlobal mac,
19757 struct csr_roam_session *session,
19758 tSirRoamOffloadScanReq *req_buffer)
19759{}
19760#endif
19761
Kapil Gupta5cda2252016-12-29 18:44:26 +053019762/**
Himanshu Agarwal8bcec572017-09-28 11:54:37 +053019763 * csr_update_score_params() - API to update Score params in RSO
19764 * @mac_ctx: Mac context
19765 * @req_buffer: RSO request buffer
19766 *
19767 * Return: None
19768 */
19769static void csr_update_score_params(tpAniSirGlobal mac_ctx,
19770 tSirRoamOffloadScanReq *req_buffer)
19771{
19772 struct scoring_param *req_score_params;
19773 struct rssi_scoring *req_rssi_score;
19774 struct sir_score_config *bss_score_params;
19775 struct sir_weight_config *weight_config;
19776 struct sir_rssi_cfg_score *rssi_score;
19777
19778 req_score_params = &req_buffer->score_params;
19779 req_rssi_score = &req_score_params->rssi_scoring;
19780
19781 bss_score_params = &mac_ctx->roam.configParam.bss_score_params;
19782 weight_config = &bss_score_params->weight_cfg;
19783 rssi_score = &bss_score_params->rssi_score;
19784
19785 if (!bss_score_params->enable_scoring_for_roam)
19786 req_score_params->disable_bitmap =
19787 WLAN_ROAM_SCORING_DISABLE_ALL;
19788
19789 req_score_params->rssi_weightage = weight_config->rssi_weightage;
19790 req_score_params->ht_weightage = weight_config->ht_caps_weightage;
19791 req_score_params->vht_weightage = weight_config->vht_caps_weightage;
19792 req_score_params->he_weightage = weight_config->he_caps_weightage;
19793 req_score_params->bw_weightage = weight_config->chan_width_weightage;
19794 req_score_params->band_weightage = weight_config->chan_band_weightage;
19795 req_score_params->nss_weightage = weight_config->nss_weightage;
19796 req_score_params->esp_qbss_weightage =
19797 weight_config->channel_congestion_weightage;
19798 req_score_params->beamforming_weightage =
19799 weight_config->beamforming_cap_weightage;
19800 req_score_params->pcl_weightage =
19801 weight_config->pcl_weightage;
19802 req_score_params->oce_wan_weightage = weight_config->oce_wan_weightage;
19803
19804 req_score_params->bw_index_score =
19805 bss_score_params->bandwidth_weight_per_index;
19806 req_score_params->band_index_score =
19807 bss_score_params->band_weight_per_index;
19808 req_score_params->nss_index_score =
19809 bss_score_params->nss_weight_per_index;
19810
19811 req_rssi_score->best_rssi_threshold = rssi_score->best_rssi_threshold;
19812 req_rssi_score->good_rssi_threshold = rssi_score->good_rssi_threshold;
19813 req_rssi_score->bad_rssi_threshold = rssi_score->bad_rssi_threshold;
19814 req_rssi_score->good_rssi_pcnt = rssi_score->good_rssi_pcnt;
19815 req_rssi_score->bad_rssi_pcnt = rssi_score->bad_rssi_pcnt;
19816 req_rssi_score->good_bucket_size = rssi_score->good_rssi_bucket_size;
19817 req_rssi_score->bad_bucket_size = rssi_score->bad_rssi_bucket_size;
19818 req_rssi_score->rssi_pref_5g_rssi_thresh =
19819 rssi_score->rssi_pref_5g_rssi_thresh;
19820
19821 req_score_params->esp_qbss_scoring.num_slot =
19822 bss_score_params->esp_qbss_scoring.num_slot;
19823 req_score_params->esp_qbss_scoring.score_pcnt3_to_0 =
19824 bss_score_params->esp_qbss_scoring.score_pcnt3_to_0;
19825 req_score_params->esp_qbss_scoring.score_pcnt7_to_4 =
19826 bss_score_params->esp_qbss_scoring.score_pcnt7_to_4;
19827 req_score_params->esp_qbss_scoring.score_pcnt11_to_8 =
19828 bss_score_params->esp_qbss_scoring.score_pcnt11_to_8;
19829 req_score_params->esp_qbss_scoring.score_pcnt15_to_12 =
19830 bss_score_params->esp_qbss_scoring.score_pcnt15_to_12;
19831
19832 req_score_params->oce_wan_scoring.num_slot =
19833 bss_score_params->oce_wan_scoring.num_slot;
19834 req_score_params->oce_wan_scoring.score_pcnt3_to_0 =
19835 bss_score_params->oce_wan_scoring.score_pcnt3_to_0;
19836 req_score_params->oce_wan_scoring.score_pcnt7_to_4 =
19837 bss_score_params->oce_wan_scoring.score_pcnt7_to_4;
19838 req_score_params->oce_wan_scoring.score_pcnt11_to_8 =
19839 bss_score_params->oce_wan_scoring.score_pcnt11_to_8;
19840 req_score_params->oce_wan_scoring.score_pcnt15_to_12 =
19841 bss_score_params->oce_wan_scoring.score_pcnt15_to_12;
19842}
19843
Abhishek Singh1f217ec2017-12-22 11:48:27 +053019844uint8_t csr_get_roam_enabled_sta_sessionid(tpAniSirGlobal mac_ctx)
19845{
19846 struct csr_roam_session *session;
19847 tpCsrNeighborRoamControlInfo roam_info;
19848 uint8_t i;
19849
19850 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
19851 session = CSR_GET_SESSION(mac_ctx, i);
19852 if (!session || !CSR_IS_SESSION_VALID(mac_ctx, i))
19853 continue;
19854 if (!session->pCurRoamProfile ||
19855 session->pCurRoamProfile->csrPersona != QDF_STA_MODE)
19856 continue;
19857 roam_info = &mac_ctx->roam.neighborRoamInfo[i];
19858 if (roam_info->b_roam_scan_offload_started) {
19859 sme_debug("Roaming enabled on iface, session: %d", i);
19860 return i;
19861 }
19862 }
19863
19864 return CSR_SESSION_ID_INVALID;
19865}
19866
Himanshu Agarwal8bcec572017-09-28 11:54:37 +053019867/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019868 * csr_roam_offload_scan() - populates roam offload scan request and sends to
19869 * WMA
19870 *
Jeff Johnson60ed45a2018-05-06 15:28:49 -070019871 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019872 * @mac_ctx: global mac ctx
19873 * @session_id: session id
19874 * @command: roam scan offload command input
19875 * @reason: reason to roam
19876 *
19877 * Return: result of operation
19878 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019879QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019880csr_roam_offload_scan(tpAniSirGlobal mac_ctx, uint8_t session_id,
19881 uint8_t command, uint8_t reason)
19882{
19883 uint8_t *state = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019884 tSirRoamOffloadScanReq *req_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019885 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019886 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019887 tpCsrNeighborRoamControlInfo roam_info =
19888 &mac_ctx->roam.neighborRoamInfo[session_id];
19889 struct roam_ext_params *roam_params_dst;
19890 struct roam_ext_params *roam_params_src;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053019891 uint8_t i, temp_session_id;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080019892 uint8_t op_channel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019893
Abhishek Singh1f217ec2017-12-22 11:48:27 +053019894 sme_debug("RSO Command %d, Session id %d, Reason %d", command,
19895 session_id, reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019896 if (NULL == session) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019897 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019898 "session is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019899 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019900 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +053019901
Abhishek Singh1f217ec2017-12-22 11:48:27 +053019902 temp_session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
19903 if ((temp_session_id != CSR_SESSION_ID_INVALID) &&
19904 (session_id != temp_session_id)) {
19905 sme_debug("Roam cmd not for session %d on which roaming is enabled",
19906 temp_session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -070019907 return QDF_STATUS_E_FAILURE;
19908 }
19909
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +053019910 if (command == ROAM_SCAN_OFFLOAD_START &&
19911 (session->pCurRoamProfile &&
19912 session->pCurRoamProfile->driver_disabled_roaming)) {
19913 if (reason == REASON_DRIVER_ENABLED) {
19914 session->pCurRoamProfile->driver_disabled_roaming =
19915 false;
19916 sme_debug("driver_disabled_roaming reset for session %d",
19917 session_id);
19918 } else {
19919 sme_debug("Roam start received for session %d on which driver has disabled roaming",
19920 session_id);
19921 return QDF_STATUS_E_FAILURE;
19922 }
19923 }
19924
Vignesh Viswanathan3d478032018-08-02 20:18:53 +053019925 if ((ROAM_SCAN_OFFLOAD_START == command &&
19926 REASON_CTX_INIT != reason) &&
19927 (session->pCurRoamProfile &&
19928 session->pCurRoamProfile->supplicant_disabled_roaming)) {
19929 sme_debug("Supplicant disabled driver roaming");
19930 return QDF_STATUS_E_FAILURE;
19931 }
19932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019933 if (0 == csr_roam_is_roam_offload_scan_enabled(mac_ctx)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019934 sme_err("isRoamOffloadScanEnabled not set");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019935 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019936 }
19937 if (!csr_is_RSO_cmd_allowed(mac_ctx, command, session_id) &&
19938 reason != REASON_ROAM_SET_BLACKLIST_BSSID) {
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070019939 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019940 ("RSO out-of-sync command %d lastSentCmd %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019941 command, roam_info->last_sent_cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019942 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019943 }
19944
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070019945 if ((true == roam_info->b_roam_scan_offload_started)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019946 && (ROAM_SCAN_OFFLOAD_START == command)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019947 sme_err("Roam Scan Offload is already started");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019948 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019949 }
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053019950
19951 /* Roaming is not supported currently for FILS akm */
19952 if (session->pCurRoamProfile && CSR_IS_AUTH_TYPE_FILS(
19953 session->pCurRoamProfile->AuthType.authType[0]) &&
Vignesh Viswanathan3d478032018-08-02 20:18:53 +053019954 !mac_ctx->is_fils_roaming_supported) {
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053019955 sme_info("FILS Roaming not suppprted by fw");
19956 return QDF_STATUS_SUCCESS;
19957 }
19958
Padma, Santhosh Kumar9d896c22017-11-10 15:33:52 +053019959 /* Roaming is not supported currently for OWE akm */
19960 if (session->pCurRoamProfile &&
19961 (session->pCurRoamProfile->AuthType.authType[0] ==
19962 eCSR_AUTH_TYPE_OWE)) {
19963 sme_info("OWE Roaming not suppprted by fw");
19964 return QDF_STATUS_SUCCESS;
19965 }
19966
Padma, Santhosh Kumar2b1e57e2017-09-14 14:42:43 +053019967 /* Roaming is not supported currently for SAE authentication */
19968 if (session->pCurRoamProfile &&
19969 CSR_IS_AUTH_TYPE_SAE(
19970 session->pCurRoamProfile->AuthType.authType[0])) {
19971 sme_info("Roaming not suppprted for SAE connection");
19972 return QDF_STATUS_SUCCESS;
19973 }
19974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019975 /*
19976 * The Dynamic Config Items Update may happen even if the state is in
19977 * INIT. It is important to ensure that the command is passed down to
Naveen Rawat224ae9c2016-10-24 15:36:56 -070019978 * the FW only if the Infra Station is in a connected state. A connected
19979 * station could also be in a PREAUTH or REASSOC states.
19980 * 1) Block all CMDs that are not STOP in INIT State. For STOP always
19981 * inform firmware irrespective of state.
19982 * 2) Block update cfg CMD if its for REASON_ROAM_SET_BLACKLIST_BSSID,
19983 * because we need to inform firmware of blacklisted AP for PNO in
19984 * all states.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019985 */
19986
19987 if ((roam_info->neighborRoamState ==
19988 eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
19989 (command != ROAM_SCAN_OFFLOAD_STOP) &&
19990 (reason != REASON_ROAM_SET_BLACKLIST_BSSID)) {
19991 state = mac_trace_get_neighbour_roam_state(
19992 roam_info->neighborRoamState);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019993 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019994 FL("Scan Command not sent to FW state=%s and cmd=%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019995 state, command);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019996 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019997 }
19998
19999 req_buf = csr_create_roam_scan_offload_request(mac_ctx, command,
20000 session_id, reason,
20001 session, roam_info);
20002 if (!req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020003 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020004 "Failed to create req packet");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020005 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020006 }
20007 roam_params_dst = &req_buf->roam_params;
20008 roam_params_src = &mac_ctx->roam.configParam.roam_params;
20009 if (reason == REASON_ROAM_SET_SSID_ALLOWED)
20010 check_allowed_ssid_list(req_buf, roam_params_src);
Abhishek Singh4db8c152017-07-18 10:40:08 +053020011
20012 /*
20013 * For CTX INT cmd if rssi disallow bssid list have any member
20014 * fill it and send it to firmware so that firmware does not
Jeff Johnson7fa88f72018-05-10 14:52:20 -070020015 * try to roam to these BSS until RSSI OR time condition are
Abhishek Singh4db8c152017-07-18 10:40:08 +053020016 * matched.
20017 */
20018 if (reason == REASON_CTX_INIT)
20019 csr_add_rssi_reject_ap_list(mac_ctx, roam_params_src);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020020 /*
20021 * Configure the lookup threshold either from INI or from framework.
20022 * If both are present, give higher priority to the one from framework.
20023 */
20024 if (roam_params_src->alert_rssi_threshold)
20025 req_buf->LookupThreshold =
20026 roam_params_src->alert_rssi_threshold;
20027 else
20028 req_buf->LookupThreshold =
20029 (int8_t)roam_info->cfgParams.neighborLookupThreshold *
20030 (-1);
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -070020031 req_buf->rssi_thresh_offset_5g =
20032 roam_info->cfgParams.rssi_thresh_offset_5g;
20033 sme_debug("5g offset threshold: %d", req_buf->rssi_thresh_offset_5g);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020034 qdf_mem_copy(roam_params_dst, roam_params_src,
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -070020035 sizeof(*roam_params_dst));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020036 /*
20037 * rssi_diff which is updated via framework is equivalent to the
20038 * INI RoamRssiDiff parameter and hence should be updated.
20039 */
20040 if (roam_params_src->rssi_diff)
20041 req_buf->RoamRssiDiff = roam_params_src->rssi_diff;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020042 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020043 "num_bssid_avoid_list: %d num_ssid_allowed_list: %d num_bssid_favored: %d raise_rssi_thresh_5g: %d drop_rssi_thresh_5g: %d raise_rssi_type_5g: %d raise_factor_5g: %d drop_rssi_type_5g: %d drop_factor_5g: %d max_raise_rssi_5g: %d max_drop_rssi_5g: %d rssi_diff: %d alert_rssi_threshold: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020044 roam_params_dst->num_bssid_avoid_list,
20045 roam_params_dst->num_ssid_allowed_list,
20046 roam_params_dst->num_bssid_favored,
20047 roam_params_dst->raise_rssi_thresh_5g,
20048 roam_params_dst->drop_rssi_thresh_5g,
20049 roam_params_dst->raise_rssi_type_5g,
20050 roam_params_dst->raise_factor_5g,
20051 roam_params_dst->drop_rssi_type_5g,
20052 roam_params_dst->drop_factor_5g,
20053 roam_params_dst->max_raise_rssi_5g,
20054 roam_params_dst->max_drop_rssi_5g,
20055 req_buf->RoamRssiDiff, roam_params_dst->alert_rssi_threshold);
20056
Gupta, Kapil71221252016-06-28 15:35:02 +053020057 /* Set initial dense roam status */
Kapil Gupta0a2477b2016-08-23 18:00:34 +053020058 if (mac_ctx->scan.roam_candidate_count[session_id] >
Gupta, Kapil71221252016-06-28 15:35:02 +053020059 roam_params_dst->dense_min_aps_cnt)
20060 roam_params_dst->initial_dense_status = true;
20061
Kapil Gupta0a2477b2016-08-23 18:00:34 +053020062 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Selvaraj, Sridhard1225e62017-03-17 12:56:58 +053020063 "dense_rssi_thresh_offset: %d, dense_min_aps_cnt:%d, traffic_threshold:%d, "
20064 "initial_dense_status:%d, candidate count:%d",
20065 roam_params_dst->dense_rssi_thresh_offset,
20066 roam_params_dst->dense_min_aps_cnt,
20067 roam_params_dst->traffic_threshold,
20068 roam_params_dst->initial_dense_status,
20069 mac_ctx->scan.roam_candidate_count[session_id]);
Vignesh Viswanathanc018e982017-09-07 18:49:19 +053020070 sme_debug("BG Scan Bad RSSI:%d, bitmap:0x%x Offset for 2G to 5G Roam %d",
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -070020071 roam_params_dst->bg_scan_bad_rssi_thresh,
Vignesh Viswanathanc018e982017-09-07 18:49:19 +053020072 roam_params_dst->bg_scan_client_bitmap,
20073 roam_params_dst->roam_bad_rssi_thresh_offset_2g);
Kapil Gupta0a2477b2016-08-23 18:00:34 +053020074
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020075 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020076 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020077 "Blacklist Bssid:"MAC_ADDRESS_STR")",
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020078 MAC_ADDR_ARRAY(roam_params_dst->bssid_avoid_list[i].
20079 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020080 }
20081 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020082 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020083 "Whitelist: %.*s",
20084 roam_params_dst->ssid_allowed_list[i].length,
20085 roam_params_dst->ssid_allowed_list[i].ssId);
20086 }
20087 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020088 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020089 "Preferred Bssid:"MAC_ADDRESS_STR") score: %d",
Srinivas Girigowdab0532392015-11-24 11:50:16 -080020090 MAC_ADDR_ARRAY(roam_params_dst->bssid_favored[i].bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020091 roam_params_dst->bssid_favored_factor[i]);
20092 }
20093
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080020094 op_channel = session->connectedProfile.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020095 req_buf->hi_rssi_scan_max_count =
20096 roam_info->cfgParams.hi_rssi_scan_max_count;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020097 req_buf->hi_rssi_scan_delay =
20098 roam_info->cfgParams.hi_rssi_scan_delay;
20099 req_buf->hi_rssi_scan_rssi_ub =
20100 roam_info->cfgParams.hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080020101 /*
20102 * If the current operation channel is 5G frequency band, then
20103 * there is no need to enable the HI_RSSI feature. This feature
20104 * is useful only if we are connected to a 2.4 GHz AP and we wish
20105 * to connect to a better 5GHz AP is available.
20106 */
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070020107 if (session->disable_hi_rssi)
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080020108 req_buf->hi_rssi_scan_rssi_delta = 0;
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070020109 else
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080020110 req_buf->hi_rssi_scan_rssi_delta =
20111 roam_info->cfgParams.hi_rssi_scan_rssi_delta;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020112 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080020113 "hi_rssi:delta=%d, max_count=%d, delay=%d, ub=%d",
20114 req_buf->hi_rssi_scan_rssi_delta,
20115 req_buf->hi_rssi_scan_max_count,
20116 req_buf->hi_rssi_scan_delay,
20117 req_buf->hi_rssi_scan_rssi_ub);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020118
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053020119 if (command != ROAM_SCAN_OFFLOAD_STOP) {
Naveen Rawatf311a5a2016-11-15 23:38:10 -080020120 req_buf->assoc_ie.length = session->nAddIEAssocLength;
Selvaraj, Sridhara7fc7632016-09-04 13:13:38 +053020121 qdf_mem_copy(req_buf->assoc_ie.addIEdata,
20122 session->pAddIEAssoc,
20123 session->nAddIEAssocLength);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053020124 csr_update_driver_assoc_ies(mac_ctx, session, req_buf);
Himanshu Agarwal8bcec572017-09-28 11:54:37 +053020125 csr_update_score_params(mac_ctx, req_buf);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053020126 csr_update_fils_params_rso(mac_ctx, session, req_buf);
Selvaraj, Sridhara7fc7632016-09-04 13:13:38 +053020127 }
20128
Vignesh Viswanathane25af782018-03-23 14:49:50 +053020129 /*
20130 * 11k offload is enabled during RSO Start after connect indication and
20131 * 11k offload is disabled during RSO Stop after disconnect indication
20132 */
20133 if (command == ROAM_SCAN_OFFLOAD_START &&
20134 reason == REASON_CTX_INIT)
20135 csr_update_11k_offload_params(mac_ctx, session, req_buf, TRUE);
20136 else if (command == ROAM_SCAN_OFFLOAD_STOP &&
20137 reason == REASON_DISCONNECTED)
20138 csr_update_11k_offload_params(mac_ctx, session, req_buf, FALSE);
20139
Selvaraj, Sridhard1225e62017-03-17 12:56:58 +053020140 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
20141 "Assoc IE buffer:");
20142 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
20143 req_buf->assoc_ie.addIEdata, req_buf->assoc_ie.length);
20144
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053020145 if (!QDF_IS_STATUS_SUCCESS(
20146 csr_roam_send_rso_cmd(mac_ctx, session_id, req_buf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020147 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053020148 "%s: Not able to post message to PE",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020149 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020150 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020151 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020152 if (ROAM_SCAN_OFFLOAD_START == command)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070020153 roam_info->b_roam_scan_offload_started = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020154 else if (ROAM_SCAN_OFFLOAD_STOP == command)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070020155 roam_info->b_roam_scan_offload_started = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020157 /* update the last sent cmd */
20158 roam_info->last_sent_cmd = command;
20159
Kapil Gupta5cda2252016-12-29 18:44:26 +053020160 /* Update PER config to FW after sending the command */
20161 csr_roam_offload_per_scan(mac_ctx, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020162 return status;
20163}
20164
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020165QDF_STATUS csr_roam_offload_scan_rsp_hdlr(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020166 tpSirRoamOffloadScanRsp
20167 scanOffloadRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020168{
20169 switch (scanOffloadRsp->reason) {
20170 case 0:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020171 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020172 "Rsp for Roam Scan Offload with failure status");
20173 break;
20174 case REASON_OS_REQUESTED_ROAMING_NOW:
20175 csr_neighbor_roam_proceed_with_handoff_req(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020176 scanOffloadRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020177 break;
20178
20179 default:
Abhishek Singh245182f2017-08-10 17:41:09 +053020180 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020181 "Rsp for Roam Scan Offload with reason %d",
20182 scanOffloadRsp->reason);
20183 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020184 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020185}
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080020186#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020187
Naveen Rawatfa2a1002018-05-17 16:06:37 -070020188#ifndef QCA_SUPPORT_CP_STATS
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020189/* pStaEntry is no longer invalid upon the return of this function. */
20190static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac,
20191 tListElem *pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020192{
20193 if (pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020194 if (csr_ll_remove_entry(&pMac->roam.statsClientReqList,
20195 pEntry, LL_ACCESS_LOCK))
20196 qdf_mem_free(GET_BASE_ADDR(pEntry,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020197 struct csr_statsclient_reqinfo, link));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020198 }
20199}
20200
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020201static void csr_roam_remove_entry_from_pe_stats_req_list(
20202tpAniSirGlobal pMac, struct csr_pestats_reqinfo *pPeStaEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020203{
20204 tListElem *pEntry;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020205 struct csr_pestats_reqinfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020207 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
20208 if (!pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020209 sme_err("List empty, no stats req for PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020210 return;
20211 }
20212 while (pEntry) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020213 pTempStaEntry = GET_BASE_ADDR(pEntry,
20214 struct csr_pestats_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020215 if (NULL == pTempStaEntry
20216 || (pTempStaEntry->statsMask !=
20217 pPeStaEntry->statsMask)) {
20218 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
20219 LL_ACCESS_NOLOCK);
20220 continue;
20221 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020222 sme_debug("Match found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020223 if (csr_ll_remove_entry(&pMac->roam.peStatsReqList, pEntry,
20224 LL_ACCESS_LOCK)) {
Naveen Rawatd0ca4412017-06-16 14:19:19 -070020225 qdf_mem_free(pTempStaEntry);
20226 pTempStaEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020227 break;
20228 }
20229 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
20230 LL_ACCESS_NOLOCK);
20231 } /* end of while loop */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020232}
20233
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020234static void csr_roam_report_statistics(tpAniSirGlobal pMac,
20235 uint32_t statsMask,
20236 tCsrStatsCallback callback, uint8_t staId,
20237 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020238{
20239 uint8_t stats[500];
20240 uint8_t *pStats = NULL;
20241 uint32_t tempMask = 0;
20242 uint8_t counter = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020243
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020244 if (!callback) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020245 sme_err("Cannot report callback NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020246 return;
20247 }
20248 if (!statsMask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020249 sme_err("Cannot report statsMask is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020250 return;
20251 }
20252 pStats = stats;
20253 tempMask = statsMask;
20254 while (tempMask) {
20255 if (tempMask & 1) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020256 /* new stats info from PE, fill up the stats
20257 * strucutres in PMAC
20258 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020259 switch (counter) {
20260 case eCsrSummaryStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020261 sme_debug("Summary stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020262 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020263 (uint8_t *) &pMac->roam.
20264 summaryStatsInfo,
20265 sizeof(tCsrSummaryStatsInfo));
20266 pStats += sizeof(tCsrSummaryStatsInfo);
20267 break;
20268 case eCsrGlobalClassAStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020269 sme_debug("ClassA stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020270 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020271 (uint8_t *) &pMac->roam.
20272 classAStatsInfo,
20273 sizeof(tCsrGlobalClassAStatsInfo));
20274 pStats += sizeof(tCsrGlobalClassAStatsInfo);
20275 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020276 case eCsrGlobalClassDStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020277 sme_debug("ClassD stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020278 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020279 (uint8_t *) &pMac->roam.
20280 classDStatsInfo,
20281 sizeof(tCsrGlobalClassDStatsInfo));
20282 pStats += sizeof(tCsrGlobalClassDStatsInfo);
20283 break;
Himanshu Agarwal37e42412016-07-21 14:35:09 +053020284 case csr_per_chain_rssi_stats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020285 sme_debug("Per Chain RSSI stats");
Himanshu Agarwal37e42412016-07-21 14:35:09 +053020286 qdf_mem_copy(pStats,
20287 (uint8_t *)&pMac->roam.per_chain_rssi_stats,
20288 sizeof(struct csr_per_chain_rssi_stats_info));
20289 pStats += sizeof(
20290 struct csr_per_chain_rssi_stats_info);
20291 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020292 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020293 sme_err(
20294 "Unknown stats type and counter %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020295 counter);
20296 break;
20297 }
20298 }
20299 tempMask >>= 1;
20300 counter++;
20301 }
20302 callback(stats, pContext);
20303}
20304
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020305static QDF_STATUS csr_roam_dereg_statistics_req(
20306 tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020307{
20308 tListElem *pEntry = NULL;
20309 tListElem *pPrevEntry = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020310 struct csr_statsclient_reqinfo *pTempStaEntry = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020311 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020312
20313 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
20314 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020315 if (!pEntry) {
20316 /* list empty */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020317 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020318 return status;
20319 }
20320 while (pEntry) {
20321 if (pPrevEntry) {
20322 pTempStaEntry =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020323 GET_BASE_ADDR(pPrevEntry,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020324 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020325 /* send up the stats report */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020326 csr_roam_report_statistics(pMac,
20327 pTempStaEntry->statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020328 pTempStaEntry->callback,
20329 pTempStaEntry->staId,
20330 pTempStaEntry->pContext);
20331 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
20332 }
20333 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020334 GET_BASE_ADDR(pEntry, struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020335 if (pTempStaEntry->pPeStaEntry) {
20336 /* pPeStaEntry can be NULL */
20337 pTempStaEntry->pPeStaEntry->numClient--;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020338 /* check if we need to delete the entry from
20339 * peStatsReqList too
20340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020341 if (!pTempStaEntry->pPeStaEntry->numClient) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020342 csr_roam_remove_entry_from_pe_stats_req_list(
20343 pMac,
20344 pTempStaEntry->
20345 pPeStaEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020346 }
20347 }
20348 /* check if we need to stop the tl stats timer too */
20349 pMac->roam.tlStatsReqInfo.numClient--;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020350 pPrevEntry = pEntry;
Naveen Rawatd0ca4412017-06-16 14:19:19 -070020351 pEntry = csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
20352 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020353 }
20354 /* the last one */
20355 if (pPrevEntry) {
20356 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020357 GET_BASE_ADDR(pPrevEntry, struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020358 /* send up the stats report */
20359 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
20360 pTempStaEntry->callback,
20361 pTempStaEntry->staId,
20362 pTempStaEntry->pContext);
20363 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
20364 }
20365 return status;
20366
20367}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070020368#endif /* QCA_SUPPORT_CP_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020369
20370tSmeCmd *csr_get_command_buffer(tpAniSirGlobal pMac)
20371{
20372 tSmeCmd *pCmd = sme_get_command_buffer(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020373
20374 if (pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020375 pMac->roam.sPendingCommands++;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020377 return pCmd;
20378}
20379
Krunal Sonidea45952017-02-15 11:58:15 -080020380static void csr_free_cmd_memory(tpAniSirGlobal pMac, tSmeCmd *pCommand)
20381{
20382 if (!pCommand) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070020383 sme_err("pCommand is NULL");
Krunal Sonidea45952017-02-15 11:58:15 -080020384 return;
20385 }
20386 switch (pCommand->command) {
Krunal Sonidea45952017-02-15 11:58:15 -080020387 case eSmeCommandRoam:
20388 csr_release_command_roam(pMac, pCommand);
20389 break;
20390 case eSmeCommandWmStatusChange:
20391 csr_release_command_wm_status_change(pMac, pCommand);
20392 break;
Krunal Sonidea45952017-02-15 11:58:15 -080020393 default:
20394 break;
20395 }
20396}
20397
Krunal Sonia8270f52017-02-23 19:51:25 -080020398void csr_release_command_buffer(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020399{
20400 if (pMac->roam.sPendingCommands > 0) {
Krunal Sonidea45952017-02-15 11:58:15 -080020401 /*
20402 * All command allocated through csr_get_command_buffer
20403 * need to decrement the pending count when releasing
20404 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020405 pMac->roam.sPendingCommands--;
Krunal Sonidea45952017-02-15 11:58:15 -080020406 csr_free_cmd_memory(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020407 sme_release_command(pMac, pCommand);
20408 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020409 sme_err("no pending commands");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020410 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020411 }
20412}
20413
Krunal Sonia8270f52017-02-23 19:51:25 -080020414void csr_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020415{
Krunal Sonia8270f52017-02-23 19:51:25 -080020416 struct wlan_serialization_queued_cmd_info cmd_info;
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020417 struct wlan_serialization_command cmd;
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070020418 struct wlan_objmgr_vdev *vdev;
Krunal Sonia8270f52017-02-23 19:51:25 -080020419
20420 if (!sme_cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020421 sme_err("sme_cmd is NULL");
Krunal Sonia8270f52017-02-23 19:51:25 -080020422 return;
20423 }
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070020424 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
20425 sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
20426 if (!vdev) {
20427 sme_err("Invalid vdev");
20428 return;
20429 }
Krunal Soni81f068c2017-02-23 19:51:55 -080020430 qdf_mem_zero(&cmd_info,
20431 sizeof(struct wlan_serialization_queued_cmd_info));
Abhinav Kumarf9989582018-02-06 17:42:22 +053020432
Krunal Sonida0e1e72018-06-01 10:50:38 -070020433 sme_debug("filled cmd_id = %d", sme_cmd->cmd_id);
20434 cmd_info.cmd_id = sme_cmd->cmd_id;
Abhinav Kumarf9989582018-02-06 17:42:22 +053020435 cmd_info.req_type = WLAN_SER_CANCEL_NON_SCAN_CMD;
Krunal Soni81f068c2017-02-23 19:51:55 -080020436 cmd_info.cmd_type = csr_get_cmd_type(sme_cmd);
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070020437 cmd_info.vdev = vdev;
20438 qdf_mem_zero(&cmd, sizeof(struct wlan_serialization_command));
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020439 cmd.cmd_id = cmd_info.cmd_id;
20440 cmd.cmd_type = cmd_info.cmd_type;
20441 cmd.vdev = cmd_info.vdev;
Krunal Soni81f068c2017-02-23 19:51:55 -080020442 if (wlan_serialization_is_cmd_present_in_active_queue(
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020443 mac_ctx->psoc, &cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020444 sme_debug("Releasing active cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020445 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Soni81f068c2017-02-23 19:51:55 -080020446 wlan_serialization_remove_cmd(&cmd_info);
20447 } else if (wlan_serialization_is_cmd_present_in_pending_queue(
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020448 mac_ctx->psoc, &cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020449 sme_debug("Releasing pending cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020450 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Soni81f068c2017-02-23 19:51:55 -080020451 wlan_serialization_cancel_request(&cmd_info);
20452 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020453 sme_debug("can't find cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020454 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Sonia8270f52017-02-23 19:51:25 -080020455 }
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020456 if (cmd_info.vdev)
20457 wlan_objmgr_vdev_release_ref(cmd_info.vdev, WLAN_LEGACY_SME_ID);
Krunal Sonia8270f52017-02-23 19:51:25 -080020458}
20459
Krunal Sonia8270f52017-02-23 19:51:25 -080020460
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020461static enum wlan_serialization_cmd_type csr_get_roam_cmd_type(
20462 tSmeCmd *sme_cmd)
Krunal Sonia8270f52017-02-23 19:51:25 -080020463{
20464 enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -070020465
Krunal Sonia8270f52017-02-23 19:51:25 -080020466 switch (sme_cmd->u.roamCmd.roamReason) {
20467 case eCsrForcedDisassoc:
20468 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC;
20469 break;
20470 case eCsrHddIssued:
20471 cmd_type = WLAN_SER_CMD_HDD_ISSUED;
20472 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020473 case eCsrForcedDisassocMICFailure:
20474 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL;
20475 break;
20476 case eCsrHddIssuedReassocToSameAP:
20477 cmd_type = WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP;
20478 break;
20479 case eCsrSmeIssuedReassocToSameAP:
20480 cmd_type = WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP;
20481 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020482 case eCsrForcedDeauth:
20483 cmd_type = WLAN_SER_CMD_FORCE_DEAUTH;
20484 break;
20485 case eCsrSmeIssuedDisassocForHandoff:
20486 cmd_type =
20487 WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF;
20488 break;
20489 case eCsrSmeIssuedAssocToSimilarAP:
20490 cmd_type =
20491 WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP;
20492 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020493 case eCsrForcedIbssLeave:
20494 cmd_type = WLAN_SER_CMD_FORCE_IBSS_LEAVE;
20495 break;
20496 case eCsrStopBss:
20497 cmd_type = WLAN_SER_CMD_STOP_BSS;
20498 break;
20499 case eCsrSmeIssuedFTReassoc:
20500 cmd_type = WLAN_SER_CMD_SME_ISSUE_FT_REASSOC;
20501 break;
20502 case eCsrForcedDisassocSta:
20503 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC_STA;
20504 break;
20505 case eCsrForcedDeauthSta:
20506 cmd_type = WLAN_SER_CMD_FORCE_DEAUTH_STA;
20507 break;
20508 case eCsrPerformPreauth:
20509 cmd_type = WLAN_SER_CMD_PERFORM_PRE_AUTH;
20510 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020511 default:
20512 break;
20513 }
20514
20515 return cmd_type;
20516}
20517
20518enum wlan_serialization_cmd_type csr_get_cmd_type(tSmeCmd *sme_cmd)
20519{
20520 enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
20521
20522 switch (sme_cmd->command) {
Krunal Sonia8270f52017-02-23 19:51:25 -080020523 case eSmeCommandRoam:
20524 cmd_type = csr_get_roam_cmd_type(sme_cmd);
20525 break;
20526 case eSmeCommandWmStatusChange:
20527 cmd_type = WLAN_SER_CMD_WM_STATUS_CHANGE;
20528 break;
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +053020529 case e_sme_command_del_sta_session:
20530 cmd_type = WLAN_SER_CMD_DEL_STA_SESSION;
20531 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020532 case eSmeCommandAddTs:
20533 cmd_type = WLAN_SER_CMD_ADDTS;
20534 break;
20535 case eSmeCommandDelTs:
20536 cmd_type = WLAN_SER_CMD_DELTS;
20537 break;
20538 case eSmeCommandTdlsSendMgmt:
20539 cmd_type = WLAN_SER_CMD_TDLS_SEND_MGMT;
20540 break;
20541 case eSmeCommandTdlsAddPeer:
20542 cmd_type = WLAN_SER_CMD_TDLS_ADD_PEER;
20543 break;
20544 case eSmeCommandTdlsDelPeer:
20545 cmd_type = WLAN_SER_CMD_TDLS_DEL_PEER;
20546 break;
20547 case eSmeCommandTdlsLinkEstablish:
20548 cmd_type = WLAN_SER_CMD_TDLS_LINK_EST;
20549 break;
20550 case e_sme_command_set_hw_mode:
20551 cmd_type = WLAN_SER_CMD_SET_HW_MODE;
20552 break;
20553 case e_sme_command_nss_update:
20554 cmd_type = WLAN_SER_CMD_NSS_UPDATE;
20555 break;
20556 case e_sme_command_set_dual_mac_config:
20557 cmd_type = WLAN_SER_CMD_SET_DUAL_MAC_CONFIG;
20558 break;
20559 case e_sme_command_set_antenna_mode:
20560 cmd_type = WLAN_SER_CMD_SET_ANTENNA_MODE;
20561 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020562 case eSmeCommandEnterBmps:
20563 cmd_type = WLAN_SER_CMD_ENTER_BMPS;
20564 break;
20565 case eSmeCommandExitBmps:
20566 cmd_type = WLAN_SER_CMD_EXIT_BMPS;
20567 break;
20568 case eSmeCommandEnterUapsd:
20569 cmd_type = WLAN_SER_CMD_ENTER_UAPSD;
20570 break;
20571 case eSmeCommandExitUapsd:
20572 cmd_type = WLAN_SER_CMD_EXIT_UAPSD;
20573 break;
20574 case eSmeCommandExitWowl:
20575 cmd_type = WLAN_SER_CMD_EXIT_WOWL;
20576 break;
20577 default:
20578 break;
20579 }
20580
20581 return cmd_type;
20582}
20583
Krunal Sonida0e1e72018-06-01 10:50:38 -070020584static uint32_t csr_get_monotonous_number(tpAniSirGlobal mac_ctx)
20585{
20586 uint32_t cmd_id;
20587 uint32_t mask = 0x00FFFFFF, prefix = 0x0D000000;
20588
20589 cmd_id = qdf_atomic_inc_return(&mac_ctx->global_cmd_id);
20590 cmd_id = (cmd_id & mask);
20591 cmd_id = (cmd_id | prefix);
20592
20593 return cmd_id;
20594}
20595
Krunal Sonia8270f52017-02-23 19:51:25 -080020596QDF_STATUS csr_set_serialization_params_to_cmd(tpAniSirGlobal mac_ctx,
20597 tSmeCmd *sme_cmd, struct wlan_serialization_command *cmd,
20598 uint8_t high_priority)
20599{
20600 QDF_STATUS status = QDF_STATUS_E_FAILURE;
20601
20602 if (!sme_cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020603 sme_err("Invalid sme_cmd");
Krunal Sonia8270f52017-02-23 19:51:25 -080020604 return status;
20605 }
20606 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020607 sme_err("Invalid serialization_cmd");
Krunal Sonia8270f52017-02-23 19:51:25 -080020608 return status;
20609 }
20610
20611 /*
20612 * no need to fill command id for non-scan as they will be
20613 * zero always
20614 */
Krunal Sonida0e1e72018-06-01 10:50:38 -070020615 sme_cmd->cmd_id = csr_get_monotonous_number(mac_ctx);
20616 cmd->cmd_id = sme_cmd->cmd_id;
20617 sme_debug("cmd_id = %d", cmd->cmd_id);
Abhinav Kumarf9989582018-02-06 17:42:22 +053020618
Krunal Sonia8270f52017-02-23 19:51:25 -080020619 cmd->cmd_type = csr_get_cmd_type(sme_cmd);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020620 sme_debug("filled cmd_type[%d] cmd_id[%d]",
Krunal Soni81f068c2017-02-23 19:51:55 -080020621 cmd->cmd_type, cmd->cmd_id);
Krunal Sonia8270f52017-02-23 19:51:25 -080020622 if (cmd->cmd_type == WLAN_SER_CMD_MAX) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070020623 sme_err("serialization enum not found");
Krunal Sonia8270f52017-02-23 19:51:25 -080020624 return status;
20625 }
20626 cmd->vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
20627 sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
Krunal Soni45ec4392017-10-20 11:44:22 -070020628 if (!cmd->vdev) {
20629 sme_err("vdev is NULL for sme_session:%d", sme_cmd->sessionId);
20630 return status;
20631 }
Krunal Sonia8270f52017-02-23 19:51:25 -080020632 cmd->umac_cmd = sme_cmd;
20633 cmd->cmd_timeout_duration = SME_DEFAULT_CMD_TIMEOUT;
20634 cmd->cmd_cb = sme_ser_cmd_callback;
20635 cmd->is_high_priority = high_priority;
20636 return QDF_STATUS_SUCCESS;
20637}
20638
20639QDF_STATUS csr_queue_sme_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd,
20640 bool high_priority)
20641{
20642 struct wlan_serialization_command cmd;
Krunal Soniaa179db2017-10-13 19:28:17 -070020643 struct wlan_objmgr_vdev *vdev = NULL;
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020644 QDF_STATUS status;
Krunal Sonia8270f52017-02-23 19:51:25 -080020645
20646 if (!SME_IS_START(mac_ctx)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020647 sme_err("Sme in stop state");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020648 QDF_ASSERT(0);
Krunal Soniaa179db2017-10-13 19:28:17 -070020649 goto error;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020650 }
20651
Krunal Soni81f068c2017-02-23 19:51:55 -080020652 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sme_cmd->sessionId)) {
Krunal Sonid3676732017-05-10 14:12:18 -070020653 if (!CSR_IS_DISCONNECT_COMMAND(sme_cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020654 sme_err("Can't process cmd(%d), waiting for key",
Krunal Soni81f068c2017-02-23 19:51:55 -080020655 sme_cmd->command);
Krunal Soniaa179db2017-10-13 19:28:17 -070020656 goto error;
Krunal Soni81f068c2017-02-23 19:51:55 -080020657 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020658 }
Krunal Soni81f068c2017-02-23 19:51:55 -080020659
Krunal Sonia8270f52017-02-23 19:51:25 -080020660 qdf_mem_zero(&cmd, sizeof(struct wlan_serialization_command));
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020661 status = csr_set_serialization_params_to_cmd(mac_ctx, sme_cmd,
20662 &cmd, high_priority);
20663 if (QDF_STATUS_SUCCESS == status) {
Krunal Soniaa179db2017-10-13 19:28:17 -070020664 vdev = cmd.vdev;
Krunal Sonia8270f52017-02-23 19:51:25 -080020665 if (WLAN_SER_CMD_DENIED_UNSPECIFIED ==
Krunal Soniaa179db2017-10-13 19:28:17 -070020666 wlan_serialization_request(&cmd))
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020667 status = QDF_STATUS_E_FAILURE;
Krunal Soniaa179db2017-10-13 19:28:17 -070020668 if (vdev)
20669 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_SME_ID);
20670 if (status == QDF_STATUS_E_FAILURE)
20671 goto error;
Krunal Sonia8270f52017-02-23 19:51:25 -080020672 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070020673 sme_err("failed to set ser params");
Krunal Soniaa179db2017-10-13 19:28:17 -070020674 goto error;
Krunal Sonia8270f52017-02-23 19:51:25 -080020675 }
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020676 return status;
Krunal Soniaa179db2017-10-13 19:28:17 -070020677
20678error:
20679 csr_release_command_buffer(mac_ctx, sme_cmd);
20680 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020681}
20682
Naveen Rawat8029a402017-06-01 10:54:19 -070020683QDF_STATUS csr_roam_update_config(tpAniSirGlobal mac_ctx, uint8_t session_id,
20684 uint16_t capab, uint32_t value)
20685{
20686 struct update_config *msg;
20687 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020688 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Naveen Rawat8029a402017-06-01 10:54:19 -070020689
20690 sme_debug("update HT config requested");
20691 if (NULL == session) {
20692 sme_err("Session does not exist for session id %d", session_id);
20693 return QDF_STATUS_E_FAILURE;
20694 }
20695
20696 msg = qdf_mem_malloc(sizeof(*msg));
20697 if (NULL == msg) {
20698 sme_err("malloc failed");
20699 return QDF_STATUS_E_NOMEM;
20700 }
20701
20702 msg->messageType = eWNI_SME_UPDATE_CONFIG;
20703 msg->sme_session_id = session_id;
20704 msg->capab = capab;
20705 msg->value = value;
20706 msg->length = sizeof(*msg);
20707 status = umac_send_mb_message_to_mac(msg);
20708
20709 return status;
20710}
20711
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020712/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020713 * pBuf points to the beginning of the message
20714 * LIM packs disassoc rsp as below,
20715 * messageType - 2 bytes
20716 * messageLength - 2 bytes
20717 * sessionId - 1 byte
20718 * transactionId - 2 bytes (uint16_t)
20719 * reasonCode - 4 bytes (sizeof(tSirResultCodes))
20720 * peerMacAddr - 6 bytes
20721 * The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP)
20722 * and not used
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020723 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020724static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf, tSirSmeDisassocRsp
20725 *pRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020726{
20727 if (pBuf && pRsp) {
20728 pBuf += 4; /* skip type and length */
20729 pRsp->sessionId = *pBuf++;
Anurag Chouhanc5548422016-02-24 18:33:27 +053020730 qdf_get_u16(pBuf, (uint16_t *) &pRsp->transactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020731 pBuf += 2;
Anurag Chouhanc5548422016-02-24 18:33:27 +053020732 qdf_get_u32(pBuf, (uint32_t *) &pRsp->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020733 pBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020734 qdf_mem_copy(pRsp->peer_macaddr.bytes, pBuf, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020735 }
20736}
20737
Anurag Chouhan6d760662016-02-20 16:05:43 +053020738/* Returns whether a session is in QDF_STA_MODE...or not */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020739bool csr_roam_is_sta_mode(tpAniSirGlobal pMac, uint32_t sessionId)
20740{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020741 struct csr_roam_session *pSession = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020743 pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020745 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020746 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020747 return false;
20748 }
20749 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020750 sme_err("Inactive session_id: %d", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020751 return false;
20752 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020753 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020754 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020755 /* There is a possibility that the above check may fail,because
20756 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
20757 * when it is connected.So,we may sneak through the above check even
20758 * if we are not a STA mode INFRA station. So, if we sneak through
20759 * the above condition, we can use the following check if we are
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020760 * really in STA Mode.
20761 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020762
20763 if (NULL != pSession->pCurRoamProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020764 if (pSession->pCurRoamProfile->csrPersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020765 return true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020766 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020767 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020768 }
20769
20770 return false;
20771}
20772
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020773QDF_STATUS csr_handoff_request(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020774 uint8_t sessionId,
20775 tCsrHandoffRequest *pHandoffInfo)
20776{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020777 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070020778 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020779
20780 tAniHandoffReq *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020781
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020782 pMsg = qdf_mem_malloc(sizeof(tAniHandoffReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020783 if (NULL == pMsg) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020784 sme_err("csr_handoff_request: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020785 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020786 }
20787 pMsg->msgType = eWNI_SME_HANDOFF_REQ;
20788 pMsg->msgLen = (uint16_t) sizeof(tAniHandoffReq);
20789 pMsg->sessionId = sessionId;
20790 pMsg->channel = pHandoffInfo->channel;
20791 pMsg->handoff_src = pHandoffInfo->src;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020792 qdf_mem_copy(pMsg->bssid, pHandoffInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020793 msg.type = eWNI_SME_HANDOFF_REQ;
20794 msg.bodyptr = pMsg;
20795 msg.reserved = 0;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080020796 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080020797 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020798 sme_err("scheduler_post_msg failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020799 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020800 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020801 }
20802 return status;
20803}
20804
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020805/**
20806 * csr_roam_channel_change_req() - Post channel change request to LIM
20807 * @pMac: mac context
20808 * @bssid: SAP bssid
20809 * @ch_params: channel information
20810 * @profile: CSR profile
20811 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080020812 * This API is primarily used to post Channel Change Req for SAP
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020813 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020814 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020815 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020816QDF_STATUS csr_roam_channel_change_req(tpAniSirGlobal pMac,
Amar Singhale4f28ee2015-10-21 14:36:56 -070020817 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080020818 struct ch_params *ch_params,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070020819 struct csr_roam_profile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020820{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020821 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020822 tSirChanChangeRequest *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020823 struct csr_roamstart_bssparams param;
hqu16d6e082017-09-04 10:52:31 +080020824 bool skip_hostapd_rate = !profile->chan_switch_hostapd_rate_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020825
Krunal Soni8f8507c2016-12-20 13:54:34 -080020826 /*
20827 * while changing the channel, use basic rates given by driver
20828 * and not by hostapd as there is a chance that hostapd might
20829 * give us rates based on original channel which may not be
20830 * suitable for new channel
20831 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020832 qdf_mem_zero(&param, sizeof(struct csr_roamstart_bssparams));
Ravi Joshib398c852017-07-18 17:55:21 -070020833
Bala Venkateshb39ed152017-12-26 19:35:27 +053020834 status = csr_roam_get_bss_start_parms(pMac, profile, &param,
20835 skip_hostapd_rate);
20836
20837 if (status != QDF_STATUS_SUCCESS) {
20838 sme_err("Failed to get bss parameters");
20839 return status;
20840 }
Ravi Joshib398c852017-07-18 17:55:21 -070020841
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020842 pMsg = qdf_mem_malloc(sizeof(tSirChanChangeRequest));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020843 if (!pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020844 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020845
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020846 pMsg->messageType = eWNI_SME_CHANNEL_CHANGE_REQ;
20847 pMsg->messageLen = sizeof(tSirChanChangeRequest);
20848 pMsg->targetChannel = profile->ChannelInfo.ChannelList[0];
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020849 pMsg->sec_ch_offset = ch_params->sec_ch_offset;
20850 pMsg->ch_width = profile->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020851 pMsg->dot11mode = csr_translate_to_wni_cfg_dot11_mode(pMac,
Himanshu Agarwalf5c5b102018-05-22 20:13:57 +053020852 param.uCfgDot11Mode);
Gupta, Kapil76ed25e2016-04-22 15:13:55 +053020853 if (IS_24G_CH(pMsg->targetChannel) &&
20854 (false == pMac->roam.configParam.enableVhtFor24GHz) &&
20855 (WNI_CFG_DOT11_MODE_11AC == pMsg->dot11mode ||
20856 WNI_CFG_DOT11_MODE_11AC_ONLY == pMsg->dot11mode))
20857 pMsg->dot11mode = WNI_CFG_DOT11_MODE_11N;
Bala Venkateshb39ed152017-12-26 19:35:27 +053020858 pMsg->nw_type = param.sirNwType;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020859 pMsg->center_freq_seg_0 = ch_params->center_freq_seg0;
20860 pMsg->center_freq_seg_1 = ch_params->center_freq_seg1;
Arif Hussain671a1902017-03-17 09:08:32 -070020861 pMsg->cac_duration_ms = profile->cac_duration_ms;
20862 pMsg->dfs_regdomain = profile->dfs_regdomain;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020863 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
20864 qdf_mem_copy(&pMsg->operational_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020865 &param.operationalRateSet, sizeof(pMsg->operational_rateset));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020866 qdf_mem_copy(&pMsg->extended_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020867 &param.extendedRateSet, sizeof(pMsg->extended_rateset));
Vignesh Viswanathan694bec32018-07-11 14:37:39 +053020868
20869 sme_debug("target_chan %d ch_width %d dot11mode %d",
20870 pMsg->targetChannel, pMsg->ch_width, pMsg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080020871 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020872
20873 return status;
20874}
20875
20876/*
20877 * Post Beacon Tx Start request to LIM
20878 * immediately after SAP CAC WAIT is
20879 * completed without any RADAR indications.
20880 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020881QDF_STATUS csr_roam_start_beacon_req(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053020882 struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020883 uint8_t dfsCacWaitStatus)
20884{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020885 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020886 tSirStartBeaconIndication *pMsg;
20887
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020888 pMsg = qdf_mem_malloc(sizeof(tSirStartBeaconIndication));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020889
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020890 if (!pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020891 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020892
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020893 pMsg->messageType = eWNI_SME_START_BEACON_REQ;
20894 pMsg->messageLen = sizeof(tSirStartBeaconIndication);
20895 pMsg->beaconStartStatus = dfsCacWaitStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020896 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020897
Rajeev Kumard138ac52017-01-30 18:38:37 -080020898 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020899
20900 return status;
20901}
20902
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020903/*
20904 * csr_roam_modify_add_ies -
20905 * This function sends msg to modify the additional IE buffers in PE
20906 *
20907 * @pMac: pMac global structure
20908 * @pModifyIE: pointer to tSirModifyIE structure
20909 * @updateType: Type of buffer
20910 *
20911 *
20912 * Return: QDF_STATUS - Success or failure
20913 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020914QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020915csr_roam_modify_add_ies(tpAniSirGlobal pMac,
20916 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
20917{
20918 tpSirModifyIEsInd pModifyAddIEInd = NULL;
20919 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020920 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020921
20922 /* following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020923 pLocalBuffer = qdf_mem_malloc(pModifyIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020924
20925 if (NULL == pLocalBuffer) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020926 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020927 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020928 }
20929
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020930 pModifyAddIEInd = qdf_mem_malloc(sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020931 if (NULL == pModifyAddIEInd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020932 sme_err("Memory Allocation Failure!!!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020933 qdf_mem_free(pLocalBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020934 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020935 }
20936
20937 /*copy the IE buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020938 qdf_mem_copy(pLocalBuffer, pModifyIE->pIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020939 pModifyIE->ieBufferlength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020940 qdf_mem_zero(pModifyAddIEInd, sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020941
20942 pModifyAddIEInd->msgType = eWNI_SME_MODIFY_ADDITIONAL_IES;
20943 pModifyAddIEInd->msgLen = sizeof(tSirModifyIEsInd);
20944
Anurag Chouhanc5548422016-02-24 18:33:27 +053020945 qdf_copy_macaddr(&pModifyAddIEInd->modifyIE.bssid, &pModifyIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020946
20947 pModifyAddIEInd->modifyIE.smeSessionId = pModifyIE->smeSessionId;
20948 pModifyAddIEInd->modifyIE.notify = pModifyIE->notify;
20949 pModifyAddIEInd->modifyIE.ieID = pModifyIE->ieID;
20950 pModifyAddIEInd->modifyIE.ieIDLen = pModifyIE->ieIDLen;
20951 pModifyAddIEInd->modifyIE.pIEBuffer = pLocalBuffer;
20952 pModifyAddIEInd->modifyIE.ieBufferlength = pModifyIE->ieBufferlength;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080020953 pModifyAddIEInd->modifyIE.oui_length = pModifyIE->oui_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020954
20955 pModifyAddIEInd->updateType = updateType;
20956
Rajeev Kumard138ac52017-01-30 18:38:37 -080020957 status = umac_send_mb_message_to_mac(pModifyAddIEInd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020958 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020959 sme_err("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg status %d",
20960 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020961 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020962 }
20963 return status;
20964}
20965
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020966/*
20967 * csr_roam_update_add_ies -
20968 * This function sends msg to updates the additional IE buffers in PE
20969 *
20970 * @pMac: pMac global structure
20971 * @sessionId: SME session id
20972 * @bssid: BSSID
20973 * @additionIEBuffer: buffer containing addition IE from hostapd
20974 * @length: length of buffer
20975 * @updateType: Type of buffer
20976 * @append: append or replace completely
20977 *
20978 *
20979 * Return: QDF_STATUS - Success or failure
20980 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020981QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020982csr_roam_update_add_ies(tpAniSirGlobal pMac,
20983 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
20984{
20985 tpSirUpdateIEsInd pUpdateAddIEs = NULL;
20986 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020987 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020988
20989 if (pUpdateIE->ieBufferlength != 0) {
20990 /* Following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020991 pLocalBuffer = qdf_mem_malloc(pUpdateIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020992 if (NULL == pLocalBuffer) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020993 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020994 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020995 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020996 qdf_mem_copy(pLocalBuffer, pUpdateIE->pAdditionIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020997 pUpdateIE->ieBufferlength);
20998 }
20999
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021000 pUpdateAddIEs = qdf_mem_malloc(sizeof(tSirUpdateIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021001 if (NULL == pUpdateAddIEs) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021002 sme_err("Memory Allocation Failure!!!");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021003 if (pLocalBuffer != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021004 qdf_mem_free(pLocalBuffer);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021005
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021006 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021007 }
21008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021009 pUpdateAddIEs->msgType = eWNI_SME_UPDATE_ADDITIONAL_IES;
21010 pUpdateAddIEs->msgLen = sizeof(tSirUpdateIEsInd);
21011
Anurag Chouhanc5548422016-02-24 18:33:27 +053021012 qdf_copy_macaddr(&pUpdateAddIEs->updateIE.bssid, &pUpdateIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021013
21014 pUpdateAddIEs->updateIE.smeSessionId = pUpdateIE->smeSessionId;
21015 pUpdateAddIEs->updateIE.append = pUpdateIE->append;
21016 pUpdateAddIEs->updateIE.notify = pUpdateIE->notify;
21017 pUpdateAddIEs->updateIE.ieBufferlength = pUpdateIE->ieBufferlength;
21018 pUpdateAddIEs->updateIE.pAdditionIEBuffer = pLocalBuffer;
21019
21020 pUpdateAddIEs->updateType = updateType;
21021
Rajeev Kumard138ac52017-01-30 18:38:37 -080021022 status = umac_send_mb_message_to_mac(pUpdateAddIEs);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021023 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021024 sme_err("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg status %d",
21025 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021026 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021027 }
21028 return status;
21029}
21030
21031/**
Abhishek Singh518323d2015-10-19 17:42:01 +053021032 * csr_send_ext_change_channel()- function to post send ECSA
21033 * action frame to lim.
21034 * @mac_ctx: pointer to global mac structure
21035 * @channel: new channel to switch
21036 * @session_id: senssion it should be sent on.
21037 *
21038 * This function is called to post ECSA frame to lim.
21039 *
21040 * Return: success if msg posted to LIM else return failure
21041 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021042QDF_STATUS csr_send_ext_change_channel(tpAniSirGlobal mac_ctx, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +053021043 uint8_t session_id)
21044{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021045 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +053021046 struct sir_sme_ext_cng_chan_req *msg;
21047
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021048 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh518323d2015-10-19 17:42:01 +053021049 if (NULL == msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021050 return QDF_STATUS_E_NOMEM;
Abhishek Singh518323d2015-10-19 17:42:01 +053021051
Abhishek Singh518323d2015-10-19 17:42:01 +053021052 msg->message_type = eWNI_SME_EXT_CHANGE_CHANNEL;
21053 msg->length = sizeof(*msg);
21054 msg->new_channel = channel;
21055 msg->session_id = session_id;
Rajeev Kumard138ac52017-01-30 18:38:37 -080021056 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh518323d2015-10-19 17:42:01 +053021057 return status;
21058}
21059
21060/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021061 * csr_roam_send_chan_sw_ie_request() - Request to transmit CSA IE
21062 * @mac_ctx: Global MAC context
21063 * @bssid: BSSID
21064 * @target_channel: Channel on which to send the IE
21065 * @csa_ie_reqd: Include/Exclude CSA IE.
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080021066 * @ch_params: operating Channel related information
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021067 *
21068 * This function sends request to transmit channel switch announcement
21069 * IE to lower layers
21070 *
21071 * Return: success or failure
21072 **/
Amar Singhale4f28ee2015-10-21 14:36:56 -070021073QDF_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
21074 struct qdf_mac_addr bssid,
21075 uint8_t target_channel,
21076 uint8_t csa_ie_reqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080021077 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021078{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021079 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021080 tSirDfsCsaIeRequest *msg;
21081
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021082 msg = qdf_mem_malloc(sizeof(tSirDfsCsaIeRequest));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021083 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021084 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021085
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021086 msg->msgType = eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ;
21087 msg->msgLen = sizeof(tSirDfsCsaIeRequest);
21088
21089 msg->targetChannel = target_channel;
21090 msg->csaIeRequired = csa_ie_reqd;
gaoleze2920bd2017-03-21 17:38:42 +080021091 msg->ch_switch_beacon_cnt =
21092 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt;
gaolez76d2a162017-03-21 19:23:58 +080021093 msg->ch_switch_mode = mac_ctx->sap.SapDfsInfo.sap_ch_switch_mode;
21094 msg->dfs_ch_switch_disable =
21095 mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021096 qdf_mem_copy(msg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Amar Singhal5cccafe2017-02-15 12:42:58 -080021097 qdf_mem_copy(&msg->ch_params, ch_params, sizeof(struct ch_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021098
Rajeev Kumard138ac52017-01-30 18:38:37 -080021099 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021100
21101 return status;
21102}
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080021103#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
21104/**
21105 * csr_roaming_report_diag_event() - Diag events for LFR3
21106 * @mac_ctx: MAC context
21107 * @roam_synch_ind_ptr: Roam Synch Indication Pointer
21108 * @reason: Reason for this event to happen
21109 *
21110 * The major events in the host for LFR3 roaming such as
21111 * roam synch indication, roam synch completion and
21112 * roam synch handoff fail will be indicated to the
21113 * diag framework using this API.
21114 *
21115 * Return: None
21116 */
21117void csr_roaming_report_diag_event(tpAniSirGlobal mac_ctx,
21118 roam_offload_synch_ind *roam_synch_ind_ptr,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021119 enum csr_diagwlan_status_eventreason reason)
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080021120{
21121 WLAN_HOST_DIAG_EVENT_DEF(roam_connection,
21122 host_event_wlan_status_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021123 qdf_mem_set(&roam_connection,
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080021124 sizeof(host_event_wlan_status_payload_type), 0);
21125 switch (reason) {
21126 case eCSR_REASON_ROAM_SYNCH_IND:
21127 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
21128 if (roam_synch_ind_ptr) {
21129 roam_connection.rssi = roam_synch_ind_ptr->rssi;
21130 roam_connection.channel =
21131 cds_freq_to_chan(roam_synch_ind_ptr->chan_freq);
21132 }
21133 break;
21134 case eCSR_REASON_ROAM_SYNCH_CNF:
21135 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
21136 break;
21137 case eCSR_REASON_ROAM_HO_FAIL:
21138 roam_connection.eventId = eCSR_WLAN_STATUS_DISCONNECT;
21139 break;
21140 default:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021141 sme_err("LFR3: Unsupported reason %d", reason);
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080021142 return;
21143 }
21144 roam_connection.reason = reason;
Abhishek Singh7a995582016-04-27 13:53:36 +053021145 WLAN_HOST_DIAG_EVENT_REPORT(&roam_connection, EVENT_WLAN_STATUS_V2);
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080021146}
21147#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021148
21149#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021150/*
21151 * fn csr_process_ho_fail_ind
21152 * brief This function will process the Hand Off Failure indication
21153 * received from the firmware. It will trigger a disconnect on
21154 * the session which the firmware reported a hand off failure
21155 * param pMac global structure
21156 * param pMsgBuf - Contains the session ID for which the handler should apply
21157 */
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080021158void csr_process_ho_fail_ind(tpAniSirGlobal mac_ctx, void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021159{
21160 tSirSmeHOFailureInd *pSmeHOFailInd = (tSirSmeHOFailureInd *) pMsgBuf;
21161 uint32_t sessionId;
21162
21163 if (pSmeHOFailInd)
21164 sessionId = pSmeHOFailInd->sessionId;
21165 else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021166 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021167 "LFR3: Hand-Off Failure Ind is NULL");
21168 return;
21169 }
21170 /* Roaming is supported only on Infra STA Mode. */
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080021171 if (!csr_roam_is_sta_mode(mac_ctx, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021172 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021173 "LFR3:HO Fail cannot be handled for session %d",
21174 sessionId);
21175 return;
21176 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080021177 mac_ctx->sme.set_connection_info_cb(false);
21178 csr_roam_roaming_offload_timer_action(mac_ctx, 0, sessionId,
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070021179 ROAMING_OFFLOAD_TIMER_STOP);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080021180 csr_roam_call_callback(mac_ctx, sessionId, NULL, 0,
Abhishek Singh533c9da2017-05-04 10:23:34 +053021181 eCSR_ROAM_NAPI_OFF, eCSR_ROAM_RESULT_FAILURE);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080021182 csr_roam_synch_clean_up(mac_ctx, sessionId);
21183 csr_roaming_report_diag_event(mac_ctx, NULL,
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080021184 eCSR_REASON_ROAM_HO_FAIL);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021185 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021186 "LFR3:Issue Disconnect on session %d", sessionId);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080021187 csr_roam_disconnect(mac_ctx, sessionId,
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -070021188 eCSR_DISCONNECT_REASON_ROAM_HO_FAIL);
Agrawal Ashishc416da62017-04-10 15:12:46 +053021189 if (mac_ctx->roam.configParam.enable_fatal_event)
Agrawal Ashish87ec5d42017-06-15 15:22:19 +053021190 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
Agrawal Ashishc416da62017-04-10 15:12:46 +053021191 WLAN_LOG_INDICATOR_HOST_DRIVER,
21192 WLAN_LOG_REASON_ROAM_HO_FAILURE,
21193 true, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021194}
21195#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
21196
21197/**
21198 * csr_update_op_class_array() - update op class for each band
21199 * @mac_ctx: mac global context
21200 * @op_classes: out param, operating class array to update
21201 * @channel_info: channel info
21202 * @ch_name: channel band name to display in debug messages
21203 * @i: out param, stores number of operating classes
21204 *
21205 * Return: void
21206 */
21207static void
21208csr_update_op_class_array(tpAniSirGlobal mac_ctx,
21209 uint8_t *op_classes,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021210 struct csr_channel *channel_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021211 char *ch_name,
21212 uint8_t *i)
21213{
21214 uint8_t j = 0, idx = 0, class = 0;
21215 bool found = false;
21216 uint8_t num_channels = channel_info->numChannels;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053021217 uint8_t ch_bandwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021218
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021219 sme_debug("Num of %s channels, %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021220 ch_name, num_channels);
21221
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070021222 for (idx = 0; idx < num_channels &&
21223 *i < (REG_MAX_SUPP_OPER_CLASSES - 1); idx++) {
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053021224 for (ch_bandwidth = BW20; ch_bandwidth < BWALL;
21225 ch_bandwidth++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070021226 class = wlan_reg_dmn_get_opclass_from_channel(
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053021227 mac_ctx->scan.countryCodeCurrent,
21228 channel_info->channelList[idx],
21229 ch_bandwidth);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021230 sme_debug("for chan %d, op class: %d",
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053021231 channel_info->channelList[idx], class);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021232
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053021233 found = false;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070021234 for (j = 0; j < REG_MAX_SUPP_OPER_CLASSES - 1;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053021235 j++) {
21236 if (op_classes[j] == class) {
21237 found = true;
21238 break;
21239 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021240 }
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053021241
21242 if (!found) {
21243 op_classes[*i] = class;
21244 *i = *i + 1;
21245 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021246 }
21247 }
21248}
21249
21250/**
21251 * csr_update_op_class_array() - update op class for all bands
21252 * @hHal: global hal context
21253 *
21254 * Return: void
21255 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021256static void csr_init_operating_classes(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021257{
21258 uint8_t i = 0;
21259 uint8_t j = 0;
21260 uint8_t swap = 0;
21261 uint8_t numClasses = 0;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070021262 uint8_t opClasses[REG_MAX_SUPP_OPER_CLASSES] = {0,};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021263 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
21264
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021265 sme_debug("Current Country = %c%c",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021266 pMac->scan.countryCodeCurrent[0],
21267 pMac->scan.countryCodeCurrent[1]);
21268
21269 csr_update_op_class_array(pMac, opClasses,
21270 &pMac->scan.base_channels, "20MHz", &i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021271 numClasses = i;
21272
21273 /* As per spec the operating classes should be in ascending order.
21274 * Bubble sort is fine since we don't have many classes
21275 */
21276 for (i = 0; i < (numClasses - 1); i++) {
21277 for (j = 0; j < (numClasses - i - 1); j++) {
21278 /* For decreasing order use < */
21279 if (opClasses[j] > opClasses[j + 1]) {
21280 swap = opClasses[j];
21281 opClasses[j] = opClasses[j + 1];
21282 opClasses[j + 1] = swap;
21283 }
21284 }
21285 }
21286
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021287 sme_debug("Number of unique supported op classes %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021288 numClasses);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021289 for (i = 0; i < numClasses; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021290 sme_debug("supported opClasses[%d] = %d", i, opClasses[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021291
21292 /* Set the ordered list of op classes in regdomain
21293 * for use by other modules
21294 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070021295 wlan_reg_dmn_set_curr_opclasses(numClasses, &opClasses[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021296}
21297
21298/**
21299 * csr_find_session_by_type() - This function will find given session type from
21300 * all sessions.
21301 * @mac_ctx: pointer to mac context.
21302 * @type: session type
21303 *
21304 * Return: session id for give session type.
21305 **/
21306static uint32_t
Jeff Johnsonc1e62782017-11-09 09:50:17 -080021307csr_find_session_by_type(tpAniSirGlobal mac_ctx, enum QDF_OPMODE type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021308{
21309 uint32_t i, session_id = CSR_SESSION_ID_INVALID;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021310 struct csr_roam_session *session_ptr;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021312 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
21313 if (!CSR_IS_SESSION_VALID(mac_ctx, i))
21314 continue;
21315
21316 session_ptr = CSR_GET_SESSION(mac_ctx, i);
21317 if (type == session_ptr->bssParams.bssPersona) {
21318 session_id = i;
21319 break;
21320 }
21321 }
21322 return session_id;
21323}
21324/**
Chaoli Zhou75b062f2018-06-11 12:36:54 +080021325 * csr_find_session_by_bssid() - This function will find given bssid from
21326 * all sessions.
21327 * @mac_ctx: pointer to mac context.
21328 * @bssid: session bssid
21329 * Return: false or true.
21330 **/
21331bool
21332csr_find_session_by_bssid(tpAniSirGlobal mac_ctx, uint8_t *bssid)
21333{
21334 tpPESession session_entry;
21335 uint8_t session_id; /* PE session_id */
21336
21337 session_entry = pe_find_session_by_bssid(mac_ctx,
21338 bssid, &session_id);
21339 if (session_entry)
21340 return true;
21341 else
21342 return false;
21343}
21344
21345/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021346 * csr_is_conn_allow_2g_band() - This function will check if station's conn
21347 * is allowed in 2.4Ghz band.
21348 * @mac_ctx: pointer to mac context.
21349 * @chnl: station's channel.
21350 *
21351 * This function will check if station's connection is allowed in 5Ghz band
21352 * after comparing it with SAP's operating channel. If SAP's operating
21353 * channel and Station's channel is different than this function will return
21354 * false else true.
21355 *
21356 * Return: true or false.
21357 **/
21358static bool csr_is_conn_allow_2g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
21359{
21360 uint32_t sap_session_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021361 struct csr_roam_session *sap_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021362
21363 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021364 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021365 FL("channel is zero, connection not allowed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021366
21367 return false;
21368 }
21369
Anurag Chouhan6d760662016-02-20 16:05:43 +053021370 sap_session_id = csr_find_session_by_type(mac_ctx, QDF_SAP_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021371 if (CSR_SESSION_ID_INVALID != sap_session_id) {
21372 sap_session = CSR_GET_SESSION(mac_ctx, sap_session_id);
21373 if ((0 != sap_session->bssParams.operationChn) &&
21374 (sap_session->bssParams.operationChn != chnl)) {
21375
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021376 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021377 "Can't allow STA to connect, chnls not same");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021378 return false;
21379 }
21380 }
21381 return true;
21382}
21383
21384/**
21385 * csr_is_conn_allow_5g_band() - This function will check if station's conn
21386 * is allowed in 5Ghz band.
21387 * @mac_ctx: pointer to mac context.
21388 * @chnl: station's channel.
21389 *
21390 * This function will check if station's connection is allowed in 5Ghz band
21391 * after comparing it with P2PGO's operating channel. If P2PGO's operating
21392 * channel and Station's channel is different than this function will return
21393 * false else true.
21394 *
21395 * Return: true or false.
21396 **/
21397static bool csr_is_conn_allow_5g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
21398{
21399 uint32_t p2pgo_session_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021400 struct csr_roam_session *p2pgo_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021401
21402 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021403 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021404 FL("channel is zero, connection not allowed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021405 return false;
21406 }
21407
Anurag Chouhan6d760662016-02-20 16:05:43 +053021408 p2pgo_session_id = csr_find_session_by_type(mac_ctx, QDF_P2P_GO_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021409 if (CSR_SESSION_ID_INVALID != p2pgo_session_id) {
21410 p2pgo_session = CSR_GET_SESSION(mac_ctx, p2pgo_session_id);
21411 if ((0 != p2pgo_session->bssParams.operationChn) &&
21412 (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED !=
21413 p2pgo_session->connectState) &&
21414 (p2pgo_session->bssParams.operationChn !=
21415 chnl)) {
21416
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021417 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053021418 "Can't allow STA to connect, chnls not same");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021419 return false;
21420 }
21421 }
21422 return true;
21423}
21424
21425/**
21426 * csr_clear_joinreq_param() - This function will clear station's params
21427 * for stored join request to csr.
21428 * @hal_handle: pointer to hal context.
21429 * @session_id: station's session id.
21430 *
21431 * This function will clear station's allocated memory for cached join
21432 * request.
21433 *
21434 * Return: true or false based on function's overall success.
21435 **/
21436bool csr_clear_joinreq_param(tpAniSirGlobal mac_ctx,
21437 uint32_t session_id)
21438{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021439 struct csr_roam_session *sta_session;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053021440 struct scan_result_list *bss_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021441
21442 if (NULL == mac_ctx)
21443 return false;
21444
21445 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
21446 if (NULL == sta_session)
21447 return false;
21448
21449 /* Release the memory allocated by previous join request */
21450 bss_list =
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053021451 (struct scan_result_list *)&sta_session->stored_roam_profile.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021452 bsslist_handle;
21453 if (NULL != bss_list) {
21454 csr_scan_result_purge(mac_ctx,
21455 sta_session->stored_roam_profile.bsslist_handle);
Abhishek Singh245182f2017-08-10 17:41:09 +053021456 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021457 FL("bss list is released for session %d"), session_id);
21458 sta_session->stored_roam_profile.bsslist_handle = NULL;
21459 }
21460 sta_session->stored_roam_profile.bsslist_handle = NULL;
21461 csr_release_profile(mac_ctx, &sta_session->stored_roam_profile.profile);
21462 sta_session->stored_roam_profile.reason = 0;
21463 sta_session->stored_roam_profile.roam_id = 0;
21464 sta_session->stored_roam_profile.imediate_flag = false;
21465 sta_session->stored_roam_profile.clear_flag = false;
21466 return true;
21467}
21468
21469/**
21470 * csr_store_joinreq_param() - This function will store station's join
21471 * request to that station's session.
21472 * @mac_ctx: pointer to mac context.
21473 * @profile: pointer to station's roam profile.
21474 * @scan_cache: pointer to station's scan cache.
21475 * @roam_id: reference to roam_id variable being passed.
21476 * @session_id: station's session id.
21477 *
21478 * This function will store station's join request to one of the
21479 * csr structure and add it to station's session.
21480 *
21481 * Return: true or false based on function's overall success.
21482 **/
21483bool csr_store_joinreq_param(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070021484 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021485 tScanResultHandle scan_cache,
21486 uint32_t *roam_id,
21487 uint32_t session_id)
21488{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021489 struct csr_roam_session *sta_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021490
21491 if (NULL == mac_ctx)
21492 return false;
21493
21494 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
21495 if (NULL == sta_session)
21496 return false;
21497
21498 sta_session->stored_roam_profile.session_id = session_id;
21499 csr_roam_copy_profile(mac_ctx,
21500 &sta_session->stored_roam_profile.profile, profile);
21501 /* new bsslist_handle's memory will be relased later */
21502 sta_session->stored_roam_profile.bsslist_handle = scan_cache;
21503 sta_session->stored_roam_profile.reason = eCsrHddIssued;
21504 sta_session->stored_roam_profile.roam_id = *roam_id;
21505 sta_session->stored_roam_profile.imediate_flag = false;
21506 sta_session->stored_roam_profile.clear_flag = false;
21507
21508 return true;
21509}
21510
21511/**
21512 * csr_issue_stored_joinreq() - This function will issues station's stored
21513 * the join request.
21514 * @mac_ctx: pointer to mac context.
21515 * @roam_id: reference to roam_id variable being passed.
21516 * @session_id: station's session id.
21517 *
21518 * This function will issue station's stored join request, from this point
21519 * onwards the flow will be just like normal connect request.
21520 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021521 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021522 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021523QDF_STATUS csr_issue_stored_joinreq(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021524 uint32_t *roam_id,
21525 uint32_t session_id)
21526{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021527 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021528 struct csr_roam_session *sta_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021529 uint32_t new_roam_id;
21530
21531 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
21532 if (NULL == sta_session)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021533 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021534 new_roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
21535 *roam_id = new_roam_id;
21536 status = csr_roam_issue_connect(mac_ctx,
21537 sta_session->stored_roam_profile.session_id,
21538 &sta_session->stored_roam_profile.profile,
21539 sta_session->stored_roam_profile.bsslist_handle,
21540 sta_session->stored_roam_profile.reason,
21541 new_roam_id,
21542 sta_session->stored_roam_profile.imediate_flag,
21543 sta_session->stored_roam_profile.clear_flag);
Will Huang8e8d3002018-05-11 10:48:03 +080021544
21545 sta_session->stored_roam_profile.bsslist_handle =
21546 CSR_INVALID_SCANRESULT_HANDLE;
21547
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021548 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021549 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021550 FL
21551 ("CSR failed issuing connect cmd with status = 0x%08X"),
21552 status);
21553 csr_clear_joinreq_param(mac_ctx, session_id);
21554 }
21555 return status;
21556}
21557
21558/**
21559 * csr_process_set_hw_mode() - Set HW mode command to PE
21560 * @mac: Globacl MAC pointer
21561 * @command: Command received from SME
21562 *
21563 * Posts the set HW mode command to PE. This message passing
21564 * through PE is required for PE's internal management
21565 *
21566 * Return: None
21567 */
21568void csr_process_set_hw_mode(tpAniSirGlobal mac, tSmeCmd *command)
21569{
21570 uint32_t len;
yeshwanth sriram guntukad4b482a2017-03-27 12:51:46 +053021571 struct s_sir_set_hw_mode *cmd = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021572 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070021573 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021574 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021575 enum policy_mgr_hw_mode_change hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021576
21577 /* Setting HW mode is for the entire system.
21578 * So, no need to check session
21579 */
21580
21581 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021582 sme_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021583 goto fail;
21584 }
21585
21586 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021587 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021588 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021589 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021590 /* Probably the fail response will also fail during malloc.
21591 * Still proceeding to send response!
21592 */
21593 goto fail;
21594 }
21595
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053021596 /* For hidden SSID case, if there is any scan command pending
21597 * it needs to be cleared before issuing set HW mode
21598 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021599 if (command->u.set_hw_mode_cmd.reason ==
21600 POLICY_MGR_UPDATE_REASON_HIDDEN_STA) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021601 sme_err("clear any pending scan command");
Abhishek Singh9fabbbb2018-01-29 17:38:36 +053021602 status = csr_scan_abort_mac_scan(mac,
21603 command->u.set_hw_mode_cmd.session_id, INVAL_SCAN_ID);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021604 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021605 sme_err("Failed to clear scan cmd");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053021606 goto fail;
21607 }
21608 }
21609
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021610 if ((POLICY_MGR_UPDATE_REASON_OPPORTUNISTIC ==
21611 command->u.set_hw_mode_cmd.reason) &&
21612 (true == mac->sme.get_connection_info_cb(NULL, NULL))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021613 sme_err("Set HW mode refused: conn in progress");
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021614 policy_mgr_restart_opportunistic_timer(mac->psoc, false);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021615 goto fail;
21616 }
21617
Tushnim Bhattacharyya356d46e2018-02-14 10:56:58 -080021618 if ((POLICY_MGR_UPDATE_REASON_OPPORTUNISTIC ==
21619 command->u.set_hw_mode_cmd.reason) &&
21620 (!command->u.set_hw_mode_cmd.hw_mode_index &&
21621 !policy_mgr_need_opportunistic_upgrade(mac->psoc))) {
21622 sme_err("Set HW mode to SMM not needed anymore");
21623 goto fail;
21624 }
21625
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021626 hw_mode = policy_mgr_get_hw_mode_change_from_hw_mode_index(
21627 mac->psoc, command->u.set_hw_mode_cmd.hw_mode_index);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021628
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021629 if (POLICY_MGR_HW_MODE_NOT_IN_PROGRESS == hw_mode) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070021630 sme_err("hw_mode %d, failing", hw_mode);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021631 goto fail;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021632 }
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021633
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021634 policy_mgr_set_hw_mode_change_in_progress(mac->psoc, hw_mode);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021636 cmd->messageType = eWNI_SME_SET_HW_MODE_REQ;
21637 cmd->length = len;
21638 cmd->set_hw.hw_mode_index = command->u.set_hw_mode_cmd.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053021639 cmd->set_hw.reason = command->u.set_hw_mode_cmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021640 /*
21641 * Below callback and context info are not needed for PE as of now.
21642 * Storing the passed value in the same s_sir_set_hw_mode format.
21643 */
21644 cmd->set_hw.set_hw_mode_cb = command->u.set_hw_mode_cmd.set_hw_mode_cb;
21645
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021646 sme_debug(
21647 "Posting set hw mode req to PE session:%d reason:%d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053021648 command->u.set_hw_mode_cmd.session_id,
21649 command->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021650
Rajeev Kumard138ac52017-01-30 18:38:37 -080021651 status = umac_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021652 if (QDF_STATUS_SUCCESS != status) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021653 policy_mgr_set_hw_mode_change_in_progress(mac->psoc,
21654 POLICY_MGR_HW_MODE_NOT_IN_PROGRESS);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021655 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021656 return;
21657 }
21658 return;
21659fail:
yeshwanth sriram guntukad4b482a2017-03-27 12:51:46 +053021660 if (cmd)
21661 qdf_mem_free(cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021662 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021663 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021664 sme_err(
21665 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021666 return;
21667 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021668 sme_err("Sending set HW fail response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021669 param->status = SET_HW_MODE_STATUS_ECANCELED;
21670 param->cfgd_hw_mode_index = 0;
21671 param->num_vdev_mac_entries = 0;
21672 msg.type = eWNI_SME_SET_HW_MODE_RESP;
21673 msg.bodyptr = param;
21674 msg.bodyval = 0;
21675 sys_process_mmh_msg(mac, &msg);
21676}
21677
21678/**
21679 * csr_process_set_dual_mac_config() - Set HW mode command to PE
21680 * @mac: Global MAC pointer
21681 * @command: Command received from SME
21682 *
21683 * Posts the set dual mac config command to PE.
21684 *
21685 * Return: None
21686 */
21687void csr_process_set_dual_mac_config(tpAniSirGlobal mac, tSmeCmd *command)
21688{
21689 uint32_t len;
21690 struct sir_set_dual_mac_cfg *cmd;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021691 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070021692 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021693 struct sir_dual_mac_config_resp *param;
21694
21695 /* Setting MAC configuration is for the entire system.
21696 * So, no need to check session
21697 */
21698
21699 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021700 sme_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021701 goto fail;
21702 }
21703
21704 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021705 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021706 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021707 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021708 /* Probably the fail response will also fail during malloc.
21709 * Still proceeding to send response!
21710 */
21711 goto fail;
21712 }
21713
21714 cmd->message_type = eWNI_SME_SET_DUAL_MAC_CFG_REQ;
21715 cmd->length = len;
21716 cmd->set_dual_mac.scan_config = command->u.set_dual_mac_cmd.scan_config;
21717 cmd->set_dual_mac.fw_mode_config =
21718 command->u.set_dual_mac_cmd.fw_mode_config;
21719 /*
21720 * Below callback and context info are not needed for PE as of now.
21721 * Storing the passed value in the same sir_set_dual_mac_cfg format.
21722 */
21723 cmd->set_dual_mac.set_dual_mac_cb =
21724 command->u.set_dual_mac_cmd.set_dual_mac_cb;
21725
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021726 sme_debug(
21727 "Posting eWNI_SME_SET_DUAL_MAC_CFG_REQ to PE: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021728 cmd->set_dual_mac.scan_config,
21729 cmd->set_dual_mac.fw_mode_config);
21730
Rajeev Kumard138ac52017-01-30 18:38:37 -080021731 status = umac_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021732 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021733 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021734 return;
21735 }
21736 return;
21737fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021738 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021739 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021740 sme_err(
21741 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021742 return;
21743 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021744 sme_err("Sending set dual mac fail response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021745 param->status = SET_HW_MODE_STATUS_ECANCELED;
21746 msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
21747 msg.bodyptr = param;
21748 msg.bodyval = 0;
21749 sys_process_mmh_msg(mac, &msg);
21750}
21751
21752/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021753 * csr_process_set_antenna_mode() - Set antenna mode command to
21754 * PE
21755 * @mac: Global MAC pointer
21756 * @command: Command received from SME
21757 *
21758 * Posts the set dual mac config command to PE.
21759 *
21760 * Return: None
21761 */
21762void csr_process_set_antenna_mode(tpAniSirGlobal mac, tSmeCmd *command)
21763{
21764 uint32_t len;
21765 struct sir_set_antenna_mode *cmd;
21766 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070021767 struct scheduler_msg msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021768 struct sir_antenna_mode_resp *param;
21769
21770 /* Setting MAC configuration is for the entire system.
21771 * So, no need to check session
21772 */
21773
21774 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021775 sme_err("Set antenna mode param is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021776 goto fail;
21777 }
21778
21779 len = sizeof(*cmd);
21780 cmd = qdf_mem_malloc(len);
21781 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021782 sme_err("Memory allocation failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021783 goto fail;
21784 }
21785
21786 cmd->message_type = eWNI_SME_SET_ANTENNA_MODE_REQ;
21787 cmd->length = len;
21788 cmd->set_antenna_mode = command->u.set_antenna_mode_cmd;
21789
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021790 sme_debug(
21791 "Posting eWNI_SME_SET_ANTENNA_MODE_REQ to PE: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021792 cmd->set_antenna_mode.num_rx_chains,
21793 cmd->set_antenna_mode.num_tx_chains);
21794
Rajeev Kumard138ac52017-01-30 18:38:37 -080021795 status = umac_send_mb_message_to_mac(cmd);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021796 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021797 sme_err("Posting to PE failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021798 /*
Rajeev Kumard138ac52017-01-30 18:38:37 -080021799 * umac_send_mb_message_to_mac would've released the mem
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021800 * allocated by cmd.
21801 */
21802 goto fail;
21803 }
21804
21805 return;
21806fail:
21807 param = qdf_mem_malloc(sizeof(*param));
21808 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021809 sme_err(
21810 "Malloc fail: Fail to send response to SME");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021811 return;
21812 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021813 sme_err("Sending set dual mac fail response to SME");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021814 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
21815 msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
21816 msg.bodyptr = param;
21817 msg.bodyval = 0;
21818 sys_process_mmh_msg(mac, &msg);
21819}
21820
21821/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021822 * csr_process_nss_update_req() - Update nss command to PE
21823 * @mac: Globacl MAC pointer
21824 * @command: Command received from SME
21825 *
21826 * Posts the nss update command to PE. This message passing
21827 * through PE is required for PE's internal management
21828 *
21829 * Return: None
21830 */
21831void csr_process_nss_update_req(tpAniSirGlobal mac, tSmeCmd *command)
21832{
21833 uint32_t len;
21834 struct sir_nss_update_request *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021835 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070021836 struct scheduler_msg msg_return = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021837 struct sir_beacon_tx_complete_rsp *param;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021838 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021840
Naveen Rawat7ecf53d2016-06-27 15:31:48 -070021841 if (!CSR_IS_SESSION_VALID(mac, command->sessionId)) {
Varun Reddy Yeturu84c497b2017-09-19 15:36:22 -070021842 sme_err("Invalid session id %d", command->sessionId);
21843 goto fail;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -070021844 }
21845 session = CSR_GET_SESSION(mac, command->sessionId);
21846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021847 len = sizeof(*msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021848 msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021849 if (!msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021850 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021851 /* Probably the fail response is also fail during malloc.
21852 * Still proceeding to send response!
21853 */
21854 goto fail;
21855 }
21856
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021857 msg->msgType = eWNI_SME_NSS_UPDATE_REQ;
21858 msg->msgLen = sizeof(*msg);
21859
21860 msg->new_nss = command->u.nss_update_cmd.new_nss;
21861 msg->vdev_id = command->u.nss_update_cmd.session_id;
21862
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021863 sme_debug("Posting eWNI_SME_NSS_UPDATE_REQ to PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021864
Rajeev Kumard138ac52017-01-30 18:38:37 -080021865 status = umac_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021866 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021867 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021868 return;
21869 }
21870 return;
21871fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021872 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021873 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021874 sme_err(
21875 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021876 return;
21877 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021878 sme_err("Sending nss update fail response to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021879 param->tx_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021880 param->session_id = command->u.nss_update_cmd.session_id;
21881 msg_return.type = eWNI_SME_NSS_UPDATE_RSP;
21882 msg_return.bodyptr = param;
21883 msg_return.bodyval = 0;
21884 sys_process_mmh_msg(mac, &msg_return);
21885}
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021886#ifdef FEATURE_WLAN_TDLS
21887/**
21888 * csr_roam_fill_tdls_info() - Fill TDLS information
21889 * @roam_info: Roaming information buffer
21890 * @join_rsp: Join response which has TDLS info
21891 *
21892 * Return: None
21893 */
Jeff Johnson172237b2017-11-07 15:32:59 -080021894void csr_roam_fill_tdls_info(tpAniSirGlobal mac_ctx,
21895 struct csr_roam_info *roam_info,
21896 tpSirSmeJoinRsp join_rsp)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021897{
21898 roam_info->tdls_prohibited = join_rsp->tdls_prohibited;
21899 roam_info->tdls_chan_swit_prohibited =
21900 join_rsp->tdls_chan_swit_prohibited;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021901 sme_debug(
21902 "tdls:prohibit: %d, chan_swit_prohibit: %d",
Kabilan Kannan32eb5022016-10-04 12:24:50 -070021903 roam_info->tdls_prohibited,
21904 roam_info->tdls_chan_swit_prohibited);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021905}
21906#endif
21907
Sridhar Selvaraje5260442017-08-19 10:12:03 +053021908#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Jeff Johnson172237b2017-11-07 15:32:59 -080021909static void csr_copy_fils_join_rsp_roam_info(struct csr_roam_info *roam_info,
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021910 roam_offload_synch_ind *roam_synch_data)
21911{
21912 struct fils_join_rsp_params *roam_fils_info;
21913
21914 roam_info->fils_join_rsp = qdf_mem_malloc(sizeof(*roam_fils_info));
21915 if (!roam_info->fils_join_rsp) {
21916 sme_err("fils_join_rsp malloc fails!");
21917 return;
21918 }
21919
21920 roam_fils_info = roam_info->fils_join_rsp;
21921 cds_copy_hlp_info(&roam_synch_data->dst_mac,
21922 &roam_synch_data->src_mac,
21923 roam_synch_data->hlp_data_len,
21924 roam_synch_data->hlp_data,
21925 &roam_fils_info->dst_mac,
21926 &roam_fils_info->src_mac,
21927 &roam_fils_info->hlp_data_len,
21928 roam_fils_info->hlp_data);
21929}
21930#else
Jeff Johnson172237b2017-11-07 15:32:59 -080021931static inline
21932void csr_copy_fils_join_rsp_roam_info(struct csr_roam_info *roam_info,
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021933 roam_offload_synch_ind *roam_synch_data)
21934{}
21935#endif
21936
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080021937#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Naveen Rawat257386f2017-05-17 11:42:18 -070021938static QDF_STATUS csr_process_roam_sync_callback(tpAniSirGlobal mac_ctx,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021939 roam_offload_synch_ind *roam_synch_data,
Naveen Rawat257386f2017-05-17 11:42:18 -070021940 tpSirBssDescription bss_desc, enum sir_roam_op_code reason)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021941{
21942 uint8_t session_id = roam_synch_data->roamedVdevId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021943 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021944 tDot11fBeaconIEs *ies_local = NULL;
21945 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
Jeff Johnson172237b2017-11-07 15:32:59 -080021946 struct csr_roam_info *roam_info;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021947 tCsrRoamConnectedProfile *conn_profile = NULL;
21948 sme_QosAssocInfo assoc_info;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021949 tpAddBssParams add_bss_params;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021950 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070021951 uint16_t len;
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +053021952#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
21953 tSirSmeHTProfile *src_profile = NULL;
21954 tCsrRoamHTProfile *dst_profile = NULL;
21955#endif
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021956
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021957 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021958 sme_err("LFR3: Session not found");
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021959 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021960 }
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +053021961
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021962 sme_debug("LFR3: reason: %d", reason);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070021963 switch (reason) {
21964 case SIR_ROAMING_DEREGISTER_STA:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070021965 /*
21966 * The following is the first thing done in CSR
21967 * after receiving RSI. Hence stopping the timer here.
21968 */
21969 csr_roam_roaming_offload_timer_action(mac_ctx,
21970 0, session_id, ROAMING_OFFLOAD_TIMER_STOP);
Abhishek Singhd5686472017-09-20 15:18:50 +053021971 if (session->discon_in_progress ||
21972 !CSR_IS_ROAM_JOINED(mac_ctx, session_id)) {
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021973 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhd5686472017-09-20 15:18:50 +053021974 FL("LFR3: Session not in connected state or disconnect is in progress %d"),
21975 session->discon_in_progress);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021976 return QDF_STATUS_E_FAILURE;
21977 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021978 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070021979 eCSR_ROAM_FT_START, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021980 return status;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021981 case SIR_ROAMING_START:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070021982 csr_roam_roaming_offload_timer_action(mac_ctx,
21983 CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD, session_id,
21984 ROAMING_OFFLOAD_TIMER_START);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070021985 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070021986 eCSR_ROAM_START, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu85090c92018-01-26 15:06:02 -080021987 wlan_abort_scan(mac_ctx->pdev, INVAL_PDEV_ID,
21988 session_id, INVAL_SCAN_ID, false);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021989 return status;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021990 case SIR_ROAMING_ABORT:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070021991 csr_roam_roaming_offload_timer_action(mac_ctx,
21992 0, session_id, ROAMING_OFFLOAD_TIMER_STOP);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070021993 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070021994 eCSR_ROAM_ABORT, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021995 return status;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070021996 case SIR_ROAM_SYNCH_NAPI_OFF:
21997 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070021998 eCSR_ROAM_NAPI_OFF, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021999 return status;
Arif Hussain43354e62017-05-24 11:24:25 -070022000 case SIR_ROAMING_INVOKE_FAIL:
Arif Hussain43354e62017-05-24 11:24:25 -070022001 /* Userspace roam request failed, disconnect with current AP */
22002 sme_debug("LFR3: roam invoke from user-space fail, dis cur AP");
22003 csr_roam_disconnect(mac_ctx, session_id,
22004 eCSR_DISCONNECT_REASON_DEAUTH);
22005 return status;
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070022006 case SIR_ROAM_SYNCH_PROPAGATION:
22007 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070022008 case SIR_ROAM_SYNCH_COMPLETE:
22009 /*
22010 * Following operations need to be done once roam sync
22011 * completion is sent to FW, hence called here:
22012 * 1) Firmware has already updated DBS policy. Update connection
22013 * table in the host driver.
22014 * 2) Force SCC switch if needed
22015 * 3) Set connection in progress = false
22016 */
22017 /* first update connection info from wma interface */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080022018 policy_mgr_update_connection_info(mac_ctx->psoc, session_id);
Naveen Rawat8cc23b02016-07-14 12:22:56 -070022019 /* then update remaining parameters from roam sync ctx */
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070022020 sme_debug("Update DBS hw mode");
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080022021 policy_mgr_hw_mode_transition_cb(
Naveen Rawat8cc23b02016-07-14 12:22:56 -070022022 roam_synch_data->hw_mode_trans_ind.old_hw_mode_index,
22023 roam_synch_data->hw_mode_trans_ind.new_hw_mode_index,
22024 roam_synch_data->hw_mode_trans_ind.num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080022025 roam_synch_data->hw_mode_trans_ind.vdev_mac_map,
22026 mac_ctx->psoc);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080022027 mac_ctx->sme.set_connection_info_cb(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -070022028 session->roam_synch_in_progress = false;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080022029 policy_mgr_check_concurrent_intf_and_restart_sap(mac_ctx->psoc);
Selvaraj, Sridhar50566502017-05-15 18:26:47 +053022030 csr_roam_offload_scan(mac_ctx, session_id,
22031 ROAM_SCAN_OFFLOAD_START,
22032 REASON_CONNECT);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070022033 return status;
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070022034 default:
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070022035 sme_debug("LFR3: callback reason %d", reason);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070022036 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022037 }
Arif Hussain557920f2016-09-07 16:03:46 -070022038 session->roam_synch_in_progress = true;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022039 session->roam_synch_data = roam_synch_data;
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070022040 status = csr_get_parsed_bss_description_ies(
22041 mac_ctx, bss_desc, &ies_local);
22042 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070022043 sme_err("LFR3: fail to parse IEs");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022044 session->roam_synch_in_progress = false;
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070022045 return status;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022046 }
22047 conn_profile = &session->connectedProfile;
22048 csr_roam_stop_network(mac_ctx, session_id,
22049 session->pCurRoamProfile,
22050 bss_desc,
22051 ies_local);
22052 ps_global_info->remain_in_power_active_till_dhcp = false;
22053 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
Jeff Johnson172237b2017-11-07 15:32:59 -080022054 roam_info = qdf_mem_malloc(sizeof(struct csr_roam_info));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022055 if (NULL == roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053022056 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022057 FL("LFR3: Mem Alloc failed for roam info"));
22058 session->roam_synch_in_progress = false;
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053022059 qdf_mem_free(ies_local);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070022060 return QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022061 }
22062 csr_scan_save_roam_offload_ap_to_scan_cache(mac_ctx, roam_synch_data,
22063 bss_desc);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022064 roam_info->sessionId = session_id;
Frank Liud1a28462017-09-06 22:55:48 +080022065 tgt_tdls_peers_deleted_notification(mac_ctx->psoc, session_id);
22066
Anurag Chouhan600c3a02016-03-01 10:33:54 +053022067 qdf_mem_copy(&roam_info->bssid.bytes, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053022068 sizeof(struct qdf_mac_addr));
Jeff Johnson536249f2018-05-12 16:48:38 -070022069 csr_roam_save_connected_information(mac_ctx, session_id,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022070 session->pCurRoamProfile,
22071 bss_desc,
22072 ies_local);
22073 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
22074 session->pCurRoamProfile->negotiatedAuthType,
22075 bss_desc, ies_local);
Yu Wang0477ee32017-02-10 20:02:03 +080022076
22077#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022078 roam_info->isESEAssoc = conn_profile->isESEAssoc;
Yu Wang0477ee32017-02-10 20:02:03 +080022079#endif
Prakash Dhavalif3287ef2016-11-28 17:56:33 -080022080
22081 /*
22082 * Encryption keys for new connection are obtained as follows:
22083 * authStatus = CSR_ROAM_AUTH_STATUS_AUTHENTICATED
22084 * Open - No keys required.
22085 * Static WEP - Firmware copies keys from old AP to new AP.
22086 * Fast roaming authentications e.g. PSK, FT, CCKM - firmware
22087 * supplicant obtains them through 4-way handshake.
22088 *
22089 * authStatus = CSR_ROAM_AUTH_STATUS_CONNECTED
22090 * All other authentications - Host supplicant performs EAPOL
22091 * with AP after this point and sends new keys to the driver.
22092 * Driver starts wait_for_key timer for that purpose.
22093 */
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -070022094 if (roam_synch_data->authStatus
22095 == CSR_ROAM_AUTH_STATUS_AUTHENTICATED) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053022096 QDF_TRACE(QDF_MODULE_ID_SME,
22097 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022098 FL("LFR3:Don't start waitforkey timer"));
22099 csr_roam_substate_change(mac_ctx,
22100 eCSR_ROAM_SUBSTATE_NONE, session_id);
22101 } else {
22102 roam_info->fAuthRequired = true;
22103 csr_roam_substate_change(mac_ctx,
22104 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
22105 session_id);
22106
22107 ps_global_info->remain_in_power_active_till_dhcp = true;
22108 mac_ctx->roam.WaitForKeyTimerInfo.sessionId = session_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053022109 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_wait_for_key_timer(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022110 mac_ctx, CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD))
22111 ) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070022112 sme_err("Failed wait for key timer start");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022113 csr_roam_substate_change(mac_ctx,
22114 eCSR_ROAM_SUBSTATE_NONE,
22115 session_id);
22116 }
22117 }
22118 roam_info->nBeaconLength = 0;
22119 roam_info->nAssocReqLength = roam_synch_data->reassoc_req_length -
22120 SIR_MAC_HDR_LEN_3A - SIR_MAC_REASSOC_SSID_OFFSET;
22121 roam_info->nAssocRspLength = roam_synch_data->reassocRespLength -
22122 SIR_MAC_HDR_LEN_3A;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053022123 roam_info->pbFrames = qdf_mem_malloc(roam_info->nBeaconLength +
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022124 roam_info->nAssocReqLength + roam_info->nAssocRspLength);
22125 if (NULL == roam_info->pbFrames) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070022126 sme_err("no memory available");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022127 session->roam_synch_in_progress = false;
22128 if (roam_info)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053022129 qdf_mem_free(roam_info);
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053022130 qdf_mem_free(ies_local);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070022131 return QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022132 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053022133 qdf_mem_copy(roam_info->pbFrames,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022134 (uint8_t *)roam_synch_data +
22135 roam_synch_data->reassoc_req_offset +
22136 SIR_MAC_HDR_LEN_3A + SIR_MAC_REASSOC_SSID_OFFSET,
22137 roam_info->nAssocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053022138 qdf_mem_copy(roam_info->pbFrames + roam_info->nAssocReqLength,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022139 (uint8_t *)roam_synch_data +
22140 roam_synch_data->reassocRespOffset +
22141 SIR_MAC_HDR_LEN_3A,
22142 roam_info->nAssocRspLength);
22143
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053022144 QDF_TRACE(QDF_MODULE_ID_SME,
22145 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022146 FL("LFR3:Clear Connected info"));
22147 csr_roam_free_connected_info(mac_ctx,
22148 &session->connectedInfo);
Yu Wang0477ee32017-02-10 20:02:03 +080022149 len = roam_synch_data->join_rsp->parsedRicRspLen;
22150
22151#ifdef FEATURE_WLAN_ESE
22152 len += roam_synch_data->join_rsp->tspecIeLen;
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070022153 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yu Wang0477ee32017-02-10 20:02:03 +080022154 FL("LFR3: tspecLen %d"),
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +053022155 roam_synch_data->join_rsp->tspecIeLen);
Yu Wang0477ee32017-02-10 20:02:03 +080022156#endif
22157
22158 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
22159 FL("LFR3: RIC length - %d"),
22160 roam_synch_data->join_rsp->parsedRicRspLen);
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070022161 if (len) {
22162 session->connectedInfo.pbFrames =
22163 qdf_mem_malloc(len);
22164 if (session->connectedInfo.pbFrames != NULL) {
22165 qdf_mem_copy(session->connectedInfo.pbFrames,
22166 roam_synch_data->join_rsp->frames, len);
22167 session->connectedInfo.nRICRspLength =
22168 roam_synch_data->join_rsp->parsedRicRspLen;
Yu Wang0477ee32017-02-10 20:02:03 +080022169
22170#ifdef FEATURE_WLAN_ESE
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +053022171 session->connectedInfo.nTspecIeLength =
22172 roam_synch_data->join_rsp->tspecIeLen;
Yu Wang0477ee32017-02-10 20:02:03 +080022173#endif
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070022174 }
22175 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022176 conn_profile->vht_channel_width =
22177 roam_synch_data->join_rsp->vht_channel_width;
22178 add_bss_params = (tpAddBssParams)roam_synch_data->add_bss_params;
22179 session->connectedInfo.staId = add_bss_params->staContext.staIdx;
22180 roam_info->staId = session->connectedInfo.staId;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022181 roam_info->timingMeasCap =
22182 roam_synch_data->join_rsp->timingMeasCap;
22183 roam_info->chan_info.nss = roam_synch_data->join_rsp->nss;
22184 roam_info->chan_info.rate_flags =
22185 roam_synch_data->join_rsp->max_rate_flags;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +053022186 roam_info->chan_info.ch_width =
22187 roam_synch_data->join_rsp->vht_channel_width;
Kabilan Kannan32eb5022016-10-04 12:24:50 -070022188 csr_roam_fill_tdls_info(mac_ctx, roam_info, roam_synch_data->join_rsp);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022189#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
22190 src_profile = &roam_synch_data->join_rsp->HTProfile;
22191 dst_profile = &conn_profile->HTProfile;
22192 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053022193 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022194 csr_roam_copy_ht_profile(dst_profile,
22195 src_profile);
22196#endif
22197 assoc_info.pBssDesc = bss_desc;
22198 roam_info->statusCode = eSIR_SME_SUCCESS;
22199 roam_info->reasonCode = eSIR_SME_SUCCESS;
22200 assoc_info.pProfile = session->pCurRoamProfile;
22201 mac_ctx->roam.roamSession[session_id].connectState =
22202 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
22203 sme_qos_csr_event_ind(mac_ctx, session_id,
22204 SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
22205 sme_qos_csr_event_ind(mac_ctx, session_id,
22206 SME_QOS_CSR_REASSOC_REQ, NULL);
22207 sme_qos_csr_event_ind(mac_ctx, session_id,
22208 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
22209 mac_ctx->roam.roamSession[session_id].connectState =
22210 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
22211 sme_qos_csr_event_ind(mac_ctx, session_id,
22212 SME_QOS_CSR_REASSOC_COMPLETE, &assoc_info);
22213 roam_info->pBssDesc = bss_desc;
22214 conn_profile->acm_mask = sme_qos_get_acm_mask(mac_ctx,
22215 bss_desc, NULL);
22216 if (conn_profile->modifyProfileFields.uapsd_mask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070022217 sme_debug(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022218 " uapsd_mask (0x%X) set, request UAPSD now",
22219 conn_profile->modifyProfileFields.uapsd_mask);
Kiran Kumar Lokere4de87552018-06-28 13:49:17 -070022220 sme_ps_start_uapsd(MAC_HANDLE(mac_ctx), session_id);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022221 }
22222 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
22223 roam_info->u.pConnectedProfile = conn_profile;
22224
Srinivas Girigowda81aef902017-03-17 09:34:19 -070022225 sme_debug(
22226 "vht ch width %d staId %d nss %d rate_flag %d dot11Mode %d",
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +053022227 conn_profile->vht_channel_width,
22228 roam_info->staId,
22229 roam_info->chan_info.nss,
22230 roam_info->chan_info.rate_flags,
22231 conn_profile->dot11Mode);
22232
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022233 if (!IS_FEATURE_SUPPORTED_BY_FW
22234 (SLM_SESSIONIZATION) &&
22235 (csr_is_concurrent_session_running(mac_ctx))) {
22236 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
22237 }
22238 roam_info->roamSynchInProgress = true;
22239 roam_info->synchAuthStatus = roam_synch_data->authStatus;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053022240 roam_info->kek_len = roam_synch_data->kek_len;
22241 roam_info->pmk_len = roam_synch_data->pmk_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053022242 qdf_mem_copy(roam_info->kck, roam_synch_data->kck, SIR_KCK_KEY_LEN);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053022243 qdf_mem_copy(roam_info->kek, roam_synch_data->kek, roam_info->kek_len);
22244
22245 if (roam_synch_data->pmk_len)
22246 qdf_mem_copy(roam_info->pmk, roam_synch_data->pmk,
22247 roam_synch_data->pmk_len);
22248
22249 qdf_mem_copy(roam_info->pmkid, roam_synch_data->pmkid, SIR_PMKID_LEN);
22250 roam_info->update_erp_next_seq_num =
22251 roam_synch_data->update_erp_next_seq_num;
22252 roam_info->next_erp_seq_num = roam_synch_data->next_erp_seq_num;
Vignesh Viswanathan8da68cf2017-09-07 14:00:04 +053022253 sme_debug("Update ERP Seq Num : %d, Next ERP Seq Num : %d",
22254 roam_info->update_erp_next_seq_num,
22255 roam_info->next_erp_seq_num);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053022256 qdf_mem_copy(roam_info->replay_ctr, roam_synch_data->replay_ctr,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022257 SIR_REPLAY_CTR_LEN);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053022258 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053022259 FL("LFR3: Copy KCK, KEK(len %d) and Replay Ctr"),
22260 roam_info->kek_len);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022261 roam_info->subnet_change_status =
22262 CSR_GET_SUBNET_STATUS(roam_synch_data->roamReason);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053022263
22264 csr_copy_fils_join_rsp_roam_info(roam_info, roam_synch_data);
22265
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022266 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
22267 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
22268 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
22269#ifdef FEATURE_WLAN_WAPI
22270 csr_reset_bkid_candidate_list(mac_ctx, session_id);
22271#endif
22272 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053022273 QDF_TRACE(QDF_MODULE_ID_SME,
22274 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022275 FL
22276 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
22277 csr_roam_link_up(mac_ctx, conn_profile->bssid);
22278 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -070022279
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022280 session->fRoaming = false;
22281 session->roam_synch_in_progress = false;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053022282 sme_free_join_rsp_fils_params(roam_info);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053022283 qdf_mem_free(roam_info->pbFrames);
22284 qdf_mem_free(roam_info);
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053022285 qdf_mem_free(ies_local);
Naveen Rawat257386f2017-05-17 11:42:18 -070022286
22287 return status;
22288}
22289
22290/**
22291 * csr_roam_synch_callback() - SME level callback for roam synch propagation
22292 * @mac_ctx: MAC Context
22293 * @roam_synch_data: Roam synch data buffer pointer
22294 * @bss_desc: BSS descriptor pointer
22295 * @reason: Reason for calling the callback
22296 *
22297 * This callback is registered with WMA and used after roaming happens in
22298 * firmware and the call to this routine completes the roam synch
22299 * propagation at both CSR and HDD levels. The HDD level propagation
22300 * is achieved through the already defined callback for assoc completion
22301 * handler.
22302 *
22303 * Return: Success or Failure.
22304 */
22305QDF_STATUS csr_roam_synch_callback(tpAniSirGlobal mac_ctx,
22306 roam_offload_synch_ind *roam_synch_data,
22307 tpSirBssDescription bss_desc, enum sir_roam_op_code reason)
22308{
22309 QDF_STATUS status;
22310
22311 status = sme_acquire_global_lock(&mac_ctx->sme);
22312 if (!QDF_IS_STATUS_SUCCESS(status)) {
22313 sme_err("LFR3: Locking failed, bailing out");
22314 return status;
22315 }
22316
22317 status = csr_process_roam_sync_callback(mac_ctx, roam_synch_data,
22318 bss_desc, reason);
22319
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022320 sme_release_global_lock(&mac_ctx->sme);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070022321
22322 return status;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080022323}
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080022324#endif